From colin at colina.demon.co.uk Sun Mar 1 01:29:19 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Mar 1 01:18:08 2009 Subject: [Haskell-cafe] Darcs or Perforce In-Reply-To: (Gwern Branwen's message of "Sat\, 28 Feb 2009 19\:28\:00 -0500") References: Message-ID: >>>>> "Gwern" == Gwern Branwen writes: Gwern> I would go for Darcs. Any advantages over Perforce? I use it at work, and find it great. So I'm using it at home too. -- Colin Adams Preston Lancashire From dons at galois.com Sun Mar 1 01:34:57 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 1 01:24:29 2009 Subject: [Haskell-cafe] missing support for NFData in uvector package In-Reply-To: <49A9EEAC.3070809@libero.it> References: <49A9EEAC.3070809@libero.it> Message-ID: <20090301063456.GA25593@whirlpool.galois.com> manlio_perillo: > Today I noticed that there is no instance declaration for NFData, in the > uvector package. > > The definition is quite simple: > > instance NFData a => NFData (UArr a) where > -- NOTE: UArr is already strict > rnf array = array `seq` () > > but it is important. > > In a my program I was using a tuple of two arrays, and plain `seq` did > not worked. Contact the author with a patch :-) -- Don (who thinks NFData should be sorted out and in base) From mle+hs at mega-nerd.com Sun Mar 1 03:21:22 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sun Mar 1 03:10:13 2009 Subject: [Haskell-cafe] Darcs or Perforce In-Reply-To: References: Message-ID: <20090301192122.eb887854.mle+hs@mega-nerd.com> Colin Paul Adams wrote: > Any advantages over Perforce? I have used Bzr, CVS, Darcs, Git, Hg (Mercurial), Perforce and SVN. While Perforce is definitely better than CVS (anything is better than CVS), Perforce's client workspace concept is a bad idea for complex projects (it bit my group of 4 developers time after time). Compared to the DVCSs above (Bzr, Darcs, Git and Hg) Perforce has no significant advantages and on significant disadvantage, cost. Yes I know there is a free as in beer version, but all of those others are available under official Open Source licenses. HTH, Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "Perl as a language has less a design than a thousand special features flying in close formation." -- From the c2 wiki From colin at colina.demon.co.uk Sun Mar 1 03:42:26 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Mar 1 03:31:16 2009 Subject: [Haskell-cafe] Can't install mkcabal because of pcre-lite Message-ID: cabal: Error: some packages failed to install: mkcabal-0.4.2 depends on pcre-light-0.3.1 which failed to install. pcre-light-0.3.1 failed during the configure step. The exception was: exit: ExitFailure 1 Downloading pcre-light-0.3.1... Configuring pcre-light-0.3.1... cabal: Missing dependency on a foreign library: * Missing C library: pcre This problem can usually be solved by installing the system package that provides this library (you may need the "-dev" version). If the library is already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where it is. I'm on fedora 10. I have package pcre installed. But yum install pcre-dev so no such package. Anyone know the anser? -- Colin Adams Preston Lancashire From wren at freegeek.org Sun Mar 1 04:07:08 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Mar 1 03:55:57 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: References: Message-ID: <49AA503C.4000506@freegeek.org> Phil wrote: | After some googling it looked like the answer may be Monad Transformers. | Specifically we could add a StateT transform for our Box Muller state to our | VanDerCorput State Monad. | Google didn?t yield a direct answer here ? so I?m not even sure if my | thinking is correct, Ignoring Daniel Fischer's astute observation that you can generalize the idea to directly describe the stream ;) The sample code you're looking for is: > {-# LANGUAGE GeneralizedNewtypeDeriving #-} > import Control.Monad.State > > > newtype VanDerCorput a = VDC (State Int a) > deriving Monad > > runVDC :: VanDerCorput a -> a > runVDC (VDC sa) = evalState sa 1 > > getVDC :: VanDerCorput Int > getVDC = VDC $ do x <- get > put (f x) > return x > where > f = (1+) > > > newtype BoxMuller a = BM (StateT (Maybe Int) VanDerCorput a) > deriving Monad > > runBM :: BoxMuller a -> a > runBM (BM vsa) = runVDC (evalStateT vsa Nothing) > > getBM :: BoxMuller Int > getBM = BM $ do saved <- get > case saved of > Just x -> put Nothing >> return x > Nothing -> do a <- lift getVDC > b <- lift getVDC > put (Just (f a b)) > return (g a b) > where > -- or whatever... > f = const > g = const id -- Live well, ~wren From colin at colina.demon.co.uk Sun Mar 1 04:08:33 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Mar 1 03:57:21 2009 Subject: [Haskell-cafe] Can't install mkcabal because of pcre-lite In-Reply-To: (Colin Paul Adams's message of "Sun\, 01 Mar 2009 08\:42\:26 +0000") References: Message-ID: >>>>> "Colin" == Colin Paul Adams writes: Colin> library: * Missing C library: pcre This problem can usually Colin> be solved by installing the system package that provides Colin> this library (you may need the "-dev" version). If the Colin> library is already installed but in a non-standard location Colin> then you can use the flags --extra-include-dirs= and Colin> --extra-lib-dirs= to specify where it is. Actually, /lib64/libcpre.so.0 /.0.0.1 exists. This is a standard location though, so it must be looking for some other library (?). -- Colin Adams Preston Lancashire From wren at freegeek.org Sun Mar 1 04:12:40 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Mar 1 04:01:29 2009 Subject: [Haskell-cafe] type universes (was Re: MPTC inheritance In-Reply-To: References: <49A437C8.9050604@solidmath.com> <49A44D54.1050303@cogito.org.uk> Message-ID: <49AA5188.9000701@freegeek.org> Larry Evans wrote: > Except that a kind sounds like a universe at level 2 or 3. > IOW, I guess haskell types are at level 1, and kines at level 2? > Then I guess values would be at level 0? Exactly. > Is there some version of haskell that has more levels in its > type universe. If not, it there some reason for that > limitation? The language you're looking for is called Omega: http://web.cecs.pdx.edu/~sheard/Omega/index.html http://code.google.com/p/omega/ http://web.cecs.pdx.edu/~sheard/ And as the name implies, the levels go all the way to the top. > Is there some reference explaining the relationship > of haskell types to nuprl type universes? That one I can't help with :) -- Live well, ~wren From jwlato at gmail.com Sun Mar 1 05:29:24 2009 From: jwlato at gmail.com (John Lato) Date: Sun Mar 1 05:18:10 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <49A9C5E4.3040704@fedoms.com> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <49A9C5E4.3040704@fedoms.com> Message-ID: <9979e72e0903010229k46d750c6ya3fb8176e44dccd4@mail.gmail.com> Hello, I'm not sure that I would call it a general-purpose resource preserving technique. As I understand it, the general concept is a means to handle strict data processing in a functional manner. Any "resource preserving" that comes from this is actually from the use of strict IO rather than lazy. I actually think it's rather like foldl' compared to foldl. John On Sat, Feb 28, 2009 at 11:16 PM, G?uenther Schmidt wrote: > So I was hopeful the above mentioned left-fold-enumerator was some sort of > general purpose resource preserving technique. I'm looking forward to study > its implementation in the future release of takusen and see if I grasp it > enough to translate it to other problems as well. From kowey at darcs.net Sun Mar 1 05:40:46 2009 From: kowey at darcs.net (Eric Y. Kow) Date: Sun Mar 1 05:29:38 2009 Subject: [Haskell-cafe] a newbies confusion with repositories - darcs or git In-Reply-To: Message-ID: <20090301104046.GB32441@Macintosh.local> Hi G?nther, > But since I have the ambition to become a real haskeller I was gonna > make myself acquainted with darcs. Should I skip that and head straight > for git? My extremely biased opinion is that you skip git and go straight for darcs ;-) Why I love darcs ================ Git is a fine revision control system; I like it and I intend to learn more about it. On the other hand, darcs does some unique, which makes it similar to Haskell (vs. other programming languages) in way, that one often has a hard time explaining to folks what it is that makes it so special (the good news is that the Haskell community is getting better and better at this! and hope that the same will happen for darcs). So let's give this a shot. Why darcs? In my opinion, the number one killer feature of darcs is that it knows how to merge changes without doing *any* guessing. It doesn't say "well, I have this patch that's supposed to tweak line number 4, but oops, I think I see that the line must have moved down to line number 7 because it looks sort of similar". Instead darcs knows with 100% certainty where the right place to apply your patch is. This is because it uses the full history of patches where everything goes. There is a lot of talk about a theory of patches, and this is largely what it's about in the darcs world, finding a precise way to talk about patches. See why some Haskellers love it? It's not just that it's written in Haskell; it's that the whole thing is driven by something which is very clean, powerful and which delivers a concrete impact in the real world. We love this kind of precision not just because we're theory-fans, but because it delivers the goods. Being able to apply and unapply patches precisely means that we can merge changes all we want -- we know that darcs will always preserve user intent -- plus we can adopt all sorts of new behaviours like cherry-picking incoming patches ("I'll take patch A, C and E; but not B and D please; oh, you tell me I can't have E without D? Very well, then") or cherry-picking changes that you want to undo ("Oops, I actually didn't mean to write that thing in line 58 and 98, but I still want to keep that thing in line 68, so I'll darcs revert them"... or "Oops, actually I've shouldn't have pulled in change C, but I still want to keep changes D E, so I'll just say 'darcs obliterate -p C' to get rid of it"). These kinds of operations happen seamlessly in darcs. There is no fuss, there is no worry; everything you can do in darcs, you can un-do. Anything you un-do in darcs, you can re-do. Darcs past, present and future ============================== So darcs has a clean theory which makes it possible to use a revision control system in a new seamless way. Why isn't everybody using it? Conflicts: It used to be the case that darcs had theoretical problems dealing with large conflicts (representing a conflict would take exponential space depending on the patches involved). It took the darcs community many years to address, but we eventually did, by releasing darcs 2. Darcs 2 repositories add enough information to the representation of conflicts which allows us to avoid the exponential blow-up most of the time. For the most part, the problem is solved. There are still cases where this blow-up can happen (we call them "conflict fights"), but they are well understood and can be avoided. In the meantime, we have some folks in the community who are doing some long-term work refining the darcs theory yet again. Performance: In addition to the conflicts problem, darcs has suffered from a lack of optimisation. (In fact, many users may have complained about patch theory problems, when they may really have been suffering more from performance issues or a mixture of the two). We have had and still have some practical day-to-day performance issues. For example, some of my larger repositories suffer when I use them on an NFS share. Rather than things being instantaneous, they would take a few seconds and I would get annoyed. Or perhaps, darcs would make too many connections over a network to fetch a lot of little files instead of sending them over in one pack. Now that darcs 2 is out, we have been focusing the bulk of our energy on tackling these basic performance problems. For other Haskellers in the room, I should point out that hacking darcs performance would be a great way for you to hone your skills and to give back to the community. No patch theory needed! Anyway, I wouldn't be too worried about performance issues. Darcs performs just fine for small to medium sized repositories. The darcs darcs repository has over 7000 patches over 6 years with over 160 contributors, no sweat. Windows: darcs support for Windows used to be a bit uneven. There were a few details here and there that none of us had time to get to (especially since none of us were using Windows). Things have gotten quite a lot better since, and we now have a dedicated Windows Czar who is helping us to bring our Windows support completely up to speed. GUIs: This too is changing, although it may take a while. Most of us are quite happy to use the command line interface to darcs, but we would love to see what kind of graphical interfaces folks will come out with in the future. In the meantime, we have recently exposed the darcs Haskell modules a sort of darcs library, which we hope will be useful to folks working on third party tools. Note that TortoiseDarcs has recently had a new release supporting darcs 2 Hosting: Aside from the haskell.org services, there was no hosting for darcs, commercial or otherwise. Now we have patch-tag.com which provides free hosting for open source projects and paid commercial hosting for private projects. So putting all this together: Darcs does precision merging, which allows you to do cool practical things like seamless merging and cherry picking (these make *my* life easier anyway). There used to be conflicts issues, but they are mostly solved. There are performance problems, but they only affect large repositories and they are getting better. There was poor Windows support, this has improved lots and has a dedicated czar. There is TortoiseDarcs if you're interested in a GUI. Hosting is available on haskell.org and patch-tag.com. Darcs and Haskell? ================== As a final note, darcs as a hacking project would be a good project to get interested in as a Haskeller. It's very much a real world program, so there are plenty of things to learn from it and plenty of things to teach it. We need lots of help. For example, we could use an army of Haskellers to scrub out our 2003 code and help us hunt down those pesky performance bugs. We now have a stable and more sustainable development team (I'm working on 20% darcs time at my job with the University of Brighton and have committed myself to spending no more than 8 hours a week on darcs to avoid burnout; a lot of our jobs have been assigned to dedicated managers -- hello!) and are adopting some new practices (hacking sprints, 6-month time based release schedule) to keep development running more smoothly. The future is bright. Come join us! Cheers, Eric P.S. Darcs will be hosting its second hacking sprint in Utrecht this 17-19 April as part of the Haskell Hackathon. It'll be a great chance to meet some darcs hackers and fix some easy bugs :-) P.P.S. All darcs patches require an inverse. Can a git user please write an inverse of this email so that G?nther can make a more informed choice? -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090301/83a2de66/attachment-0001.bin From duncan.coutts at worc.ox.ac.uk Sun Mar 1 06:42:58 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 1 06:31:55 2009 Subject: [Haskell-cafe] Can't install mkcabal because of pcre-lite In-Reply-To: References: Message-ID: <1235907778.7915.97.camel@localhost> On Sun, 2009-03-01 at 09:08 +0000, Colin Paul Adams wrote: > >>>>> "Colin" == Colin Paul Adams writes: > > Colin> library: * Missing C library: pcre This problem can usually > Colin> be solved by installing the system package that provides > Colin> this library (you may need the "-dev" version). If the > Colin> library is already installed but in a non-standard location > Colin> then you can use the flags --extra-include-dirs= and > Colin> --extra-lib-dirs= to specify where it is. > > Actually, /lib64/libcpre.so.0 /.0.0.1 exists. This is a standard > location though, so it must be looking for some other library (?). It's making a little .c file, and using gcc to compile it with -lpcre. I would expect that /lib64/libpcre.so.0 would be on your standard linker path. You can run configure with -v to see how it is calling gcc to compile this test c file. Perhaps try and reproduce it manually, see what gcc says. Duncan From manlio_perillo at libero.it Sun Mar 1 08:03:06 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 07:52:10 2009 Subject: [Haskell-cafe] differences between Data.Array and Data.Vector In-Reply-To: <20090227182036.GG18853@whirlpool.galois.com> References: <49A5C9FC.3070404@libero.it> <20090227182036.GG18853@whirlpool.galois.com> Message-ID: <49AA878A.5060003@libero.it> Don Stewart ha scritto: > manlio_perillo: >> Hi. >> >> In Hackage there are some packages named "*array*", and others named >> "*vector*". >> >> What are the differences? >> >> >> Is available a guide to the various data structures available in Haskell? >> > > The vector packages tend to be either easily growable, or easily > fusible, or both. > For the uvector package, how efficient is snocU? In the documentation there are no notes about performance. Thanks Manlio Perillo From david.waern at gmail.com Sun Mar 1 08:05:55 2009 From: david.waern at gmail.com (David Waern) Date: Sun Mar 1 07:54:42 2009 Subject: [Haskell-cafe] Problem with haddock - it dislikes my comments In-Reply-To: References: Message-ID: 2009/2/28 Colin Paul Adams : >>>>>> "Colin" == Colin Paul Adams writes: > >>>>>> "Gwern" == Gwern Branwen writes: > ? ?Gwern> On Sat, Feb 28, 2009 at 2:59 PM, Colin Paul Adams > ? ?Gwern> wrote: > ? ?>>> Having just read the Haddock manual , I am haddocking (may I > ? ?>>> copyleft that verb?) my code. > ? ?>>> > ? ?>>> But half-way through this data type, I discover that haddock > ? ?>>> rejects my non-haddock comments, although GHC is fine: > > ? ?>>> How can I document the components of each constructor? > > ? ?Gwern> http://trac.haskell.org/haddock/ticket/60 ? > > ? ?Colin> That seems to be a different bug - my haddock comments are > ? ?Colin> accepted fine - it's the plain Haskell ones (no ^) that it > ? ?Colin> complains about as a parse error. > > No, I'm wrong - it does seem to be the same problem. In fact, it's not. I've added two new tickets for your problem: http://trac.haskell.org/haddock/ticket/95 http://trac.haskell.org/haddock/ticket/94 > Since the ticket has been downgraded to a minor problem, it seems the > Haddock team doesn't want to allow documentation of components, except > when they are named fields. Again, not the same problem. The ticket is about documenting empty data declarations on the same line, e.g: data Empty -- ^ A comment Since you can just put the comment above or below the declaration, I consider it a minor problem. We have more serious bugs to focus on :) The new tickets for your problem have been assigned major priority, though. Thanks, David From manlio_perillo at libero.it Sun Mar 1 08:05:52 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 07:54:49 2009 Subject: [Haskell-cafe] ANNOUNCE: text and text-icu, fast and comprehensive Unicode support using stream fusion In-Reply-To: References: Message-ID: <49AA8830.1000204@libero.it> Bryan O'Sullivan ha scritto: > On behalf of the Data.Text team, I am delighted to announce the release > of preview versions of two new packages: > [...] > text-icu 0.1 > Augments text with comprehensive character set conversion support and > normalization (and soon more), via bindings to the ICU library. > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/text-icu > This is interesting. Any plans to write a pure Haskell package, using Unicode CLDR data? http://unicode.org/cldr/ As an example, Python Babel does this, and it also have support for GNU gettext catalogs. > [...] Regards Manlio Perillo From nicu.ionita at acons.at Sun Mar 1 08:26:42 2009 From: nicu.ionita at acons.at (Nicu Ionita) Date: Sun Mar 1 08:15:37 2009 Subject: [Haskell-cafe] Basic problem in Haskell language design? Message-ID: Hi, Today I found the following problem when writing a simple function: > -- Whole info from a word8 list to moves > movesFromWord8s :: [Word8] -> [Move] > movesFromWord8s (f:t:ws) = (f, t) : movesFromWord8s ws > moverFromWord8s _ = [] Here I made a small typo in the second equation, writing "mover..." instead of "moves..." for the name of the declared function. Of course this is an error, because I have non-exhaustive patterns in the function movesFromWord8s. But the compiler (here GHC 6.8.2 on WinXP) has in principle no chance to detect this mistake, I saw it only in QuickCheck (aka at run-time). I think this is a basic problem with the language design. In small programs it's not so bad, but in large ones this could be. What do you think about it? Are there possible solutions or workarounds? Nicu Ionita From barsoap at web.de Sun Mar 1 08:35:58 2009 From: barsoap at web.de (Achim Schneider) Date: Sun Mar 1 08:24:53 2009 Subject: [Haskell-cafe] Re: Basic problem in Haskell language design? References: Message-ID: <20090301143558.3a9b3f51@solaris> "Nicu Ionita" wrote: > Hi, > > Today I found the following problem when writing a simple function: > > > -- Whole info from a word8 list to moves > > movesFromWord8s :: [Word8] -> [Move] > > movesFromWord8s (f:t:ws) = (f, t) : movesFromWord8s ws > > moverFromWord8s _ = [] > > Here I made a small typo in the second equation, writing "mover..." > instead of "moves..." for the name of the declared function. Of > course this is an error, because I have non-exhaustive patterns in > the function movesFromWord8s. But the compiler (here GHC 6.8.2 on > WinXP) has in principle no chance to detect this mistake, I saw it > only in QuickCheck (aka at run-time). > > I think this is a basic problem with the language design. In small > programs it's not so bad, but in large ones this could be. What do > you think about it? Are there possible solutions or workarounds? > -Wall? The number of -W options enabled should scale (at least) linearly with code size. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From scook0 at gmail.com Sun Mar 1 08:44:49 2009 From: scook0 at gmail.com (Stuart Cook) Date: Sun Mar 1 08:33:36 2009 Subject: [Haskell-cafe] Re: Basic problem in Haskell language design? In-Reply-To: <20090301143558.3a9b3f51@solaris> References: <20090301143558.3a9b3f51@solaris> Message-ID: <49b351060903010544o4c69e5c3x40cb4a9132534cf6@mail.gmail.com> On Mon, Mar 2, 2009 at 12:35 AM, Achim Schneider wrote: > -Wall? The number of -W options enabled should scale (at least) > linearly with code size. To make this a little more clear: You should probably be using the -Wall compiler option, which will produce a message for code constructs that the compiler finds suspicious. In your case you should see three relevant warnings: 1. "moverFromWord8s" is defined but not used 2. "moverFromWord8s" has no explicit type signature 3. "movesFromWord8s" has a non-exhaustive pattern match Stuart From nicu.ionita at acons.at Sun Mar 1 09:03:12 2009 From: nicu.ionita at acons.at (Nicu Ionita) Date: Sun Mar 1 08:52:06 2009 Subject: AW: [Haskell-cafe] Re: Basic problem in Haskell language design? In-Reply-To: <49b351060903010544o4c69e5c3x40cb4a9132534cf6@mail.gmail.com> Message-ID: <0C75BEB4634E4198A70CB27E0EDC9FE1@A64X2> Ok, thanks, compiling from Eclipse I totally forgot to check the compiler flags. Nicu Ionita > -----Urspr?ngliche Nachricht----- > Von: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] Im Auftrag von Stuart Cook > Gesendet: Sonntag, 1. M?rz 2009 14:45 > An: haskell-cafe@haskell.org > Betreff: Re: [Haskell-cafe] Re: Basic problem in Haskell > language design? > > > On Mon, Mar 2, 2009 at 12:35 AM, Achim Schneider > wrote: > > -Wall? The number of -W options enabled should scale (at least) > > linearly with code size. > > To make this a little more clear: > > You should probably be using the -Wall compiler option, which > will produce a message for code constructs that the compiler > finds suspicious. > > In your case you should see three relevant warnings: > > 1. "moverFromWord8s" is defined but not used > 2. "moverFromWord8s" has no explicit type signature > 3. "movesFromWord8s" has a non-exhaustive pattern match > > > Stuart > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From manlio_perillo at libero.it Sun Mar 1 09:03:14 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 08:52:07 2009 Subject: [Haskell-cafe] memory-efficient data type for Netflix data - UArray Int Int vs UArray Int Word8 In-Reply-To: <01A51063-B12A-4B5C-B941-2165920052C9@ugent.be> References: <01A51063-B12A-4B5C-B941-2165920052C9@ugent.be> Message-ID: <49AA95A2.8070909@libero.it> Kenneth Hoste ha scritto: > Hello, > > I'm having a go at the Netflix Prize using Haskell. Yes, I'm brave. > > I kind of have an algorithm in mind that I want to implement using Haskell, > but up until now, the main issue has been to find a way to efficiently > represent > the data... > > For people who are not familiar with the Netflix data, in short, it > consist of > roughly 100M (1e8) user ratings (1-5, integer) for 17,770 different > movies, coming from > 480,109 different users. > Hi Kenneth. I have written a simple program that parses the Netflix training data set, using this data structure: type MovieRatings = IntMap (UArr Word32, UArr Word8) The ratings are grouped by movies. The parsing is done in: real 8m32.476s user 3m5.276s sys 0m8.681s On a DELL Inspiron 6400 notebook, Intel Core2 T7200 @ 2.00GHz, and 2 GB memory. However the memory used is about 1.4 GB. How did you manage to get 700 MB memory usage? Note that the minimum space required is about 480 MB (assuming 4 byte integer for the ID, and 1 byte integer for rating). Using a 4 byte integer for both ID and rating, the space required is about 765 MB. 1.5 GB is the space required if one uses a total of 16 bytes to store both the ID and the rating. Maybe it is the garbage collector that does not release memory to the operating system? Thanks Manlio Perillo From manlio_perillo at libero.it Sun Mar 1 09:07:08 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 08:55:59 2009 Subject: [Haskell-cafe] odd problem with export list of System.IO Message-ID: <49AA968C.2000105@libero.it> Hi. Maybe I'm missing something, but I don't understand why the following program: module Main where import System.IO (Handle, withFile, ReadMode) main = do return fails to compile, with a Module `System.IO' does not export `ReadMode' Thanks Manlio Perillo From johan.tibell at gmail.com Sun Mar 1 09:14:08 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun Mar 1 09:02:57 2009 Subject: [Haskell-cafe] odd problem with export list of System.IO In-Reply-To: <49AA968C.2000105@libero.it> References: <49AA968C.2000105@libero.it> Message-ID: <90889fe70903010614p5fc001adwd064812bd46f0940@mail.gmail.com> On Sun, Mar 1, 2009 at 3:07 PM, Manlio Perillo wrote: > Hi. > > Maybe I'm missing something, but I don't understand why the following > program: > > module Main where > import System.IO (Handle, withFile, ReadMode) You want to import IOMode(..), not ReadMode. The latter is a data constructor of the IOMode type. Cheers, Johan From aneumann at inf.fu-berlin.de Sun Mar 1 09:46:18 2009 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sun Mar 1 09:35:27 2009 Subject: [Haskell-cafe] Basic problem in Haskell language design? In-Reply-To: References: Message-ID: You could turn on -Wall to get a whole bunch of such warnings. Am 01.03.2009 um 14:26 schrieb Nicu Ionita: > Hi, > > Today I found the following problem when writing a simple function: > >> -- Whole info from a word8 list to moves >> movesFromWord8s :: [Word8] -> [Move] >> movesFromWord8s (f:t:ws) = (f, t) : movesFromWord8s ws >> moverFromWord8s _ = [] > > Here I made a small typo in the second equation, writing "mover..." > instead > of "moves..." for the name of the declared function. Of course this > is an > error, because I have non-exhaustive patterns in the function > movesFromWord8s. But the compiler (here GHC 6.8.2 on WinXP) has in > principle > no chance to detect this mistake, I saw it only in QuickCheck (aka at > run-time). > > I think this is a basic problem with the language design. In small > programs > it's not so bad, but in large ones this could be. What do you think > about > it? Are there possible solutions or workarounds? > > Nicu Ionita > > > _______________________________________________ > 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/20090301/7e38279e/PGP.bin From manlio_perillo at libero.it Sun Mar 1 09:55:37 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 09:44:28 2009 Subject: [Haskell-cafe] odd problem with export list of System.IO In-Reply-To: <90889fe70903010614p5fc001adwd064812bd46f0940@mail.gmail.com> References: <49AA968C.2000105@libero.it> <90889fe70903010614p5fc001adwd064812bd46f0940@mail.gmail.com> Message-ID: <49AAA1E9.9030001@libero.it> Johan Tibell ha scritto: > On Sun, Mar 1, 2009 at 3:07 PM, Manlio Perillo wrote: >> Hi. >> >> Maybe I'm missing something, but I don't understand why the following >> program: >> >> module Main where >> import System.IO (Handle, withFile, ReadMode) > > You want to import IOMode(..), not ReadMode. The latter is a data > constructor of the IOMode type. > import System.IO (Handle, withFile, IOMode(ReadMode)) solved the problem, thanks. However, why individual data constructors of the IOMode type are not exported? Thanks Manlio From daniel.is.fischer at web.de Sun Mar 1 10:10:42 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 1 09:59:32 2009 Subject: [Haskell-cafe] Basic problem in Haskell language design? In-Reply-To: References: Message-ID: <200903011610.42386.daniel.is.fischer@web.de> Am Sonntag, 1. M?rz 2009 15:46 schrieb Adrian Neumann: > You could turn on -Wall to get a whole bunch of such warnings. And explicitely turn off those warnings that you're not interested in, like ghc -O2 -Wall -fno-warn-type-defaults --make Somefile.hs Cheers, Daniel From manlio_perillo at libero.it Sun Mar 1 10:45:59 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 10:34:56 2009 Subject: [Haskell-cafe] Cabal and `main-is` field Message-ID: <49AAADB7.5010809@libero.it> Hi. I have started to use Cabal for a small project where I have to build several executables. The project layout is something like this: / bin/ a.hs b.hs src/ X.hs Y.hs The Cabal configuration file is something like: executable a build-depends: haskell98, base, ... main-is: a.hs hs-source-dirs: src bin other-modules: X This is perfectly reasonable, but it is odd, IMHO. I don't understand why `main-is` is relative to `hs-source-dirs`. What is the rationale? After all, there is only one executable that can be specified in the `executable` block. The configuration file should be, instead (IMHO, of course): executable a build-depends: haskell98, base, ... main-is: bin/a.hs hs-source-dirs: src other-modules: X Another "problem" I have noted, is that if I specify `main-is` field two times, no error is reported. Simply, Cabal uses the last directive. One last thing: is it possible to define "macros" in Cabal? In my package, I have n executables, that have many dependencies in common. I would like to avoid having to repeat the same dependencies for each executable block. Thanks Manlio Perillo From allbery at ece.cmu.edu Sun Mar 1 10:50:34 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Mar 1 10:39:32 2009 Subject: [Haskell-cafe] odd problem with export list of System.IO In-Reply-To: <49AAA1E9.9030001@libero.it> References: <49AA968C.2000105@libero.it> <90889fe70903010614p5fc001adwd064812bd46f0940@mail.gmail.com> <49AAA1E9.9030001@libero.it> Message-ID: <9DB18BB0-35BA-4778-9FAC-7597926ADFFE@ece.cmu.edu> On 2009 Mar 1, at 9:55, Manlio Perillo wrote: > Johan Tibell ha scritto: >> On Sun, Mar 1, 2009 at 3:07 PM, Manlio Perillo > > wrote: >>> Hi. >>> >>> Maybe I'm missing something, but I don't understand why the >>> following >>> program: >>> >>> module Main where >>> import System.IO (Handle, withFile, ReadMode) >> You want to import IOMode(..), not ReadMode. The latter is a data >> constructor of the IOMode type. > > However, why individual data constructors of the IOMode type are not > exported? You asked for an explicit export list, why are you surprised that things not in that export list aren't exported? If you're asking why an individual constructor needs a type with it, it's because it's only meaningful in the context of that type, if you hand the compiler ReadMode without the IOMode definition, it wouldn't be able to do anything useful with it. (You could think if it as: ReadMode is IOMode[0] (not Haskell syntax, but internally ReadMode has the 0th constructor slot in the IOMode type), WriteMode is IOMode[1], you need IOMode for either to be useful/ meaningful.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090301/d67d9020/PGP.bin From gwern0 at gmail.com Sun Mar 1 10:51:43 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Mar 1 10:40:57 2009 Subject: [Haskell-cafe] Cabal and `main-is` field In-Reply-To: <49AAADB7.5010809@libero.it> Message-ID: On Sun, Mar 1, 2009 at 10:45 AM, Manlio Perillo wrote: > Hi. ... > One last thing: is it possible to define "macros" in Cabal? > In my package, I have n executables, that have many dependencies in common. > I would like to avoid having to repeat the same dependencies for each > executable block. > > > > Thanks ? Manlio Perillo You can hoist the common build-depends out of the executable stanzas. ie. from xmonad-utils.cabal: build-depends: base<4, X11>=1.3, ghc>=6.8, unix, random>=1.0 ... executable: hxsel main-is: Hxsel.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all executable: hxput main-is: Hxput.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all .... Notice that though hxput and hxsel need the packages in the top-level build-depends, they don't need to declare it. -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 270 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090301/245bb286/signature.bin From nicolas.pouillard at gmail.com Sun Mar 1 11:23:38 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Sun Mar 1 11:13:31 2009 Subject: [Haskell-cafe] differences between Data.Array and Data.Vector In-Reply-To: <49AA878A.5060003@libero.it> References: <49A5C9FC.3070404@libero.it> <20090227182036.GG18853@whirlpool.galois.com> <49AA878A.5060003@libero.it> Message-ID: <1235923838-sup-694@ausone.local> Excerpts from Manlio Perillo's message of Sun Mar 01 14:03:06 +0100 2009: > Don Stewart ha scritto: > > manlio_perillo: > >> Hi. > >> > >> In Hackage there are some packages named "*array*", and others named > >> "*vector*". > >> > >> What are the differences? > >> > >> > >> Is available a guide to the various data structures available in Haskell? > >> > > > > The vector packages tend to be either easily growable, or easily > > fusible, or both. > > > > For the uvector package, how efficient is snocU? > > In the documentation there are no notes about performance. I think it will depend on fusion, if no fusion occurs, you get an O(n) time copy of the vector (if I correctly got the code). -- Nicolas Pouillard From manlio_perillo at libero.it Sun Mar 1 12:10:43 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 11:59:45 2009 Subject: [Haskell-cafe] Cabal and `main-is` field In-Reply-To: References: Message-ID: <49AAC193.60004@libero.it> Gwern Branwen ha scritto: > [...] > > You can hoist the common build-depends out of the executable stanzas. > ie. from xmonad-utils.cabal: > > build-depends: base<4, X11>=1.3, ghc>=6.8, unix, random>=1.0 > ... > executable: hxsel > main-is: Hxsel.hs > hs-source-dirs: src > ghc-options: -funbox-strict-fields -Wall > ghc-prof-options: -prof -auto-all > > executable: hxput > main-is: Hxput.hs > hs-source-dirs: src > ghc-options: -funbox-strict-fields -Wall > ghc-prof-options: -prof -auto-all > .... > > Notice that though hxput and hxsel need the packages in the top-level > build-depends, they don't need to declare it. > Thanks. From documentation it was not clear this feature. However, what happens if hxput add a build-depends field? Will this override the "global" field? Manlio Perillo From gwern0 at gmail.com Sun Mar 1 12:19:55 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Mar 1 12:09:02 2009 Subject: [Haskell-cafe] Cabal and `main-is` field In-Reply-To: <49AAC193.60004@libero.it> Message-ID: On Sun, Mar 1, 2009 at 12:10 PM, Manlio Perillo wrote: > Gwern Branwen ha scritto: >> >> [...] >> >> You can hoist the common build-depends out of the executable stanzas. ie. >> from xmonad-utils.cabal: >> >> build-depends: ? ? ?base<4, X11>=1.3, ghc>=6.8, unix, random>=1.0 >> ... >> executable: ? ? ? ? hxsel >> main-is: ? ? ? ? ? ?Hxsel.hs >> hs-source-dirs: ? ? src >> ghc-options: ? ? ? ?-funbox-strict-fields -Wall >> ghc-prof-options: ? -prof -auto-all >> >> executable: ? ? ? ? hxput >> main-is: ? ? ? ? ? ?Hxput.hs >> hs-source-dirs: ? ? src >> ghc-options: ? ? ? ?-funbox-strict-fields -Wall >> ghc-prof-options: ? -prof -auto-all >> .... >> >> Notice that though hxput and hxsel need the packages in the top-level >> build-depends, they don't need to declare it. >> > > Thanks. > From documentation it was not clear this feature. > > However, what happens if hxput add a build-depends field? > Will this override the "global" field? > > > > Manlio Perillo It doesn't override, but adds to. If the toplevel declares 'base', and then hxput does 'build-depends: random', hxput will be built against 'base, random'. -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 270 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090301/b279efa9/signature.bin From huschi at gmx.org Sun Mar 1 12:30:48 2009 From: huschi at gmx.org (Martin Huschenbett) Date: Sun Mar 1 12:19:36 2009 Subject: [Haskell-cafe] Re: memory issues Message-ID: <49AAC648.90306@gmx.org> ChrisK schrieb: > Bulat is right about making Block's fields strict. > >> >> -- | Get the offsets between entries in a list >> getSizes :: [Integer] -> [Integer] >> getSizes (x:y:[]) = [y - x] >> getSizes (x:y:ys) = (y - x):(getSizes (y:ys)) > > You should change the first part to add maxSize: > > > getSizes :: [Integer] -> [Integer] > > getSizes (x:y:[]) = [y - x,maxSize] > > getSizes (x:y:ys) = (y - x):(getSizes (y:ys)) > > This avoids the ugly use of (++) below. Note that appending to a singly > linked list is a bad "code smell": But Chris' version changed semantics. It should be > getSizes :: [Integer] -> [Integer] > getSizes (x:y:[]) = [y-x,maxSize-y] > getSizes (x:y:ys) = (y-x):getSizes (y:ys) instead. But > getSizes :: [Integer] -> [Integer] > getSizes [x] = [maxSize-x] > getSizes (x:y:ys) = (y-x):getSizes (y:ys) is even better as it doesn't repeat the y-x term. Regards, Martin. From huschi at gmx.org Sun Mar 1 12:42:34 2009 From: huschi at gmx.org (Martin Huschenbett) Date: Sun Mar 1 12:31:19 2009 Subject: [Haskell-cafe] Supplying a default implementation for a typeclass based on another class In-Reply-To: <221b53ab0902280259x407464b9j495d08b76b417d4b@mail.gmail.com> References: <221b53ab0902280259x407464b9j495d08b76b417d4b@mail.gmail.com> Message-ID: <49AAC90A.5070000@gmx.org> Hi, you could do something like > instance (Show a,Read a) => Binary a where > put = put . show > get = fmap read get But then you will need the following language extensions: FlexibleInstances, OverlappingInstances, UndecidableInstances I don't know how safe this is but it seems to work. Regards, Martin. Svein Ove Aas schrieb: > I'm in the process of writing a distributed filesystem (in haskell, > yay), which of course means I'm using Binary for de/serialization. > > Now, that's fine enough, but for simplicity (and for wireshark), I'd > like to be able to have Binary fall back on an instance based on > Show/Read for any type that lacks any other Binary instance.. > > Well, I understand why this would be somewhere between extremely hard > and impossible in haskell '98, but I'm not entirely up on all the > extensions, so I thought I'd ask - given every extension implemented > in ghc 6.10.1, is there any reasonable way to do this? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at worc.ox.ac.uk Sun Mar 1 13:24:15 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 1 13:13:10 2009 Subject: [Haskell-cafe] ANNOUNCE: tar 0.3.0.0 Message-ID: <1235931855.7915.145.camel@localhost> All, I'm pleased to announce a major new release of the tar package for handling ".tar" archive files. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/tar This release has a completely new and much improved API. See the hackage page for the API documentation. There are high level "all in one" functions for extracting or creating .tar files. More interestingly, it is easy to make variants by composing a pipeline. For example extracting a ".tar.gz" file is just: > Tar.unpack dir . Tar.read . GZip.decompress =<< BS.readFile tar Or creating a ".tar.bz2" file: > BS.writeFile tar . BZip.compress . Tar.write =<< Tar.pack base dir In addition it provides a full api for inspecting and constructing tar files without having to pack or unpack to local files. The functions are lazy which allows large archives to be processed in constant space. It is based on the tar handling code that has been in use in the cabal-install program for the last year or so. It has been tested on a large number of real world .tar.gz files so compatibility should be pretty good. There is also an 'htar' tool which is essentially a demo program for the tar library. It implements the common subset of the command line interface of the standard tar program, including gzip and bzip compression. Thanks to Christian Maeder for feedback on pre-release versions. Duncan From manlio_perillo at libero.it Sun Mar 1 13:25:56 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 13:14:47 2009 Subject: [Haskell-cafe] monadic MapReduce Message-ID: <49AAD334.9090202@libero.it> Hi. I have a function that do some IO (take a file path, read the file, parse, and return some data), and I would like to parallelize it, so that multiple files can be parsed in parallel. I would like to use the simple mapReduce function, from Real Word Haskell: mapReduce :: Strategy b -- evaluation strategy for mapping -> (a -> b) -- map function -> Strategy c -- evaluation strategy for reduction -> ([b] -> c) -- reduce function -> [a] -- list to map over -> c mapReduce mapStrat mapFunc reduceStrat reduceFunc input = mapResult `pseq` reduceResult where mapResult = parMap mapStrat mapFunc input reduceResult = reduceFunc mapResult `using` reduceStrat Is this possible? Thanks Manlio Perillo I From duncan.coutts at worc.ox.ac.uk Sun Mar 1 13:56:36 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 1 13:45:31 2009 Subject: [Haskell-cafe] Cabal and `main-is` field In-Reply-To: <49AAC193.60004@libero.it> References: <49AAC193.60004@libero.it> Message-ID: <1235933796.7915.146.camel@localhost> On Sun, 2009-03-01 at 18:10 +0100, Manlio Perillo wrote: > Gwern Branwen ha scritto: > > [...] > > > > You can hoist the common build-depends out of the executable stanzas. > > ie. from xmonad-utils.cabal: > > > > build-depends: base<4, X11>=1.3, ghc>=6.8, unix, random>=1.0 > > ... > > executable: hxsel > > main-is: Hxsel.hs > > hs-source-dirs: src > > ghc-options: -funbox-strict-fields -Wall > > ghc-prof-options: -prof -auto-all > > > > executable: hxput > > main-is: Hxput.hs > > hs-source-dirs: src > > ghc-options: -funbox-strict-fields -Wall > > ghc-prof-options: -prof -auto-all > > .... > > > > Notice that though hxput and hxsel need the packages in the top-level > > build-depends, they don't need to declare it. > > > > Thanks. > From documentation it was not clear this feature. That's because it's a bug, not a feature. :-) Be careful of using this "feature" as we might fix it. Duncan From anishmuttreja at gmail.com Sun Mar 1 13:58:17 2009 From: anishmuttreja at gmail.com (Anish Muttreja) Date: Sun Mar 1 13:47:06 2009 Subject: [Haskell-cafe] monadic MapReduce In-Reply-To: <49AAD334.9090202@libero.it> References: <49AAD334.9090202@libero.it> Message-ID: <20090301185817.GE15163@raven> On Sun, Mar 01, 2009 at 07:25:56PM +0100, Manlio Perillo wrote: > Hi. > > I have a function that do some IO (take a file path, read the file, > parse, and return some data), and I would like to parallelize it, so > that multiple files can be parsed in parallel. > > I would like to use the simple mapReduce function, > from Real Word Haskell: > > mapReduce :: Strategy b -- evaluation strategy for mapping > -> (a -> b) -- map function > -> Strategy c -- evaluation strategy for reduction > -> ([b] -> c) -- reduce function > -> [a] -- list to map over > -> c > > mapReduce mapStrat mapFunc reduceStrat reduceFunc input = > mapResult `pseq` reduceResult > where mapResult = parMap mapStrat mapFunc input > reduceResult = reduceFunc mapResult `using` reduceStrat > > Is this possible? > > > Thanks Manlio Perillo Would this work? Read in each file into a string (or byteString) using a lazy function and then call mapReduce with the strings instead of file paths. import qualified Data.Bytestring.Lazy.Char8 as L do let handles = map (openFile ) files strings <- mapM L.hGetContents handles let result = mapReduce ... The actual work of reading in the file should happen on-demand inside the parsing function called by mapReduce. I would like to know if this gives you the speedup you expect. Regards, Anish From manlio_perillo at libero.it Sun Mar 1 14:59:25 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 1 14:48:22 2009 Subject: [Haskell-cafe] Cabal and `main-is` field In-Reply-To: <1235933796.7915.146.camel@localhost> References: <49AAC193.60004@libero.it> <1235933796.7915.146.camel@localhost> Message-ID: <49AAE91D.9060509@libero.it> Duncan Coutts ha scritto: > [...] >>> >>> Notice that though hxput and hxsel need the packages in the top-level >>> build-depends, they don't need to declare it. >>> >> Thanks. >> From documentation it was not clear this feature. > > That's because it's a bug, not a feature. :-) > > Be careful of using this "feature" as we might fix it. > Thanks, I was going to "fix" my Cabal configuration right now! Manlio Perillo From pbeadling at mail2web.com Sun Mar 1 15:03:02 2009 From: pbeadling at mail2web.com (Phil) Date: Sun Mar 1 14:53:39 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: <200902281431.01154.daniel.is.fischer@web.de> Message-ID: Hi, Thanks for the replies - I haven't had a chance to try out everything suggested yet - but your explanations of transformers nailed it for me. However, in terms of performance when stacking, I've come across something I'm struggling to explain - I was wondering if anyone could offer up and explanation. I've rewritten my code twice - one with 3 stacked monads, and one with 2 stacked monads and a load of maps. Heuristically I would have thought the 3 stacked monads would have performed as well, or even better than the 2 stacked solution, but the 2 stacked solution is MUCH faster and MUCH less memory is used. They are both using 90% of the same code and both chain together the same number of computations using replicateM. From profiling I can see that the pure function 'reflect' takes up most of the umph in both cases - which I'd expect. But in the triple stacked version the garbage collector is using up >90% of the time. I've tried using BangPatterns to reduce memory usage in the Triple Stack version - doing this I can half the time it takes, but it is still running at over twice the time of the two stack version. The BangPatterns were also put in Common Code in the reflect function - so I'd expect both solutions to need them? Even though both pieces of code are a bit untidy, the triple stacked monad 'feels' nicer to me - everything is encapsulated away and one evaluation in main yields the result. From purely a design perspective I prefer it - but obviously not if it runs like a dog! Any ideas why the triple stack runs so slow? Thanks again! Phil ***************** Triple Stack Specific Impl: type MonteCarloStateT = StateT Double mc :: MonteCarloStateT BoxMullerQuasiState () mc = StateT $ \s -> do nextNormal <- generateNormal let stochastic = 0.2*1*nextNormal let drift = 0.05 - (0.5*(0.2*0.2))*1 let newStockSum = payOff 100 ( 100 * exp ( drift + stochastic ) ) + s return ((),newStockSum) iterations = 1000000 main :: IO() main = do let sumOfPayOffs = evalState ( evalStateT ( execStateT (do replicateM_ iterations mc) $ 0 ) $ (Nothing,nextHalton) ) $ (1,[3,5]) let averagePO = sumOfPayOffs / fromIntegral iterations let discountPO = averagePO * exp (-0.05) print discountPO ***************** Double Stack and Map Specific Impl: iterations = 1000000 main :: IO() main = do let normals = evalState ( evalStateT (do replicateM iterations generateNormal) $ (Nothing,nextHalton) ) $ (1,[3,5]) let stochastic = map (0.2*1*) normals let sde = map ((( 0.05 - (0.5*(0.2*0.2)) )*1)+) stochastic let expiryMult = map exp sde let expiry = map (100*) expiryMult let payoff = map (payOff 100) expiry let averagePO = (foldr (+) 0 payoff) / fromIntegral iterations let discountPO = averagePO * exp (-0.05) print discountPO ***************** Common Code Used By Both Methods: import Control.Monad.State import Debug.Trace -- State Monad for QRNGs - stores current iteration and list of -- bases to compute type QuasiRandomState = State (Int,[Int]) nextHalton :: QuasiRandomState [Double] nextHalton = do (n,bases) <- get let !nextN = n+1 put (nextN,bases) return $ map (reflect (n,1,0)) bases type ReflectionThreadState = (Int,Double,Double) reflect :: ReflectionThreadState -> Int -> Double reflect (k,f,h) base | k <= 0 = h | otherwise = reflect (newK,newF,newH) base where newK = k `div` base newF = f / fromIntegral base newH = h + fromIntegral(k `mod` base) * newF -- So we are defining a state transform which has state of 'maybe double' and an -- operating function for the inner monad of type QuasiRandomMonad returning a [Double] -- We then say that it wraps an QuasiRandomMonad (State Monad) - it must of course -- if we pass it a function that operates on these Monads we must wrap the same -- type of Monad. And finally it returns a double type BoxMullerStateT = StateT (Maybe Double, QuasiRandomState [Double]) type BoxMullerQuasiState = BoxMullerStateT QuasiRandomState generateNormal :: BoxMullerQuasiState Double generateNormal = StateT $ \s -> case s of (Just d,qrnFunc) -> return (d,(Nothing,qrnFunc)) (Nothing,qrnFunc) -> do qrnBaseList <- qrnFunc let (norm1,norm2) = boxMuller (head qrnBaseList) (head $ tail qrnBaseList) return (norm1,(Just norm2,qrnFunc)) boxMuller :: Double -> Double -> (Double,Double) -- boxMuller rn1 rn2 | trace ( "rn1 " ++ show rn1 ++ " rn2 " ++ show rn2 ) False=undefined boxMuller rn1 rn2 = (normal1,normal2) where r = sqrt ( (-2)*log rn1) twoPiRn2 = 2 * pi * rn2 normal1 = r * cos ( twoPiRn2 ) normal2 = r * sin ( twoPiRn2 ) payOff :: Double -> Double -> Double payOff strike stock | (stock - strike) > 0 = stock - strike | otherwise = 0 On 28/02/2009 13:31, "Daniel Fischer" wrote: > Am Samstag, 28. Februar 2009 13:23 schrieb Phil: >> Hi, >> >> The problem is ? HOW DO I WRAP ANOTHER INDEPENDENT STATE AROUND THIS? >> >> After some googling it looked like the answer may be Monad Transformers. >> Specifically we could add a StateT transform for our Box Muller state to >> our VanDerCorput State Monad. >> Google didn?t yield a direct answer here ? so I?m not even sure if my >> thinking is correct, people describe the process of using a transform as >> ?wrapping one monad in another? or ?threading one monad into another?. >> What we want to do is have some internal state controlled by an independent >> outer state - this sounds about right to me? > > If you absolutely don't want to have a state describing both, yes. > >> From svein.ove at aas.no Sun Mar 1 15:12:34 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sun Mar 1 15:01:19 2009 Subject: [Haskell-cafe] Supplying a default implementation for a typeclass based on another class In-Reply-To: <49AAC90A.5070000@gmx.org> References: <221b53ab0902280259x407464b9j495d08b76b417d4b@mail.gmail.com> <49AAC90A.5070000@gmx.org> Message-ID: <221b53ab0903011212k21480792m3b982d2be4cef1c5@mail.gmail.com> On Sun, Mar 1, 2009 at 6:42 PM, Martin Huschenbett wrote: > Hi, > > you could do something like > >> instance (Show a,Read a) => Binary a where >> ?put = put . show >> ?get = fmap read get > > But then you will need the following language extensions: FlexibleInstances, > OverlappingInstances, UndecidableInstances > Well, isn't there a good chance it'll end up picking that instance even when a more specific one is available, then? I think the problem here is that I don't know of any way to inform GHC that any particular instance is "less specific". From wagner.andrew at gmail.com Sun Mar 1 15:16:27 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Sun Mar 1 15:05:16 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: References: <200902281431.01154.daniel.is.fischer@web.de> Message-ID: I know very little about profiling, but your comment about spending a lot of time garbage collecting rang a bell with me - the example on RWH talks about that exact issue. Thus, I would recommend walking through the profiling techniques described on http://book.realworldhaskell.org/read/profiling-and-optimization.html . On Sun, Mar 1, 2009 at 3:03 PM, Phil wrote: > Hi, > > Thanks for the replies - I haven't had a chance to try out everything > suggested yet - but your explanations of transformers nailed it for me. > > However, in terms of performance when stacking, I've come across something > I'm struggling to explain - I was wondering if anyone could offer up and > explanation. > I've rewritten my code twice - one with 3 stacked monads, and one with 2 > stacked monads and a load of maps. Heuristically I would have thought the > 3 > stacked monads would have performed as well, or even better than the 2 > stacked solution, but the 2 stacked solution is MUCH faster and MUCH less > memory is used. They are both using 90% of the same code and both chain > together the same number of computations using replicateM. From profiling > I > can see that the pure function 'reflect' takes up most of the umph in both > cases - which I'd expect. But in the triple stacked version the garbage > collector is using up >90% of the time. > > I've tried using BangPatterns to reduce memory usage in the Triple Stack > version - doing this I can half the time it takes, but it is still running > at over twice the time of the two stack version. The BangPatterns were > also > put in Common Code in the reflect function - so I'd expect both solutions > to > need them? > > Even though both pieces of code are a bit untidy, the triple stacked monad > 'feels' nicer to me - everything is encapsulated away and one evaluation in > main yields the result. From purely a design perspective I prefer it - but > obviously not if it runs like a dog! > > Any ideas why the triple stack runs so slow? > > Thanks again! > > Phil > > ***************** Triple Stack Specific Impl: > > type MonteCarloStateT = StateT Double > > mc :: MonteCarloStateT BoxMullerQuasiState () > mc = StateT $ \s -> do nextNormal <- generateNormal > let stochastic = 0.2*1*nextNormal > let drift = 0.05 - (0.5*(0.2*0.2))*1 > let newStockSum = payOff 100 ( 100 * exp ( drift + > stochastic ) ) + s > return ((),newStockSum) > > iterations = 1000000 > main :: IO() > main = do let sumOfPayOffs = evalState ( evalStateT ( execStateT (do > replicateM_ iterations mc) $ 0 ) $ (Nothing,nextHalton) ) $ (1,[3,5]) > let averagePO = sumOfPayOffs / fromIntegral iterations > let discountPO = averagePO * exp (-0.05) > print discountPO > > > ***************** Double Stack and Map Specific Impl: > > > iterations = 1000000 > main :: IO() > main = do let normals = evalState ( evalStateT (do replicateM iterations > generateNormal) $ (Nothing,nextHalton) ) $ (1,[3,5]) > let stochastic = map (0.2*1*) normals > let sde = map ((( 0.05 - (0.5*(0.2*0.2)) )*1)+) stochastic > let expiryMult = map exp sde > let expiry = map (100*) expiryMult > let payoff = map (payOff 100) expiry > let averagePO = (foldr (+) 0 payoff) / fromIntegral iterations > let discountPO = averagePO * exp (-0.05) > print discountPO > > > ***************** Common Code Used By Both Methods: > > > import Control.Monad.State > import Debug.Trace > > -- State Monad for QRNGs - stores current iteration and list of > -- bases to compute > type QuasiRandomState = State (Int,[Int]) > > nextHalton :: QuasiRandomState [Double] > nextHalton = do (n,bases) <- get > let !nextN = n+1 > put (nextN,bases) > return $ map (reflect (n,1,0)) bases > > type ReflectionThreadState = (Int,Double,Double) > > reflect :: ReflectionThreadState -> Int -> Double > reflect (k,f,h) base > | k <= 0 = h > | otherwise = reflect (newK,newF,newH) base > where > newK = k `div` base > newF = f / fromIntegral base > newH = h + fromIntegral(k `mod` base) * newF > > -- So we are defining a state transform which has state of 'maybe double' > and an > -- operating function for the inner monad of type QuasiRandomMonad > returning > a [Double] > -- We then say that it wraps an QuasiRandomMonad (State Monad) - it must of > course > -- if we pass it a function that operates on these Monads we must wrap the > same > -- type of Monad. And finally it returns a double > > type BoxMullerStateT = StateT (Maybe Double, QuasiRandomState [Double]) > type BoxMullerQuasiState = BoxMullerStateT QuasiRandomState > > generateNormal :: BoxMullerQuasiState Double > generateNormal = StateT $ \s -> case s of > (Just d,qrnFunc) -> return (d,(Nothing,qrnFunc)) > (Nothing,qrnFunc) -> do qrnBaseList <- qrnFunc > let (norm1,norm2) = boxMuller (head > qrnBaseList) (head $ tail qrnBaseList) > return (norm1,(Just norm2,qrnFunc)) > > boxMuller :: Double -> Double -> (Double,Double) > -- boxMuller rn1 rn2 | trace ( "rn1 " ++ show rn1 ++ " rn2 " ++ show rn2 ) > False=undefined > boxMuller rn1 rn2 = (normal1,normal2) > where > r = sqrt ( (-2)*log rn1) > twoPiRn2 = 2 * pi * rn2 > normal1 = r * cos ( twoPiRn2 ) > normal2 = r * sin ( twoPiRn2 ) > > > > payOff :: Double -> Double -> Double > payOff strike stock | (stock - strike) > 0 = stock - strike > | otherwise = 0 > > > > > > > > > On 28/02/2009 13:31, "Daniel Fischer" wrote: > > > Am Samstag, 28. Februar 2009 13:23 schrieb Phil: > >> Hi, > >> > >> The problem is ? HOW DO I WRAP ANOTHER INDEPENDENT STATE AROUND THIS? > >> > >> After some googling it looked like the answer may be Monad Transformers. > >> Specifically we could add a StateT transform for our Box Muller state to > >> our VanDerCorput State Monad. > >> Google didn?t yield a direct answer here ? so I?m not even sure if my > >> thinking is correct, people describe the process of using a transform as > >> ?wrapping one monad in another? or ?threading one monad into another?. > >> What we want to do is have some internal state controlled by an > independent > >> outer state - this sounds about right to me? > > > > If you absolutely don't want to have a state describing both, yes. > > > >> > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090301/608d4dac/attachment-0001.htm From jwlato at gmail.com Sun Mar 1 16:04:52 2009 From: jwlato at gmail.com (John Lato) Date: Sun Mar 1 15:53:38 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <20090228225416.GG23790@whirlpool.galois.com> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> Message-ID: <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> Hi Don, Would you please elaborate on what features or capabilities you think are missing from left-fold that would elevate it out of the special purpose category? I think that the conception is so completely different from bytestrings that just saying it's not a bytestring equivalent doesn't give me any ideas as to what would make it more useful. Since the technique is being actively developed and researched, IMO this is a good time to be making changes. Incidentally, in my package I've made newtypes that read data into strict bytestrings. It would be relatively simple to use unsafeInterleaveIO in an enumerator to create lazy bytestrings using this technique. I don't see why anyone would want to do so, however, since it would have all the negatives of lazy IO and be less efficient than simply using lazy bytestrings directly. Cheers, John On Sat, Feb 28, 2009 at 10:54 PM, Don Stewart wrote: >> There are a few iteratee/enumerator design questions that remain, >> which Oleg and others would like to explore more fully. ?The results >> of that research will likely find there way into this library. > > > I agree. There's no left-fold 'bytestring' equivalent. So it remains a > special purpose technique. > > -- Don > From john at repetae.net Sun Mar 1 16:08:14 2009 From: john at repetae.net (John Meacham) Date: Sun Mar 1 15:56:59 2009 Subject: [Haskell-cafe] Re: Hidden module? In-Reply-To: <20090227215328.32a71c8d@solaris> References: <200902271519.47968.daniel.is.fischer@web.de> <20090227215328.32a71c8d@solaris> Message-ID: <20090301210814.GA2631@sliver.repetae.net> On Fri, Feb 27, 2009 at 09:53:28PM +0100, Achim Schneider wrote: > Cristiano Paris wrote: > > > I had to append process and directory as dependencies but then it > > worked. How can I submit a patch to Hackage? Do I have to contact the > > owner? > > > In general, just try the maintainer and/or author adresses given on > hsc2hs's hackage page. > > I'd advice you to switch over to c2hs, which is actively developed, > while hsc2hs's last update date smells like abandonware. They serve different purposes, hsc2hs is meant to run on the actual machine the library is being _built_ _for_ to obtain information that is only available on the final build architecture/operating system. as in, an hsc file is the lowest level portable code you can write. c2hs is more of a developers tool. If anything, I think c2hs should generate hsc files, which can then be portably distributed. John -- John Meacham - ?repetae.net?john? From phunge0 at hotmail.com Sun Mar 1 16:10:50 2009 From: phunge0 at hotmail.com (Brian Bloniarz) Date: Sun Mar 1 15:59:37 2009 Subject: [Haskell-cafe] A foray into type-level programming, and getting stuck In-Reply-To: <1235661010.15210.28.camel@porges-laptop> References: <1235661010.15210.28.camel@porges-laptop> Message-ID: Hi George, Since none of the type metaprogramming specialists have answered you on-list, I took a crack at this -- I think you can work around the issue by avoiding overlapping instances entirely. I learned about this technique from the HList paper & this message: http://okmij.org/ftp/Haskell/keyword-arguments.lhs (see "the rest of the implementation"). I'm not sure it's the simplest approach, but it works for me. To avoid overlap in ImplementsPrev t n, use type-level's comparison class (Trich) to compare n to D1: > class (Pos n) ? ImplementsPrev t n > instance (Trich n D1 cmpD1, ImplementsPrev' cmpD1 t n) ? ImplementsPrev t n Now, the auxiliary class ImplementsPrev' can be non-overlapping because it dispatches on the result of (Trich n D1): > class (Pos n) ? ImplementsPrev' cmpD1 t n > instance (Pred n n', Nthable t n' a) ? ImplementsPrev' GT t n > instance ImplementsPrev' EQ t D1 I needed one more change to make it work, including the ImplementsPrev constraint in the Nthable instance. > instance (Pred x x', Nthable b x' r, ImplementsPrev (Tuple n a b) x) ? Nthable (Tuple n a b) x r where > nth _ (Tuple _ b) = nth (undefined ? x') b I'm not sure why this is needed. Hope this helps, -Brian > Okay, so I've written a small library to generalize 'fst' and 'snd' to > arbitrary tuples, but I'd like to extend it a bit. I'm using the > type-level library to do the thinking :) > > Imports and defines first: > >> {-# LANGUAGE UnicodeSyntax, MultiParamTypeClasses, >> FunctionalDependencies, FlexibleInstances, FlexibleContexts, >> UndecidableInstances, DeriveDataTypeable, OverlappingInstances, >> ScopedTypeVariables #-} >> import Prelude hiding ((-),Eq) >> import qualified Prelude as P >> import Data.TypeLevel.Num.Sets >> import Data.TypeLevel.Num.Reps >> import Data.TypeLevel.Num.Aliases >> import Data.TypeLevel.Bool >> import Data.TypeLevel.Num.Ops >> import Data.Typeable > > I start by requiring that if you can access element 'n', you should be > able to access element 'n-1'. > >> class (ImplementsPrev t n a) ? Nthable t n a | t n ? a where >> nth ? n ? t ? a >> >> class (Pos n) ? ImplementsPrev t n a >> instance (Pred n n', Nthable t n' a') ? ImplementsPrev t n a >> instance ImplementsPrev t D1 a > > So, this is a simple induction. Testing it with the nthable instances > confirms that it works; removing either of the first two lines stops the > code from compiling, hurrah! > >> instance Nthable (a,b,c) D1 a where nth _ (a,_,_) = a >> instance Nthable (a,b,c) D2 b where nth _ (_,b,_) = b >> instance Nthable (a,b,c) D3 c where nth _ (_,_,c) = c > > Now, I have heard talk/suggestions of revamping tuples in Haskell to a > more flexible system. Perhaps we would like to do it like this (modulo > strictness annotations): > >> data (Nat n) ? Tuple n a b = Tuple a b >> deriving (Show,Read,Typeable,P.Eq,Ord) >> infixr 0 `comma` >> -- comma :: a -> (b ~> c) -> (a ~> (b ~> c)) -- to investigate >> comma ? (Succ n n') ? a ? Tuple n b c ? Tuple n' a (Tuple n b c) >> x `comma` y = Tuple x y >> empty ? Tuple D0 () undefined >> empty = Tuple () undefined > > Thus, we can create, e.g. (1 `comma` 2 `comma` empty). Now, I'd like to be > able to write Nthable instances, so I start with the base case: > >> instance (n :>=: D1) ? Nthable (Tuple n a b) D1 a where >> nth _ (Tuple a _) = a > > This works well. However, I am really stuck on the instance for the inductive case. > My first idea was this: > >> instance (Pred x x', Nthable b x' r) ? Nthable (Tuple n a b) x r where >> nth _ (Tuple _ b) = nth (undefined ? x') b > > But this doesn't work, muttering about IncoherentInstances and hidden datatypes from > the type-level library. > > So, I turn to Haskell caf? for help :) _________________________________________________________________ Windows Live? Contacts: Organize your contact list. http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009 From phunge0 at hotmail.com Sun Mar 1 16:30:27 2009 From: phunge0 at hotmail.com (Brian Bloniarz) Date: Sun Mar 1 16:19:13 2009 Subject: [Haskell-cafe] A foray into type-level programming, and getting stuck In-Reply-To: References: <1235661010.15210.28.camel@porges-laptop> Message-ID: Actually, it's not necessary to remove the overlap, it's enough to add the ImplementsPrev constraint: > instance (Pred x x', Nthable b x' r, ImplementsPrev (Tuple n a b) x) ? Nthable (Tuple n a b) x r where > nth _ (Tuple _ b) = nth (undefined ? x') b It looks like this typechecks too -- the only thing overlap-free did was to make the error message clearer. -Brian > Hi George, > > Since none of the type metaprogramming specialists have answered you on-list, > I took a crack at this -- I think you can work around the issue by avoiding > overlapping instances entirely. I learned about this technique from the HList > paper & this message: > http://okmij.org/ftp/Haskell/keyword-arguments.lhs > (see "the rest of the implementation"). > > I'm not sure it's the simplest approach, but it works for me. > To avoid overlap in ImplementsPrev t n, use type-level's comparison class (Trich) > to compare n to D1: >> class (Pos n) ? ImplementsPrev t n >> instance (Trich n D1 cmpD1, ImplementsPrev' cmpD1 t n) ? ImplementsPrev t n > > Now, the auxiliary class ImplementsPrev' can be non-overlapping because it dispatches > on the result of (Trich n D1): >> class (Pos n) ? ImplementsPrev' cmpD1 t n >> instance (Pred n n', Nthable t n' a) ? ImplementsPrev' GT t n >> instance ImplementsPrev' EQ t D1 > > I needed one more change to make it work, including the ImplementsPrev constraint > in the Nthable instance. >> instance (Pred x x', Nthable b x' r, ImplementsPrev (Tuple n a b) x) ? Nthable (Tuple n a b) x r where >> nth _ (Tuple _ b) = nth (undefined ? x') b > I'm not sure why this is needed. > > Hope this helps, > -Brian > >> Okay, so I've written a small library to generalize 'fst' and 'snd' to >> arbitrary tuples, but I'd like to extend it a bit. I'm using the >> type-level library to do the thinking :) >> >> Imports and defines first: >> >>> {-# LANGUAGE UnicodeSyntax, MultiParamTypeClasses, >>> FunctionalDependencies, FlexibleInstances, FlexibleContexts, >>> UndecidableInstances, DeriveDataTypeable, OverlappingInstances, >>> ScopedTypeVariables #-} >>> import Prelude hiding ((-),Eq) >>> import qualified Prelude as P >>> import Data.TypeLevel.Num.Sets >>> import Data.TypeLevel.Num.Reps >>> import Data.TypeLevel.Num.Aliases >>> import Data.TypeLevel.Bool >>> import Data.TypeLevel.Num.Ops >>> import Data.Typeable >> >> I start by requiring that if you can access element 'n', you should be >> able to access element 'n-1'. >> >>> class (ImplementsPrev t n a) ? Nthable t n a | t n ? a where >>> nth ? n ? t ? a >>> >>> class (Pos n) ? ImplementsPrev t n a >>> instance (Pred n n', Nthable t n' a') ? ImplementsPrev t n a >>> instance ImplementsPrev t D1 a >> >> So, this is a simple induction. Testing it with the nthable instances >> confirms that it works; removing either of the first two lines stops the >> code from compiling, hurrah! >> >>> instance Nthable (a,b,c) D1 a where nth _ (a,_,_) = a >>> instance Nthable (a,b,c) D2 b where nth _ (_,b,_) = b >>> instance Nthable (a,b,c) D3 c where nth _ (_,_,c) = c >> >> Now, I have heard talk/suggestions of revamping tuples in Haskell to a >> more flexible system. Perhaps we would like to do it like this (modulo >> strictness annotations): >> >>> data (Nat n) ? Tuple n a b = Tuple a b >>> deriving (Show,Read,Typeable,P.Eq,Ord) >>> infixr 0 `comma` >>> -- comma :: a -> (b ~> c) -> (a ~> (b ~> c)) -- to investigate >>> comma ? (Succ n n') ? a ? Tuple n b c ? Tuple n' a (Tuple n b c) >>> x `comma` y = Tuple x y >>> empty ? Tuple D0 () undefined >>> empty = Tuple () undefined >> >> Thus, we can create, e.g. (1 `comma` 2 `comma` empty). Now, I'd like to be >> able to write Nthable instances, so I start with the base case: >> >>> instance (n :>=: D1) ? Nthable (Tuple n a b) D1 a where >>> nth _ (Tuple a _) = a >> >> This works well. However, I am really stuck on the instance for the inductive case. >> My first idea was this: >> >>> instance (Pred x x', Nthable b x' r) ? Nthable (Tuple n a b) x r where >>> nth _ (Tuple _ b) = nth (undefined ? x') b >> >> But this doesn't work, muttering about IncoherentInstances and hidden datatypes from >> the type-level library. >> >> So, I turn to Haskell caf? for help :) > > _________________________________________________________________ > Windows Live? Contacts: Organize your contact list. > http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009 _________________________________________________________________ Windows Live?: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 From pbeadling at mail2web.com Sun Mar 1 16:35:29 2009 From: pbeadling at mail2web.com (Phil) Date: Sun Mar 1 16:27:06 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: Message-ID: On 01/03/2009 20:16, "Andrew Wagner" wrote: I know very little about profiling, but your comment about spending a lot of time garbage collecting rang a bell with me - the example on RWH talks about that exact issue. Thus, I would recommend walking through the profiling techniques described on http://book.realworldhaskell.org/read/profiling-and-optimization.html . Yes, I?ve been going through this very example to try to ascertain where the problem lies: Profiling gives an almost identical program flow for both: Three stacks: http://pastebin.com/m18e530e2 Two Stacks: http://pastebin.com/m2ef7c081 The output from ??sstderr? shows the garbage collector in overdrive for Three Stacks: Three Stacks: http://pastebin.com/m5f1c93d8 Two Stacks: http://pastebin.com/m2f5a625 Also note the huge memory usage for Three Stacks! If I ?heap profile? this I can see that within the first few seconds the ?Three Stacks? approach grabs ~85MB, it then peaks after 100 seconds. It then starts to reclaim the memory until the end of the program.... Slowly but surely. The ~85MB is due to a Constant Applicative Form ? as I understand it these are values with no arguments that have a one-off cost. I assume this means they are things that are not assigned to a variable. On the other hand the graph for the Two Stack approach is a mess ? that is it jumps all over the place which I can only interpret as things are being allocated and de-allocated very quickly. Three Stacks heap: http://www.beadling.co.uk/mc2_3stacks.pdf Two Stacks heap: http://www.beadling.co.uk/mc2_2stacks.pdf Thinking about this some more, perhaps the issue here is that all the memory required is held through the whole computation for the Three Stack approach, because we continually thread computations until we have an answer. Because the Two Stack approach produces a list that we then map, perhaps the garbage collector can start to reduce memory usage as it does the final computation. This is counterintuitive to what I had hoped ? but if we use replicateM, does haskell throw away preceding states after we have a new state, or is holding the 3 states of every single computation right up until it has chained the last computation? I?d still expect to see a spike or a peak in the Two State approach, but we see nothing of the sort. If anyone can offer up a better explanation, I?d be interested to hear it! Thanks again, Phil, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090301/8bb01367/attachment.htm From daniel.is.fischer at web.de Sun Mar 1 16:46:47 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 1 16:35:37 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: References: Message-ID: <200903012246.47545.daniel.is.fischer@web.de> Am Sonntag, 1. M?rz 2009 21:03 schrieb Phil: > Hi, > > Thanks for the replies - I haven't had a chance to try out everything > suggested yet - but your explanations of transformers nailed it for me. > > However, in terms of performance when stacking, I've come across something > I'm struggling to explain - I was wondering if anyone could offer up and > explanation. > I've rewritten my code twice - one with 3 stacked monads, and one with 2 > stacked monads and a load of maps. Heuristically I would have thought the > 3 stacked monads would have performed as well, or even better than the 2 > stacked solution, but the 2 stacked solution is MUCH faster and MUCH less > memory is used. They are both using 90% of the same code and both chain > together the same number of computations using replicateM. Not quite, the triple stack uses replicateM_, whihc should be a little cheaper. > From profiling > I can see that the pure function 'reflect' takes up most of the umph in > both cases - which I'd expect. But in the triple stacked version the > garbage collector is using up >90% of the time. > > I've tried using BangPatterns to reduce memory usage in the Triple Stack > version - doing this I can half the time it takes, but it is still running > at over twice the time of the two stack version. The BangPatterns were > also put in Common Code in the reflect function - so I'd expect both > solutions to need them? One thing that helps much is to use import Control.Monad.State.Strict Using the default lazy State monad, you build enormous thunks in the states, which harms the triple stack even more than the double stack. With the strict State monad (and a strict left fold instead of foldr in the double stack), I get ./v6tripleStrict +RTS -sstderr -K16M 10.450674088955589 444,069,720 bytes allocated in the heap 234,808,472 bytes copied during GC (scavenged) 30,504,688 bytes copied during GC (not scavenged) 41,074,688 bytes maximum residency (9 sample(s)) 786 collections in generation 0 ( 21.03s) 9 collections in generation 1 ( 2.54s) 106 Mb total memory in use INIT time 0.00s ( 0.00s elapsed) MUT time 4.05s ( 4.21s elapsed) GC time 23.57s ( 24.18s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 27.62s ( 28.40s elapsed) %GC time 85.3% (85.2% elapsed) Alloc rate 109,646,844 bytes per MUT second Productivity 14.7% of total user, 14.3% of total elapsed ./v6doubleStrict +RTS -sstderr 10.450674088955592 388,795,972 bytes allocated in the heap 177,748,228 bytes copied during GC (scavenged) 23,953,900 bytes copied during GC (not scavenged) 44,560,384 bytes maximum residency (9 sample(s)) 710 collections in generation 0 ( 11.62s) 9 collections in generation 1 ( 3.03s) 94 Mb total memory in use INIT time 0.01s ( 0.00s elapsed) MUT time 13.54s ( 13.91s elapsed) GC time 14.65s ( 15.02s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 28.20s ( 28.93s elapsed) %GC time 52.0% (51.9% elapsed) Alloc rate 28,693,429 bytes per MUT second Productivity 48.0% of total user, 46.8% of total elapsed So, yes, the triple stack uses more memory, but not terribly much more. However, it spends much more time gc'ing, but as its MUT time is much less, the total times are not much different. Now,if we give them enough heap space to begin with: ./v6tripleStrict +RTS -sstderr -K16M -H192M 10.450674088955589 444,077,972 bytes allocated in the heap 95,828,976 bytes copied during GC (scavenged) 15,441,936 bytes copied during GC (not scavenged) 36,147,200 bytes maximum residency (2 sample(s)) 5 collections in generation 0 ( 2.16s) 2 collections in generation 1 ( 0.43s) 185 Mb total memory in use INIT time 0.00s ( 0.00s elapsed) MUT time 4.20s ( 4.55s elapsed) GC time 2.59s ( 2.74s elapsed) EXIT time 0.00s ( 0.95s elapsed) Total time 6.79s ( 7.29s elapsed) %GC time 38.1% (37.6% elapsed) Alloc rate 105,732,850 bytes per MUT second Productivity 61.9% of total user, 57.6% of total elapsed ./v6doubleStrict +RTS -sstderr -K16M -H192M 10.450674088955592 388,806,408 bytes allocated in the heap 46,446,680 bytes copied during GC (scavenged) 77,852 bytes copied during GC (not scavenged) 159,744 bytes maximum residency (2 sample(s)) 4 collections in generation 0 ( 1.36s) 2 collections in generation 1 ( 0.03s) 182 Mb total memory in use INIT time 0.00s ( 0.00s elapsed) MUT time 4.53s ( 5.11s elapsed) GC time 1.39s ( 1.44s elapsed) EXIT time 0.00s ( 0.02s elapsed) Total time 5.92s ( 6.55s elapsed) %GC time 23.5% (21.9% elapsed) Alloc rate 85,829,229 bytes per MUT second Productivity 76.5% of total user, 69.2% of total elapsed MUCH better. I have no idea why the MUT time for the double stack decreases so much, though. > > Even though both pieces of code are a bit untidy, the triple stacked monad > 'feels' nicer to me - everything is encapsulated away and one evaluation in > main yields the result. From purely a design perspective I prefer it - but > obviously not if it runs like a dog! > > Any ideas why the triple stack runs so slow? It suffers horribly from laziness. One thing is the lazy State monad, another is the implementation of mc. > > Thanks again! > > Phil > > ***************** Triple Stack Specific Impl: > > type MonteCarloStateT = StateT Double > > mc :: MonteCarloStateT BoxMullerQuasiState () > mc = StateT $ \s -> do nextNormal <- generateNormal > let stochastic = 0.2*1*nextNormal > let drift = 0.05 - (0.5*(0.2*0.2))*1 > let newStockSum = payOff 100 ( 100 * exp ( drift + > stochastic ) ) + s > return ((),newStockSum) Don't use a new let on each line, have it all in one let-block. And, please, force the evaluation of newStockSum: mc :: MonteCarloStateT BoxMullerQuasiState () mc = StateT $ \s -> do nextNormal <- generateNormal let stochastic = 0.2*1*nextNormal drift = 0.05 - (0.5*(0.2*0.2))*1 !newStockSum = payOff 100 ( 100 * exp ( drift + stochastic ) ) + s return ((),newStockSum) Now: ./v8tripleStrict +RTS -sstderr 10.450674088955589 396,391,172 bytes allocated in the heap 65,252 bytes copied during GC (scavenged) 22,272 bytes copied during GC (not scavenged) 40,960 bytes maximum residency (1 sample(s)) 757 collections in generation 0 ( 0.02s) 1 collections in generation 1 ( 0.00s) 1 Mb total memory in use INIT time 0.00s ( 0.00s elapsed) MUT time 3.36s ( 3.49s elapsed) GC time 0.02s ( 0.05s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 3.38s ( 3.54s elapsed) %GC time 0.6% (1.3% elapsed) Alloc rate 117,973,563 bytes per MUT second Productivity 99.4% of total user, 94.9% of total elapsed w00t! > > iterations = 1000000 > main :: IO() > main = do let sumOfPayOffs = evalState ( evalStateT ( execStateT (do > replicateM_ iterations mc) $ 0 ) $ (Nothing,nextHalton) ) $ (1,[3,5]) > let averagePO = sumOfPayOffs / fromIntegral iterations > let discountPO = averagePO * exp (-0.05) > print discountPO > Again, don't needlessly multiply the lets. > > ***************** Double Stack and Map Specific Impl: > > > iterations = 1000000 > main :: IO() > main = do let normals = evalState ( evalStateT (do replicateM iterations > generateNormal) $ (Nothing,nextHalton) ) $ (1,[3,5]) > let stochastic = map (0.2*1*) normals > let sde = map ((( 0.05 - (0.5*(0.2*0.2)) )*1)+) stochastic > let expiryMult = map exp sde > let expiry = map (100*) expiryMult > let payoff = map (payOff 100) expiry > let averagePO = (foldr (+) 0 payoff) / fromIntegral iterations > let discountPO = averagePO * exp (-0.05) > print discountPO > Same here, but important for performance is to replace the foldr with foldl'. > > ***************** Common Code Used By Both Methods: > > > import Control.Monad.State > import Debug.Trace > > -- State Monad for QRNGs - stores current iteration and list of > -- bases to compute > type QuasiRandomState = State (Int,[Int]) > > nextHalton :: QuasiRandomState [Double] > nextHalton = do (n,bases) <- get > let !nextN = n+1 > put (nextN,bases) > return $ map (reflect (n,1,0)) bases > > type ReflectionThreadState = (Int,Double,Double) > > reflect :: ReflectionThreadState -> Int -> Double > reflect (k,f,h) base > > | k <= 0 = h > | otherwise = reflect (newK,newF,newH) base > > where > newK = k `div` base > newF = f / fromIntegral base > newH = h + fromIntegral(k `mod` base) * newF > > -- So we are defining a state transform which has state of 'maybe double' > and an > -- operating function for the inner monad of type QuasiRandomMonad > returning a [Double] > -- We then say that it wraps an QuasiRandomMonad (State Monad) - it must of > course > -- if we pass it a function that operates on these Monads we must wrap the > same > -- type of Monad. And finally it returns a double > > type BoxMullerStateT = StateT (Maybe Double, QuasiRandomState [Double]) > type BoxMullerQuasiState = BoxMullerStateT QuasiRandomState > > generateNormal :: BoxMullerQuasiState Double > generateNormal = StateT $ \s -> case s of > (Just d,qrnFunc) -> return (d,(Nothing,qrnFunc)) > (Nothing,qrnFunc) -> do qrnBaseList <- qrnFunc > let (norm1,norm2) = boxMuller (head > qrnBaseList) (head $ tail qrnBaseList) > return (norm1,(Just norm2,qrnFunc)) > > boxMuller :: Double -> Double -> (Double,Double) > -- boxMuller rn1 rn2 | trace ( "rn1 " ++ show rn1 ++ " rn2 " ++ show rn2 ) > False=undefined > boxMuller rn1 rn2 = (normal1,normal2) > where > r = sqrt ( (-2)*log rn1) > twoPiRn2 = 2 * pi * rn2 > normal1 = r * cos ( twoPiRn2 ) > normal2 = r * sin ( twoPiRn2 ) > > > > payOff :: Double -> Double -> Double > payOff strike stock | (stock - strike) > 0 = stock - strike > > | otherwise = 0 > Cheers, Daniel From pbeadling at mail2web.com Sun Mar 1 17:18:15 2009 From: pbeadling at mail2web.com (Phil) Date: Sun Mar 1 17:07:47 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: <200903012246.47545.daniel.is.fischer@web.de> Message-ID: Thanks very much for your patient explanations - this has really helped again! A few final questions in-line..... On 01/03/2009 21:46, "Daniel Fischer" wrote: > > One thing that helps much is to use > > import Control.Monad.State.Strict > > Using the default lazy State monad, you build enormous thunks in the states, > which harms the triple stack even more than the double stack. > With the strict State monad (and a strict left fold instead of foldr in the > double stack), I get Ahhh, I see. Just to make sure I understand this the Strict version will evaluate each state as an atomic number. The standard lazy version will create each state as an expression of past states... Consequentially these will grow and grow as state is incremented? >> >> type MonteCarloStateT = StateT Double >> >> mc :: MonteCarloStateT BoxMullerQuasiState () >> mc = StateT $ \s -> do nextNormal <- generateNormal >> let stochastic = 0.2*1*nextNormal >> let drift = 0.05 - (0.5*(0.2*0.2))*1 >> let newStockSum = payOff 100 ( 100 * exp ( drift + >> stochastic ) ) + s >> return ((),newStockSum) > > Don't use a new let on each line, have it all in one let-block. > And, please, force the evaluation of newStockSum: > I had looked at making this strict (along with the values in the reflect function too), it was making a little bit of difference, but not much. I reckon this is because the improvement was being masked by the lazy state monad. Now that this is corrected, I can see it makes a big difference. One question here tho - if we have made our State strict, will this not result in newStockSum being atomically evaluated when we set the new state? Also on the use of multiple 'let' statements - this has obviously completely passed me by so far! I'm assuming that under one let we only actually create the newStockSum, but with 3 let statements, each is created as a separate entity? > > > w00t! > > You're not joking - this is a textbook example of performance enhancement! It's clearly something I have to keep more in mind. >> >> ***************** Double Stack and Map Specific Impl: >> >> >> iterations = 1000000 >> main :: IO() >> main = do let normals = evalState ( evalStateT (do replicateM iterations >> generateNormal) $ (Nothing,nextHalton) ) $ (1,[3,5]) >> let stochastic = map (0.2*1*) normals >> let sde = map ((( 0.05 - (0.5*(0.2*0.2)) )*1)+) stochastic >> let expiryMult = map exp sde >> let expiry = map (100*) expiryMult >> let payoff = map (payOff 100) expiry >> let averagePO = (foldr (+) 0 payoff) / fromIntegral iterations >> let discountPO = averagePO * exp (-0.05) >> print discountPO >> > > Same here, but important for performance is to replace the foldr with foldl'. > Again I understand that foldl' is the strict version of foldl, and as we are summing elements we can use either foldl or foldr. I'm assuming this is another thunk optimisation. Does foldl not actually calculate the sum, but moreover it creates an expression of the form a+b+c+d+e+.... Where foldl' will actually evaluate the expression to an atomic number? > > Cheers, > Daniel From haskell at list.mightyreason.com Sun Mar 1 17:36:20 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Sun Mar 1 17:25:18 2009 Subject: [Haskell-cafe] major speed improvement: regex-tdfa reaches 1.0.0 Message-ID: <49AB0DE4.2020706@list.mightyreason.com> Announcing the version 1.0.0 release of regex-tdfa. I am proud of this release. This is not just a bug fix release. It is a serious improvement in the asymptotic running time. The previous versions allowed bad combinations of pattern and searched text length to scale badly in the length of the text. Previously the worst case for text of length N was O(N^3). The new worst case asymptotic runtime scaled as O(N). There is never any backtracking. And the worst case storage space is independent of N. The package is on hackage at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-tdfa The darcs repository is at http://darcs.haskell.org/packages/regex-unstable/regex-tdfa/ All non-overlapping matches are found and returned, along with all captured (parenthesized) subexpressions. The result is precisely what Posix extended regular expressions are supposed to return. To be concrete, consider example text with length of N of (2^n)+2: > longInput = replicate (2^n) 'a' ++ "bc" And define 4 worst-case-scenario patterns. I wrote the code and I know how to kill it: > wcs0 = "a*b" > wcs1 = "a*c" > wcs2 = "(a|aa)*b" > wcs3 = "(a|aa)*c" wcs0 is easy. wcs1 causes the old code to backtrack. wcs2 causes the old code's storage to scale as O(N). wcs3 causes both backtracking and O(N) storage with the old code. The old code's time scales as O(N) for wcs0, O(N^2) for wcs1 and wcs2, and O(N^3) for wcs3. The new code is always O(N). The actual timings for the old code on my G4 laptop for wcs on 2^8 and 2^9 and 2^10 are: Reason:compare-tdfa chrisk$ time ./Test-TDFA-np wcs3 8 +RTS -sstderr 2>&1 | head -4 ./Test-TDFA-np wcs3 8 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(257,1)),(1,(-1,0))]] 263,776,756 bytes allocated in the heap user 0m1.017s sys 0m0.058s Reason:compare-tdfa chrisk$ time ./Test-TDFA-np wcs3 9 +RTS -sstderr 2>&1 | head -4 ./Test-TDFA-np wcs3 9 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(513,1)),(1,(-1,0))]] 1,998,647,452 bytes allocated in the heap user 0m7.083s sys 0m0.289s Reason:compare-tdfa chrisk$ time ./Test-TDFA-np wcs3 10 +RTS -sstderr 2>&1 | head -4 ./Test-TDFA-np wcs3 10 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(1025,1)),(1,(-1,0))]] 15,653,277,200 bytes allocated in the heap user 0m53.350s sys 0m2.056s The doubling of length is causing a nearly eight-fold time increase. The heap allocation is also increasing nearly eight-fold. The new code with the same input pattern and texts gives: Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 8 +RTS -sstderr 2>&1 | head -4 ./Test-TDFA2-0.99.19-np2 wcs3 8 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(257,1)),(1,(-1,0))]] 2,135,324 bytes allocated in the heap user 0m0.017s sys 0m0.017s Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 9 +RTS -sstderr 2>&1 | head -4 ./Test-TDFA2-0.99.19-np2 wcs3 9 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(513,1)),(1,(-1,0))]] 3,588,656 bytes allocated in the heap user 0m0.024s sys 0m0.017s Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 10 +RTS -sstderr 2>&1 | head -4 ./Test-TDFA2-0.99.19-np2 wcs3 10 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(1025,1)),(1,(-1,0))]] 6,345,436 bytes allocated in the heap user 0m0.038s sys 0m0.018s Note that the heap allocation for the 1026 character example above is 2466 times less than the old code. That was too fast to prove the scaling, so take more input: Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 20 +RTS -sstderr 2>&1 | head -4 ./Test-TDFA2-0.99.19-np2 wcs3 20 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(1048577,1)),(1,(-1,0))]] 5,708,574,848 bytes allocated in the heap user 0m26.023s sys 0m0.985s Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 21 +RTS -sstderr 2>&1 | head -4 ./Test-TDFA2-0.99.19-np2 wcs3 21 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(2097153,1)),(1,(-1,0))]] 11,416,354,056 bytes allocated in the heap user 0m52.656s sys 0m1.985s The length and time both doubled, as did the heap allocation. And the new code has searched two million characters in the time the old code searched one thousand. How about away from the worst case scenario? On the testing suite the new code is running slightly slower: Reason:compare-tdfa chrisk$ time ./Test-TDFA-np -r 1 100 > /dev/null user 0m4.841s sys 0m3.019s Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 -r 1 100 > /dev/null user 0m5.970s sys 0m3.012s So that is an increase of execution time of 14%. This small dip in performance might be reclaimable with more optimization. I think the gain in worst case performance already offsets the slight cost. The code for String is complete. The strict and lazy bytestrings and the (Seq Char) are currently using the String code for matching. This will be improved in a future release. Cheers, Chris The small print: regex-tdfa will still behave badly in space and time if given a pathological pattern, e.g. "(((a|aa){0,100}){0,100}){0,100}". But, I am hopeful than I can improve regex-tdfa to behave well with the patterns like this one. That is my vague goal for a future version 2.0.0 release. The very small print: I have been using ghc-6.10.1, and I think I have carried over cabal switches to make ghc-6.8.3 also work. The library probably can work with ghc-6.6, but the cabal file will need editing first as well as fixes to "Text.Regex.TDFA.NewDFA.copySTU". From duncan.coutts at worc.ox.ac.uk Sun Mar 1 18:03:41 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 1 17:52:34 2009 Subject: [Haskell-cafe] Re: Hidden module? In-Reply-To: <20090301210814.GA2631@sliver.repetae.net> References: <200902271519.47968.daniel.is.fischer@web.de> <20090227215328.32a71c8d@solaris> <20090301210814.GA2631@sliver.repetae.net> Message-ID: <1235948621.7915.163.camel@localhost> On Sun, 2009-03-01 at 13:08 -0800, John Meacham wrote: > On Fri, Feb 27, 2009 at 09:53:28PM +0100, Achim Schneider wrote: > > Cristiano Paris wrote: > > > > > I had to append process and directory as dependencies but then it > > > worked. How can I submit a patch to Hackage? Do I have to contact the > > > owner? > > > > > In general, just try the maintainer and/or author adresses given on > > hsc2hs's hackage page. > > > > I'd advice you to switch over to c2hs, which is actively developed, > > while hsc2hs's last update date smells like abandonware. > > They serve different purposes, hsc2hs is meant to run on the actual > machine the library is being _built_ _for_ to obtain information that is > only available on the final build architecture/operating system. as in, > an hsc file is the lowest level portable code you can write. c2hs is > more of a developers tool. If anything, I think c2hs should generate hsc > files, which can then be portably distributed. Like hsc2hs, c2hs has to be run using the C headers for the target machine. It needs these to calculate struct sizes like hsc2hs does. The reason it cannot generate .hsc files and leave the rest to hsc2hs is that it also generates Haskell ffi imports. It imports the C functions at the correct Haskell types. If the C headers on a different platform are quite different then we will get a type error at compile time. With hsc2hs we'll just get a segfault. So c2hs and hsc2hs are in the same class here. They both must be run for the target machine. In theory c2hs should be a strict superset of the hsc2hs functionality. In practise I do not yet fully trust the calculation of C type sizes. It needs a comprehensive test of that first. That's why gtk2hs uses both c2hs, for function imports, and hsc2hs for C struct Storable instances. Duncan From daniel.is.fischer at web.de Sun Mar 1 18:56:07 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 1 18:44:55 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: References: Message-ID: <200903020056.08057.daniel.is.fischer@web.de> Am Sonntag, 1. M?rz 2009 23:18 schrieb Phil: > Thanks very much for your patient explanations - this has really helped > again! > > A few final questions in-line..... > > On 01/03/2009 21:46, "Daniel Fischer" wrote: > > One thing that helps much is to use > > > > import Control.Monad.State.Strict > > > > Using the default lazy State monad, you build enormous thunks in the > > states, which harms the triple stack even more than the double stack. > > With the strict State monad (and a strict left fold instead of foldr in > > the double stack), I get > > Ahhh, I see. Just to make sure I understand this the Strict version will > evaluate each state as an atomic number. The standard lazy version will > create each state as an expression of past states... Consequentially these > will grow and grow as state is incremented? No, it's not that strict. If it were, we wouldn't need the bang on newStockSum (but lots of applications needing some laziness would break). The Monad instance in Control.Monad.State.Strict is instance (Monad m) => Monad (StateT s m) where return a = StateT $ \s -> return (a, s) m >>= k = StateT $ \s -> do (a, s') <- runStateT m s runStateT (k a) s' fail str = StateT $ \_ -> fail str (In the lazy instance, the second line of the >>= implementation is ~(a,s') <- runStateT m s) The state will only be evaluated if "runStateT m" resp. "runStateT (k a)" require it. However, it is truly separated from the return value a, which is not the case in the lazy implementation. The state is an expression of past states in both implementations, the expression is just much more complicated for the lazy. > > >> type MonteCarloStateT = StateT Double > >> > >> mc :: MonteCarloStateT BoxMullerQuasiState () > >> mc = StateT $ \s -> do nextNormal <- generateNormal > >> let stochastic = 0.2*1*nextNormal > >> let drift = 0.05 - (0.5*(0.2*0.2))*1 > >> let newStockSum = payOff 100 ( 100 * exp ( drift > >> + stochastic ) ) + s > >> return ((),newStockSum) > > > > Don't use a new let on each line, have it all in one let-block. > > And, please, force the evaluation of newStockSum: > > I had looked at making this strict (along with the values in the reflect > function too), it was making a little bit of difference, but not much. I > reckon this is because the improvement was being masked by the lazy state > monad. Now that this is corrected, I can see it makes a big difference. Yes, the bang doesn't do anything until the state is inspected. In the lazy state monad, the lazy (~) patterns delay that until the very end, when it has to be evaluated anyway. > > One question here tho - if we have made our State strict, will this not > result in newStockSum being atomically evaluated when we set the new state? No, see above, it's not that strict. But as state and return value are now properly separated, we can effectively say "evaluate now". > > Also on the use of multiple 'let' statements - this has obviously > completely passed me by so far! I'm assuming that under one let we only > actually create the newStockSum, but with 3 let statements, each is created > as a separate entity? I think both forms are equivalent, I just find it easier to parse with one 'let'. > > > w00t! > > You're not joking - this is a textbook example of performance enhancement! > It's clearly something I have to keep more in mind. > > >> ***************** Double Stack and Map Specific Impl: > >> > >> > >> iterations = 1000000 > >> main :: IO() > >> main = do let normals = evalState ( evalStateT (do replicateM iterations > >> generateNormal) $ (Nothing,nextHalton) ) $ (1,[3,5]) > >> let stochastic = map (0.2*1*) normals > >> let sde = map ((( 0.05 - (0.5*(0.2*0.2)) )*1)+) stochastic > >> let expiryMult = map exp sde > >> let expiry = map (100*) expiryMult > >> let payoff = map (payOff 100) expiry > >> let averagePO = (foldr (+) 0 payoff) / fromIntegral iterations > >> let discountPO = averagePO * exp (-0.05) > >> print discountPO > > > > Same here, but important for performance is to replace the foldr with > > foldl'. > > Again I understand that foldl' is the strict version of foldl, and as we > are summing elements we can use either foldl or foldr. Since addition of floating point numbers is neither associative nor commutative, they can lead to different results, so it might also matter for the result and not only the performance, which you use. But using foldr with a strict combination function on a long list always gives poor performance, you build a thunk of the form a1 + (a2 + (a3 + ........ (an + b) ........)) and before any evaluation can be done, the whole list has to be traversed, requiring O(n) space (beware of stack overflows). If you use foldl, you build a thunk of the form ((...(b + a1) + ...) + an), again requiring O(n) space, unless the compiler sees the value is needed and transforms it into foldl' itself. > I'm assuming this > is another thunk optimisation. Does foldl not actually calculate the sum, > but moreover it creates an expression of the form a+b+c+d+e+.... Where > foldl' will actually evaluate the expression to an atomic number? What foldl does depends on what the compiler sees. It may build a thunk or it may evaluate it at each step (when summing Ints and compiling with optimisations, chances are good). If you use foldl', at each step the accumulator is evaluated to weak head normal form, for types like Int or Double, that is complete evaluation, but for lists, evaluation goes only so far to determine whether it's [] or (_:_). To get complete evaluation at each step, import Control.Parallel.Strategies result = foldl' f' z xs where f' y x = (f y x) `using` rnf comes in handy. > > > Cheers, > > Daniel From newsham at lava.net Sun Mar 1 19:30:34 2009 From: newsham at lava.net (Tim Newsham) Date: Sun Mar 1 19:19:37 2009 Subject: [Haskell-cafe] nubBy changed? Message-ID: Did nubBy change recently? In 6.8.2 I could generate primes as: nubBy (\a b -> b `mod` a == 0) [2..] but in 6.10.1 I have to use nubBy (\a b -> a `mod` b == 0) [2..] Is this change intentional? If so, what is the reason? Tim Newsham http://www.thenewsh.com/~newsham/ From gue.schmidt at web.de Sun Mar 1 19:31:02 2009 From: gue.schmidt at web.de (=?windows-1252?Q?G=FC=3Fnther_Schmidt?=) Date: Sun Mar 1 19:20:00 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> Message-ID: Hi everyone, after reading all the responses I would like to ask someone, anyone, to kind of summarize the merits of the left-fold-enumerator approach. From all that I read so far about it all I was able to gather was that it has significance but I'm still not even sure what for and what not for. Apparently Oleg has done various CS work, this particular piece just being one. But he also broaches the topic at very high level, ok, too high for me, ie. no CS or higher math background. Would one of the super geeks please summarize it up? (In RWH kind of style if possible) G?nther John Lato schrieb: > Hi Don, > > Would you please elaborate on what features or capabilities you think > are missing from left-fold that would elevate it out of the special > purpose category? I think that the conception is so completely > different from bytestrings that just saying it's not a bytestring > equivalent doesn't give me any ideas as to what would make it more > useful. Since the technique is being actively developed and > researched, IMO this is a good time to be making changes. > > Incidentally, in my package I've made newtypes that read data into > strict bytestrings. It would be relatively simple to use > unsafeInterleaveIO in an enumerator to create lazy bytestrings using > this technique. I don't see why anyone would want to do so, however, > since it would have all the negatives of lazy IO and be less efficient > than simply using lazy bytestrings directly. > > Cheers, > John > > On Sat, Feb 28, 2009 at 10:54 PM, Don Stewart wrote: > >>> There are a few iteratee/enumerator design questions that remain, >>> which Oleg and others would like to explore more fully. The results >>> of that research will likely find there way into this library. >> >> I agree. There's no left-fold 'bytestring' equivalent. So it remains a >> special purpose technique. >> >> -- Don >> From ross at soi.city.ac.uk Sun Mar 1 19:56:48 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Sun Mar 1 19:45:36 2009 Subject: [Haskell-cafe] nubBy changed? In-Reply-To: References: Message-ID: <20090302005648.GA5236@soi.city.ac.uk> On Sun, Mar 01, 2009 at 02:30:34PM -1000, Tim Newsham wrote: > Did nubBy change recently? In 6.8.2 I could generate primes as: > > nubBy (\a b -> b `mod` a == 0) [2..] > > but in 6.10.1 I have to use > > nubBy (\a b -> a `mod` b == 0) [2..] > > Is this change intentional? If so, what is the reason? Tue Sep 2 10:29:50 BST 2008 Simon Marlow * #2528: reverse the order of args to (==) in nubBy to match nub This only makes a difference when the (==) definition is not reflexive, but strictly speaking it does violate the report definition of nubBy, so we should fix it. See also: http://hackage.haskell.org/trac/ghc/ticket/2528 http://www.haskell.org/onlinereport/list.html#sect17.6 The Report imposes the precondition that the relation be an equivalence, so your use was out of spec. Still, perhaps it would have been better to fix #2528 by changing nub instead of nubBy. As it is the USE_REPORT_PRELUDE versions of nub and nubBy differ from the faster versions. (And the comment on elem_by is untrue.) From trentbuck at gmail.com Sun Mar 1 21:58:31 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Sun Mar 1 21:48:46 2009 Subject: [Haskell-cafe] Re: a newbies confusion with repositories - darcs or git References: <20090301104046.GB32441@Macintosh.local> <49AAD522.7000702@gmail.com> Message-ID: <304oycpr54.fsf@Clio.twb.ath.cx> Max Battcher writes: > +1. For the most part this was a great email. It probably belongs > immortalized on the darcs blog and elsewhere. It could even go in the manual! I think the first two chapters of the manual should be 1. Why Darcs? 2. Quick Start ...and the stuff about compiling darcs and migrating from other VCSs moved either to the end (as appendices) or simply onto the wiki. From magicloud.magiclouds at gmail.com Sun Mar 1 22:56:23 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Sun Mar 1 22:45:07 2009 Subject: [Haskell-cafe] How to work with date? Message-ID: <3bd412d40903011956u3875682bx5b9ae7586c35666b@mail.gmail.com> Hi, ? I am working on some calendar GUI thing. And I cannot find a library to operate the "date". Like, when `now <- getZonedTime`, how could I get all the dates of the week. Or when I got `today`, how to get the date of 10 days ago? Thanks. -- ??????? ??????? From jfredett at gmail.com Sun Mar 1 23:24:58 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Sun Mar 1 23:13:39 2009 Subject: [Haskell-cafe] Hint & Cabal Install weirdness. Message-ID: <49AB5F9A.6070800@gmail.com> I'm attempting to install hint, I started by doing: cabal install hint and it gives me the following error: cabal: dependencies conflict: ghc-6.10.1 requires process ==1.0.1.1 however process-1.0.1.1 was excluded because ghc-6.10.1 requires process ==1.0.1.0 So I decided to try installing it via darcs, expecting to either have it work, or boil it down to one or two dependencies that were causing the problem, my hunch was right, it boils down to the ghc-mtl package, leading to the same error as above. My question is, how can I fix this? Doing a ghc-pkg hide on either process package breaks Cabal and Haddock (among others) according to the error message, and even after that happens, cabal complains about needing ghc >= 6.6 (or 6.8, depending on which package I disable), even though I have ghc 6.10. Detailed system info follows, help me haskell-cafe-kenobi(s), you're (all) my only hope(s)! Sysinfo: Arch Linux: uname -a gives: Linux Erdos 2.6.28-ARCH #1 SMP PREEMPT Mon Feb 2 22:22:59 UTC 2009 i686 Intel(R) Celeron(R) CPU 3.06GHz GenuineIntel GNU/Linux ghc --version gives: The Glorious Glasgow Haskell Compilation System, version 6.10.1 cabal --version: cabal-install version 0.6.0 using version 1.6.0.1 of the Cabal library Thanks again, /Joe -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090301/5f15292a/jfredett.vcf From daniel.is.fischer at web.de Mon Mar 2 00:10:56 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 1 23:59:44 2009 Subject: [Haskell-cafe] Hint & Cabal Install weirdness. In-Reply-To: <49AB5F9A.6070800@gmail.com> References: <49AB5F9A.6070800@gmail.com> Message-ID: <200903020610.56424.daniel.is.fischer@web.de> Am Montag, 2. M?rz 2009 05:24 schrieb Joseph Fredette: > I'm attempting to install hint, I started by doing: > > cabal install hint > > and it gives me the following error: > > cabal: dependencies conflict: ghc-6.10.1 requires process ==1.0.1.1 however > process-1.0.1.1 was excluded because ghc-6.10.1 requires process ==1.0.1.0 > That seems to be *the* most frequent problem this year. Duncan Coutts explained the matter in http://haskell.org/pipermail/haskell-cafe/2009-January/054523.html Hopefully one of the process packages is in the user db, if both are in the global db, it might be necessary to reinstall ghc. > So I decided to try installing it via darcs, expecting to either have it > work, or boil it down to one or two dependencies that were causing the > problem, my hunch was right, it boils down to the ghc-mtl package, > leading to the same error as above. My question is, how can I fix this? > Doing a ghc-pkg hide on either process package breaks Cabal and Haddock > (among others) according to the error message, and even after that > happens, cabal complains about needing ghc >= 6.6 (or 6.8, depending on > which package I disable), even though I have ghc 6.10. > > Detailed system info follows, help me haskell-cafe-kenobi(s), you're > (all) my only hope(s)! > > Sysinfo: > > Arch Linux: uname -a gives: > Linux Erdos 2.6.28-ARCH #1 SMP PREEMPT Mon Feb 2 22:22:59 UTC 2009 i686 > Intel(R) Celeron(R) CPU 3.06GHz GenuineIntel GNU/Linux > > ghc --version gives: > The Glorious Glasgow Haskell Compilation System, version 6.10.1 > > cabal --version: > cabal-install version 0.6.0 > using version 1.6.0.1 of the Cabal library > > Thanks again, > > /Joe From wren at freegeek.org Mon Mar 2 00:23:04 2009 From: wren at freegeek.org (wren ng thornton) Date: Mon Mar 2 00:11:49 2009 Subject: [Haskell-cafe] Supplying a default implementation for a typeclass based on another class In-Reply-To: <221b53ab0903011212k21480792m3b982d2be4cef1c5@mail.gmail.com> References: <221b53ab0902280259x407464b9j495d08b76b417d4b@mail.gmail.com> <49AAC90A.5070000@gmx.org> <221b53ab0903011212k21480792m3b982d2be4cef1c5@mail.gmail.com> Message-ID: <49AB6D38.8090804@freegeek.org> Svein Ove Aas wrote: > Martin Huschenbett wrote: > > > >> instance (Show a,Read a) => Binary a where > >> put = put . show > >> get = fmap read get > > But then you will need the following language extensions: FlexibleInstances, > > OverlappingInstances, UndecidableInstances > > Well, isn't there a good chance it'll end up picking that instance > even when a more specific one is available, then? > > I think the problem here is that I don't know of any way to inform GHC > that any particular instance is "less specific". OverlappingInstances will allow more specific instances to be defined, and will select them when appropriate. Where "specific" has to do with the usual type unification algorithm. This instance is on a type variable, hence is the least specific. An instance on (Maybe a), (Either a b), etc would all be more specific. Instances on (Maybe Int), (Either Bool b), (Either a Double) would be more specific still. Aside: Depending on how you're using this, we can run into problems with, say, (Either Bool Double). Does it fall under (Either Bool b) or under (Either a Double)? By default, OverlappingInstances requires that you manually resolve this diamond issue (i.e. by defining an instance for (Either Bool Double) which is more specific than all other options). The IncoherentInstances option tells the compiler to deal with the ambiguity itself, which means it will pick the most specific instance which does not introduce ambiguity (i.e. the other end of the diamond; in this case, the instance for the fully unspecified type variable). Obviously, incoherence generally does not mean what you want. The UndecidableInstances is because the two elements of the context are not "smaller" than the head (Binary a), and hence the compiler cannot guarantee that progress is being made when it backward-chains to find those instances. To witness why this could be a problem, imagine an instance for Show or Read which took Binary in the context. -- Live well, ~wren From jfredett at gmail.com Mon Mar 2 00:27:32 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Mon Mar 2 00:16:14 2009 Subject: [Haskell-cafe] Hint & Cabal Install weirdness. In-Reply-To: <200903020610.56424.daniel.is.fischer@web.de> References: <49AB5F9A.6070800@gmail.com> <200903020610.56424.daniel.is.fischer@web.de> Message-ID: <49AB6E44.1080409@gmail.com> Unregistering and then reinstalling the packages it broke seems to have fixed it, Thanks Dan! /Joe Daniel Fischer wrote: > Am Montag, 2. M?rz 2009 05:24 schrieb Joseph Fredette: > >> I'm attempting to install hint, I started by doing: >> >> cabal install hint >> >> and it gives me the following error: >> >> cabal: dependencies conflict: ghc-6.10.1 requires process ==1.0.1.1 however >> process-1.0.1.1 was excluded because ghc-6.10.1 requires process ==1.0.1.0 >> >> > > That seems to be *the* most frequent problem this year. > > Duncan Coutts explained the matter in > http://haskell.org/pipermail/haskell-cafe/2009-January/054523.html > > Hopefully one of the process packages is in the user db, if both are in the > global db, it might be necessary to reinstall ghc. > > >> So I decided to try installing it via darcs, expecting to either have it >> work, or boil it down to one or two dependencies that were causing the >> problem, my hunch was right, it boils down to the ghc-mtl package, >> leading to the same error as above. My question is, how can I fix this? >> Doing a ghc-pkg hide on either process package breaks Cabal and Haddock >> (among others) according to the error message, and even after that >> happens, cabal complains about needing ghc >= 6.6 (or 6.8, depending on >> which package I disable), even though I have ghc 6.10. >> >> Detailed system info follows, help me haskell-cafe-kenobi(s), you're >> (all) my only hope(s)! >> >> Sysinfo: >> >> Arch Linux: uname -a gives: >> Linux Erdos 2.6.28-ARCH #1 SMP PREEMPT Mon Feb 2 22:22:59 UTC 2009 i686 >> Intel(R) Celeron(R) CPU 3.06GHz GenuineIntel GNU/Linux >> >> ghc --version gives: >> The Glorious Glasgow Haskell Compilation System, version 6.10.1 >> >> cabal --version: >> cabal-install version 0.6.0 >> using version 1.6.0.1 of the Cabal library >> >> Thanks again, >> >> /Joe >> > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090302/8f2f9f47/jfredett.vcf From wren at freegeek.org Mon Mar 2 00:49:49 2009 From: wren at freegeek.org (wren ng thornton) Date: Mon Mar 2 00:38:33 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: References: Message-ID: <49AB737D.5090501@freegeek.org> Phil wrote: > Again I understand that foldl' is the strict version of foldl, and as we are > summing elements we can use either foldl or foldr. I'm assuming this is > another thunk optimisation. Does foldl not actually calculate the sum, but > moreover it creates an expression of the form a+b+c+d+e+.... Where foldl' > will actually evaluate the expression to an atomic number? It's two things. The first thing is that foldl/foldl' is tail-recursive which can be optimized into a loop in the assembly, and ensures that the fold won't stack overflow (though that says nothing about what the fold builds). The second is that foldl' is strict. That is, rather than building up a large thunk at all, at each step of the recursion we force the accumulator. This is essential to prevent stack overflows when evaluating the accumulator for atomic types like Int or Double. The same number of evaluations happen, but they're ordered differently so they can be amortized across the recursion, rather than being demanded all at once (which can exceed the resources of our non-infinite computers). For non-atomic types the added strictness is less essential. The pyramid shape of http://www.beadling.co.uk/mc2_3stacks.pdf is a canonical image of not letting go of memory incrementally, which is often the result of being too lazy. You see the same shape with, say, building up a very long list, but holding onto the first element (which prevents the GC from cleaning up behind you as you traverse the list). Which is the same as building up a very large computation, but holding off on evaluating it. The image of http://www.beadling.co.uk/mc2_2stacks.pdf looks jittery, but if we zoomed out a bit we'd see that it's a flat line, which means we're freeing memory as quickly as we're allocating it, rather than building up anything large in memory. Ideally, all programs should look like this. -- Live well, ~wren From ekirpichov at gmail.com Mon Mar 2 01:58:44 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Mar 2 01:47:28 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> Message-ID: <5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com> OK, I'm far from being a supergeek, but anyways. I'm not considering the lazy IO approach, as it doesn't involve any form of control over resources. With the traditional approach, you manually ask a stream do to something (read a block of bytes, seek to a position etc.), and your program is a mixture of stuff that asks the stream to do something and stuff that deals with the results. With the iteratee approach, you split the program into two parts: Iteratee (a thing that encapsulates the state of your work with the stream: either you're done and you don't need any new data, or you need another block of bytes to do more work (and you know *which* work), or you need to seek to a different position and you know what you're going to do after that) and Enumerator : a thing that 'runs' an iteratee, looking at what is is demanding, performing the corresponding action, giving its result to the iteratee and seeing what it wants next repeatedly. Simplifying all the monadic stuff, we end up with something like this: data Iteratee a = Done a | NeedAnotherChunk (Maybe Chunk -> Iteratee a) -- Will be given Nothing if we're at EOF | NeedToSeek Int (Maybe Chunk -> Iteratee a) type Enumerator a = Iteratee a -> Iteratee a The key point is that you, by construction, *always* know whether you need the stream or not. Thus, since the data processing loop is concentrated in one place, namely the particular enumerator, this loop *always* knows whether it's time to close the stream or not. It is time, if the iteratee has become a Done, or if the stream was closed or encountered an error. Another key point is that both the iteratees and enumerators are highly composable; and iteratees also form a monad, thus becoming suitable for easily writing parsers. Also, there's no recursion in the iteratees, and they are fusable and thus extremely performant. Further, you better read Oleg's article and code. 2009/3/2 G??nther Schmidt : > Hi everyone, > > after reading all the responses I would like to ask someone, anyone, to kind > of summarize the merits of the left-fold-enumerator approach. > > From all that I read so far about it all I was able to gather was that it > has significance but I'm still not even sure what for and what not for. > > Apparently Oleg has done various CS work, this particular piece just being > one. But he also broaches the topic at very high level, ok, too high for me, > ie. no CS or higher math background. > > Would one of the super geeks please summarize it up? (In RWH kind of style > if possible) > > G?nther > > > > John Lato schrieb: >> >> Hi Don, >> >> Would you please elaborate on what features or capabilities you think >> are missing from left-fold that would elevate it out of the special >> purpose category? ?I think that the conception is so completely >> different from bytestrings that just saying it's not a bytestring >> equivalent doesn't give me any ideas as to what would make it more >> useful. ?Since the technique is being actively developed and >> researched, IMO this is a good time to be making changes. >> >> Incidentally, in my package I've made newtypes that read data into >> strict bytestrings. ?It would be relatively simple to use >> unsafeInterleaveIO in an enumerator to create lazy bytestrings using >> this technique. ?I don't see why anyone would want to do so, however, >> since it would have all the negatives of lazy IO and be less efficient >> than simply using lazy bytestrings directly. >> >> Cheers, >> John >> >> On Sat, Feb 28, 2009 at 10:54 PM, Don Stewart wrote: >> >>>> There are a few iteratee/enumerator design questions that remain, >>>> which Oleg and others would like to explore more fully. ?The results >>>> of that research will likely find there way into this library. >>> >>> I agree. There's no left-fold 'bytestring' equivalent. So it remains a >>> special purpose technique. >>> >>> -- Don >>> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From DekuDekuplex at Yahoo.com Mon Mar 2 02:44:10 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Mar 2 02:33:06 2009 Subject: [Haskell-cafe] Re: Take a break: write an essay for Onward! Essays References: <638ABD0A29C8884A91BC5FB5C349B1C33399201B74@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: On Thu, 12 Feb 2009 09:41:49 +0000, Simon Peyton-Jones wrote: >PS: To get your imagination going, here are a couple of (strongly-contrasting) past essays: > * Dan Grossman "The transactional memory / garbage collection analogy" > http://www.cs.washington.edu/homes/djg/papers/analogy_oopsla07.pdf > * Dick Gabriel "Designed as designer" > http://dreamsongs.org/DesignedAsDesigner.html One other sample essay mentioned, which I personally find to be quite useful, is the following: * Friedrich Steimann "The paradoxical success of aspect-oriented programming" http://onward-conference.org/files/steimannessay.pdf Although not specifically related to Haskell or functional programming, it discusses an apparent paradox in a different programming paradigm, which could be useful when discussing functional paradigm-related issues pertaining to Haskell. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From martijn at van.steenbergen.nl Mon Mar 2 02:52:41 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Mar 2 02:41:27 2009 Subject: [Haskell-cafe] major speed improvement: regex-tdfa reaches 1.0.0 In-Reply-To: <49AB0DE4.2020706@list.mightyreason.com> References: <49AB0DE4.2020706@list.mightyreason.com> Message-ID: <49AB9049.2010802@van.steenbergen.nl> ChrisK wrote: > The previous versions allowed bad combinations of pattern and searched > text length to scale badly in the length of the text. Previously the > worst case for text of length N was O(N^3). > > The new worst case asymptotic runtime scaled as O(N). > There is never any backtracking. > And the worst case storage space is independent of N. That's an awesome result. :-) Thanks! Martijn. From anotheraddress at gmx.de Mon Mar 2 03:19:45 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Mon Mar 2 03:08:39 2009 Subject: [Haskell-cafe] Basic problem in Haskell language design? Message-ID: <200903020919.45093.anotheraddress@gmx.de> Hi, On Sunday 01 March 2009 14:26:42 Nicu Ionita wrote: > [...] > movesFromWord8s (f:t:ws) = (f, t) : movesFromWord8s ws > moverFromWord8s _ = [] > [...] > Are there possible solutions or workarounds? for the particular problem of having to repeat the function name, you could use "case": movesFromWord8s x = case x of f:t:ws -> (f, t) : movesFromWord8s ws _ -> [] (at the cost of one extra variable name :)) Greetings, Daniel From g9ks157k at acme.softbase.org Mon Mar 2 05:41:17 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Mon Mar 2 05:30:03 2009 Subject: [Haskell-cafe] A foray into type-level programming, =?utf-8?q?=09and_getting?= stuck In-Reply-To: References: <1235661010.15210.28.camel@porges-laptop> Message-ID: <200903021141.17508.g9ks157k@acme.softbase.org> Am Sonntag, 1. M?rz 2009 22:10 schrieb Brian Bloniarz: > Hi George, > > Since none of the type metaprogramming specialists have answered you > on-list, I took a crack at this -- I think you can work around the issue by > avoiding overlapping instances entirely. I learned about this technique > from the HList paper & this message: > http://okmij.org/ftp/Haskell/keyword-arguments.lhs > (see "the rest of the implementation"). Note that HList still needs overlapping instances for implementing type equality. If we will have closed type families at some future time, this will change. See: Best wishes, Wolfgang From manlio_perillo at libero.it Mon Mar 2 06:00:50 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 05:49:45 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com> Message-ID: <49ABBC62.4070408@libero.it> Eugene Kirpichov ha scritto: > OK, I'm far from being a supergeek, but anyways. > > I'm not considering the lazy IO approach, as it doesn't involve any > form of control over resources. This is not always true. I'm using lazy IO, still having full control over the resources. parse path = withFile path ReadMode parse' where parse' :: Handle -> IO (UArr Xxx) parse' handle = do contents <- L.hGetContents handle let v = toU $ xxx $ L.lines contents rnf v `seq` return v All the file is consumed, before the result is returned. > [...] Manlio Perillo From jon.fairbairn at cl.cam.ac.uk Mon Mar 2 06:22:55 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Mon Mar 2 06:11:55 2009 Subject: [Haskell-cafe] Re: How to work with date? References: <3bd412d40903011956u3875682bx5b9ae7586c35666b@mail.gmail.com> Message-ID: Magicloud Magiclouds writes: > Hi, > ? I am working on some calendar GUI thing. And I cannot find a library > to operate the "date". > Like, when `now <- getZonedTime`, how could I get all the dates of > the week. Or when I got `today`, how to get the date of 10 days ago? This sort of thing (given now <- getZonedTime): take 10 $ map (addDays (-1)) $ repeat $ utctDay $ zonedTimeToUTC now there's enough functions in that to be going on with, I think. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2009-01-31) From ekirpichov at gmail.com Mon Mar 2 06:27:37 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Mar 2 06:16:21 2009 Subject: [Haskell-cafe] major speed improvement: regex-tdfa reaches 1.0.0 In-Reply-To: <49AB0DE4.2020706@list.mightyreason.com> References: <49AB0DE4.2020706@list.mightyreason.com> Message-ID: <5e0214850903020327n16c90537ue0b75ed7e39fc331@mail.gmail.com> Congratulations! This is really cool. And this also made me find a bug in GHC :) http://hackage.haskell.org/trac/ghc/ticket/3059 2009/3/2 ChrisK : > Announcing the version 1.0.0 release of regex-tdfa. > > I am proud of this release. > This is not just a bug fix release. > It is a serious improvement in the asymptotic running time. > > The previous versions allowed bad combinations of pattern and searched > text length to scale badly in the length of the text. ?Previously the > worst case for text of length N was O(N^3). > > The new worst case asymptotic runtime scaled as O(N). > There is never any backtracking. > And the worst case storage space is independent of N. > > The package is on hackage at > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-tdfa > The darcs repository is at > http://darcs.haskell.org/packages/regex-unstable/regex-tdfa/ > > All non-overlapping matches are found and returned, along with all > captured (parenthesized) subexpressions. ?The result is precisely what > Posix extended regular expressions are supposed to return. > > To be concrete, consider example text with length of N of (2^n)+2: > >> longInput = replicate (2^n) 'a' ++ "bc" > > And define 4 worst-case-scenario patterns. ?I wrote the code and I > know how to kill it: > >> wcs0 = "a*b" >> wcs1 = "a*c" >> wcs2 = "(a|aa)*b" >> wcs3 = "(a|aa)*c" > > wcs0 is easy. > wcs1 causes the old code to backtrack. > wcs2 causes the old code's storage to scale as O(N). > wcs3 causes both backtracking and O(N) storage with the old code. > > The old code's time scales as O(N) for wcs0, O(N^2) for wcs1 and wcs2, > and O(N^3) for wcs3. ?The new code is always O(N). ?The actual timings > for the old code on my G4 laptop for wcs on 2^8 and 2^9 and 2^10 are: > > Reason:compare-tdfa chrisk$ time ./Test-TDFA-np wcs3 8 +RTS -sstderr 2>&1 ?| > head -4 > ./Test-TDFA-np wcs3 8 +RTS -sstderr > Test for [Char] > Right [array (0,1) [(0,(257,1)),(1,(-1,0))]] > ? ? 263,776,756 bytes allocated in the heap > user ? ?0m1.017s > sys ? ? 0m0.058s > > Reason:compare-tdfa chrisk$ time ./Test-TDFA-np wcs3 9 +RTS -sstderr 2>&1 ?| > head -4 > ./Test-TDFA-np wcs3 9 +RTS -sstderr > Test for [Char] > Right [array (0,1) [(0,(513,1)),(1,(-1,0))]] > ? 1,998,647,452 bytes allocated in the heap > user ? ?0m7.083s > sys ? ? 0m0.289s > > Reason:compare-tdfa chrisk$ time ./Test-TDFA-np wcs3 10 +RTS -sstderr 2>&1 > ?| head -4 > ./Test-TDFA-np wcs3 10 +RTS -sstderr > Test for [Char] > Right [array (0,1) [(0,(1025,1)),(1,(-1,0))]] > ?15,653,277,200 bytes allocated in the heap > user ? ?0m53.350s > sys ? ? 0m2.056s > > The doubling of length is causing a nearly eight-fold time increase. > The heap allocation is also increasing nearly eight-fold. > > The new code with the same input pattern and texts gives: > > Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 8 +RTS > -sstderr 2>&1 ?| head -4 > ./Test-TDFA2-0.99.19-np2 wcs3 8 +RTS -sstderr > Test for [Char] > Right [array (0,1) [(0,(257,1)),(1,(-1,0))]] > ? ? ? 2,135,324 bytes allocated in the heap > user ? ?0m0.017s > sys ? ? 0m0.017s > > Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 9 +RTS > -sstderr 2>&1 ?| head -4 > ./Test-TDFA2-0.99.19-np2 wcs3 9 +RTS -sstderr > Test for [Char] > Right [array (0,1) [(0,(513,1)),(1,(-1,0))]] > ? ? ? 3,588,656 bytes allocated in the heap > user ? ?0m0.024s > sys ? ? 0m0.017s > > Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 10 +RTS > -sstderr 2>&1 ?| head -4 > ./Test-TDFA2-0.99.19-np2 wcs3 10 +RTS -sstderr > Test for [Char] > Right [array (0,1) [(0,(1025,1)),(1,(-1,0))]] > ? ? ? 6,345,436 bytes allocated in the heap > user ? ?0m0.038s > sys ? ? 0m0.018s > > Note that the heap allocation for the 1026 character example above is > 2466 times less than the old code. > > That was too fast to prove the scaling, so take more input: > > Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 20 +RTS > -sstderr 2>&1 ?| head -4 > ./Test-TDFA2-0.99.19-np2 wcs3 20 +RTS -sstderr > Test for [Char] > Right [array (0,1) [(0,(1048577,1)),(1,(-1,0))]] > ? 5,708,574,848 bytes allocated in the heap > user ? ?0m26.023s > sys ? ? 0m0.985s > > Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 wcs3 21 +RTS > -sstderr 2>&1 ?| head -4 > ./Test-TDFA2-0.99.19-np2 wcs3 21 +RTS -sstderr > Test for [Char] > Right [array (0,1) [(0,(2097153,1)),(1,(-1,0))]] > ?11,416,354,056 bytes allocated in the heap > user ? ?0m52.656s > sys ? ? 0m1.985s > > The length and time both doubled, as did the heap allocation. ?And the > new code has searched two million characters in the time the old code > searched one thousand. > > How about away from the worst case scenario? ?On the testing suite the > new code is running slightly slower: > > Reason:compare-tdfa chrisk$ time ./Test-TDFA-np -r 1 100 > /dev/null > user ? ?0m4.841s > sys ? ? 0m3.019s > > Reason:compare-tdfa chrisk$ time ./Test-TDFA2-0.99.19-np2 -r 1 100 > > /dev/null > user ? ?0m5.970s > sys ? ? 0m3.012s > > So that is an increase of execution time of 14%. ?This small dip in > performance might be reclaimable with more optimization. ?I think the > gain in worst case performance already offsets the slight cost. > > The code for String is complete. ?The strict and lazy bytestrings and > the (Seq Char) are currently using the String code for matching. ?This > will be improved in a future release. > > Cheers, > ?Chris > > The small print: regex-tdfa will still behave badly in space and time > if given a pathological pattern, > e.g. "(((a|aa){0,100}){0,100}){0,100}". ?But, I am hopeful than I can > improve regex-tdfa to behave well with the patterns like this one. > That is my vague goal for a future version 2.0.0 release. > > The very small print: I have been using ghc-6.10.1, and I think I have > carried over cabal switches to make ghc-6.8.3 also work. ?The library > probably can work with ghc-6.6, but the cabal file will need editing > first as well as fixes to "Text.Regex.TDFA.NewDFA.copySTU". > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From bulat.ziganshin at gmail.com Mon Mar 2 06:28:06 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 2 06:17:06 2009 Subject: [Haskell-cafe] Re: How to work with date? In-Reply-To: References: <3bd412d40903011956u3875682bx5b9ae7586c35666b@mail.gmail.com> Message-ID: <1898530072.20090302142806@gmail.com> Hello Jon, Monday, March 2, 2009, 2:22:55 PM, you wrote: > take 10 $ map (addDays (-1)) $ repeat $ utctDay $ zonedTimeToUTC now take 10 $ iterate (addDays (-1)) $ utctDay $ zonedTimeToUTC now -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From temp.public at gmail.com Mon Mar 2 06:42:42 2009 From: temp.public at gmail.com (Anonymous Anonymous) Date: Mon Mar 2 06:31:25 2009 Subject: [Haskell-cafe] Assignment of grayCode Message-ID: <74d873f40903020342l683de045y42d8bbf8f5058853@mail.gmail.com> Hello, I'm working on a project for my university. But I do not understand the assignment. It asks me to write a function that does the following: grayCode :: Int -> ([Char] -> Int, Int -> [Char]) well in my opinion this assignment tells me to write some function that gets one input (an integer) and result two functions in one tuple. One function goes from [Char] to Int and the other one goes from Int to [Char]. But in my opinion this function will stay the same forever... am I mistaken? The assignment should be: Write an efficient code grayCode :: Int -> ([Char] -> Int, Int -> [Char]) that, for values between 2 and 36 (included), creates a Gray Code. That is, a tuple of two functions. Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090302/63935f78/attachment.htm From Alistair.Bayley at invesco.com Mon Mar 2 06:50:41 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Mon Mar 2 06:39:26 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <49ABBC62.4070408@libero.it> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com> <49ABBC62.4070408@libero.it> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025ECD@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Manlio Perillo > Sent: 02 March 2009 11:01 > > Eugene Kirpichov ha scritto: > > I'm not considering the lazy IO approach, as it doesn't involve any > > form of control over resources. > > This is not always true. > I'm using lazy IO, still having full control over the resources. > > parse path = withFile path ReadMode parse' > where > parse' :: Handle -> IO (UArr Xxx) > parse' handle = do > contents <- L.hGetContents handle > let v = toU $ xxx $ L.lines contents > rnf v `seq` return v > > All the file is consumed, before the result is returned. This only works if the entire file can reasonably fit into memory. If you want to process something really big, then you need some sort of streaming approach, where you only look at a small part of the file (a line, or a block) at a time. And this is where the enumerator-iteratee approach looks better, because the IO is strict, but you still take a stream-like approach to processing the contents. BTW, does this discussion remind anyone (else) of Peter Simon's Block-IO proposal? http://cryp.to/blockio/fast-io.html 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 ndmitchell at gmail.com Mon Mar 2 06:53:04 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Mar 2 06:41:48 2009 Subject: [Haskell-cafe] Assignment of grayCode In-Reply-To: <74d873f40903020342l683de045y42d8bbf8f5058853@mail.gmail.com> References: <74d873f40903020342l683de045y42d8bbf8f5058853@mail.gmail.com> Message-ID: <404396ef0903020353h4a359e5w37f8e36aaa443dc9@mail.gmail.com> Hi > I'm working on a project for my university. But I do not understand the > assignment. If you don't understand a university assignment the best place to ask is the person who set the assignment. If you don't understand what is being asked, most lecturers will provide clarification. > It asks me to write a function that does the following: > > grayCode :: Int -> ([Char] -> Int, Int -> [Char]) > > well in my opinion this assignment tells me to write some function that gets > one input (an integer) and result two functions in one tuple. One function > goes from [Char] to Int and the other one goes from Int to [Char]. > > But in my opinion this function will stay the same forever... am I mistaken? What do you mean by stay the same forever? Haskell is referentially transparent and pure so all functions always return the same results for the same input. > Write an efficient code > > grayCode :: Int -> ([Char] -> Int, Int -> [Char]) > > that, for values between 2 and 36 (included), creates a Gray Code. That is, > a tuple of two functions. That seems a reasonable description, but without checking with the person who set the test, you may never know for sure. I personally can't see any difference between your second version and the original question... Thanks Neil From bulat.ziganshin at gmail.com Mon Mar 2 07:00:58 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 2 06:49:58 2009 Subject: [Haskell-cafe] Assignment of grayCode In-Reply-To: <404396ef0903020353h4a359e5w37f8e36aaa443dc9@mail.gmail.com> References: <74d873f40903020342l683de045y42d8bbf8f5058853@mail.gmail.com> <404396ef0903020353h4a359e5w37f8e36aaa443dc9@mail.gmail.com> Message-ID: <1221710816.20090302150058@gmail.com> Hello Neil, Monday, March 2, 2009, 2:53:04 PM, you wrote: > That seems a reasonable description, but without checking with the > person who set the test, you may never know for sure. I personally > can't see any difference between your second version and the original > question... he probably thinks that if the things are the same forever, then grayCode function sshouldn't return different answers for different params :) starting university courses with imperative programming languages is evil! :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jwlato at gmail.com Mon Mar 2 07:03:18 2009 From: jwlato at gmail.com (John Lato) Date: Mon Mar 2 06:52:03 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> Message-ID: <9979e72e0903020403s7e90582br5b0fbca58acebe8f@mail.gmail.com> Hello, I am not a super-geek (at least, not compared to others on this list), but I'll take a try at this anyway. The benefits of iteratees mostly depend on differences between lazy and strict IO (see ch. 7 of Real World Haskell for more on this). Lazy IO allows for some seriously cool tricks. You can write functions that process entire files at once, without explicitly writing loops or recursion, and the runtime system will process data in chunks without attempting to load the whole file into memory. This allows for a very functional style of code, making it easy to abstract and compose operations. This benefit comes with a high cost. Lazy IO can make it much more difficult to manage resources. For example, suppose you open a Handle and use hGetContents to read from that handle into a data structure. Then you close the Handle. Later on, when you try to use the data, you get an error message about the handle being closed. Because the data structure wasn't fully evaluated before you closed the handle, some IO necessary to fill it was never performed, and now that the handle is closed it's too late. You don't have to explicitly close handles (when the result is garbage collected the handle should be closed automatically), but if you're doing a lot of IO this means that you'll have open handles accumulating until they can be GC'd, using up a finite resource. Lazy IO often makes it difficult to reason about the behavior of your code. One problem is unintentionally holding onto values, preventing them from being GC'd. Here's an example of a different sort of problem. Suppose you're writing a file, and the format specifies that you first write the size of data that follows, then the actual data. In order to obtain this value, you do something like the following: process = do data <- getFile "Infile.txt" writeFile "Outfile.txt" $ show $ length data You've now read the entire contents of Infile.txt into memory. If you have any code following that uses the string in "data", it won't get GC'd until after "data" is processed. If Infile.txt is large, this is a problem. You've lost one of the main benefits of lazy IO, that data is read only as necessary. Since the entire file is necessary to calculate the length of the string, the whole thing is forced into memory. In general, lazy IO doesn't have a good solution if you run into this issue. Strict IO avoids these problems, but only because the programmer has to manually manage the resources. Now the programmer is responsible for explicit recursion (typically in the IO monad), meaning the programmer needs to handle exceptions in the recursion. Buffering must also be managed manually. You've avoided the pitfalls of lazy IO, but now have a lot more work. Most of what you write will also be much less composable, leading to a lot of functions that do slight variations on the same thing. If you do strict IO long enough, you will soon desire a more generalized solution. First you'll make a function which will take a function parameter and recursively apply it to data read from a file (the enumerator). You'll want to add exception handling as well. Next, you'll find that you frequently don't need to read all of a file, only part of it. You'll want to modify your recursive function so that the function which is being repeatedly applied (the iteratee) can signal when it's finished, so the enumerator can stop processing the file at that point. After several more enhancements, you'll end up with what is essentially Oleg's iteratee code. At this point you have achieved the following: 1. Composability - both iteratees and enumerators can be composed. A number of basic iteratees are provided which can be combined by the user as necessary. 2. Layering - stream processing can be separated, e.g. one layer that creates lines, another to create words, etc. It is possible to make iteratees that operate on words, lines, or any other element that makes sense for the problem domain. 3. Efficiency - data is processed in chunks, and only as much IO is performed as necessary to evaluate the result. 4. Safety - IO exceptions don't leak outside the enumerator, and the file handle is closed after IO exceptions. 5. Generality - many different types of resources can be read (handles, files, sockets, etc.). In addition, they can easily be combined. One of Oleg's examples muxes input from two sockets into one stream in a process which is transparent to the iteratee. Furthermore, this works with any monad, not just IO (although IO actions must be performed in IO). 6. Seeking - seeking is allowed for seekable resources. So you've managed to achieve many of the benefits of lazy IO (composability, generality, and efficiency) without the drawbacks. Furthermore resources are managed strictly and released as soon as possible. I hope this is helpful. Cheers, John Lato > Message: 12 > Date: Mon, 02 Mar 2009 01:31:02 +0100 > From: G??nther Schmidt > Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl > ? ? ? ?overlooked? > To: haskell-cafe@haskell.org > Message-ID: > Content-Type: text/plain; charset=windows-1252; format=flowed > > Hi everyone, > > after reading all the responses I would like to ask someone, anyone, to > kind of summarize the merits of the left-fold-enumerator approach. > > ?From all that I read so far about it all I was able to gather was that > it has significance but I'm still not even sure what for and what not for. > > Apparently Oleg has done various CS work, this particular piece just > being one. But he also broaches the topic at very high level, ok, too > high for me, ie. no CS or higher math background. > > Would one of the super geeks please summarize it up? (In RWH kind of > style if possible) > > G?nther > > > > John Lato schrieb: >> Hi Don, >> >> Would you please elaborate on what features or capabilities you think >> are missing from left-fold that would elevate it out of the special >> purpose category? ?I think that the conception is so completely >> different from bytestrings that just saying it's not a bytestring >> equivalent doesn't give me any ideas as to what would make it more >> useful. ?Since the technique is being actively developed and >> researched, IMO this is a good time to be making changes. >> >> Incidentally, in my package I've made newtypes that read data into >> strict bytestrings. ?It would be relatively simple to use >> unsafeInterleaveIO in an enumerator to create lazy bytestrings using >> this technique. ?I don't see why anyone would want to do so, however, >> since it would have all the negatives of lazy IO and be less efficient >> than simply using lazy bytestrings directly. >> >> Cheers, >> John >> >> On Sat, Feb 28, 2009 at 10:54 PM, Don Stewart wrote: >> >>>> There are a few iteratee/enumerator design questions that remain, >>>> which Oleg and others would like to explore more fully. ?The results >>>> of that research will likely find there way into this library. >>> >>> I agree. There's no left-fold 'bytestring' equivalent. So it remains a >>> special purpose technique. >>> >>> -- Don >>> > > > From duncan.coutts at worc.ox.ac.uk Mon Mar 2 07:06:33 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Mar 2 06:55:25 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025ECD@GBLONXMB02.corp.amvescap.net> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com> <49ABBC62.4070408@libero.it> <125EACD0CAE4D24ABDB4D148C4593DA911025ECD@GBLONXMB02.corp.amvescap.net> Message-ID: <1235995593.7915.171.camel@localhost> On Mon, 2009-03-02 at 11:50 +0000, Bayley, Alistair wrote: > > From: haskell-cafe-bounces@haskell.org > > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Manlio Perillo > > Sent: 02 March 2009 11:01 > > > > Eugene Kirpichov ha scritto: > > > I'm not considering the lazy IO approach, as it doesn't involve any > > > form of control over resources. > > > > This is not always true. > > I'm using lazy IO, still having full control over the resources. > > > > parse path = withFile path ReadMode parse' > > where > > parse' :: Handle -> IO (UArr Xxx) > > parse' handle = do > > contents <- L.hGetContents handle > > let v = toU $ xxx $ L.lines contents > > rnf v `seq` return v > > > > All the file is consumed, before the result is returned. > This only works if the entire file can reasonably fit into memory. If > you want to process something really big, then you need some sort of > streaming approach, where you only look at a small part of the file (a > line, or a block) at a time. And this is where the enumerator-iteratee > approach looks better, because the IO is strict, but you still take a > stream-like approach to processing the contents. This can still be done using withFile and hGetContents. You just have to put the consumer inside the scope of withFile. The consumer can work in a streaming fashion. With lazy bytestrings this can be both efficient, work in constant memory and guarantee the file is closed. We guarantee the file is closed by using withFile. The only thing to watch out for is a consumer that doesn't consume as much as you were expecting before the file does get closed. You should notice that pretty quickly though since it should happen every time (whereas resource leaks are not so immediately visible). Duncan From jon.fairbairn at cl.cam.ac.uk Mon Mar 2 07:14:18 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Mon Mar 2 07:03:17 2009 Subject: [Haskell-cafe] Re: How to work with date? References: <3bd412d40903011956u3875682bx5b9ae7586c35666b@mail.gmail.com> <1898530072.20090302142806@gmail.com> Message-ID: Bulat Ziganshin writes: > Hello Jon, > > Monday, March 2, 2009, 2:22:55 PM, you wrote: > >> take 10 $ map (addDays (-1)) $ repeat $ utctDay $ zonedTimeToUTC now > > take 10 $ iterate (addDays (-1)) $ utctDay $ zonedTimeToUTC now take anything I post before 14:00 with a pinch of salt. Or something stronger. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From manlio_perillo at libero.it Mon Mar 2 07:40:32 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 07:29:33 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025ECD@GBLONXMB02.corp.amvescap.net> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com> <49ABBC62.4070408@libero.it> <125EACD0CAE4D24ABDB4D148C4593DA911025ECD@GBLONXMB02.corp.amvescap.net> Message-ID: <49ABD3C0.4050703@libero.it> Bayley, Alistair ha scritto: >> From: haskell-cafe-bounces@haskell.org >> [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Manlio Perillo >> Sent: 02 March 2009 11:01 >> >> Eugene Kirpichov ha scritto: >>> I'm not considering the lazy IO approach, as it doesn't involve any >>> form of control over resources. >> This is not always true. >> I'm using lazy IO, still having full control over the resources. >> >> parse path = withFile path ReadMode parse' >> where >> parse' :: Handle -> IO (UArr Xxx) >> parse' handle = do >> contents <- L.hGetContents handle >> let v = toU $ xxx $ L.lines contents >> rnf v `seq` return v >> >> All the file is consumed, before the result is returned. > > > This only works if the entire file can reasonably fit into memory. It's not the entire file, but only the parsed data structure. > If you want to process something really big, then you need some sort of streaming approach, Yes, this is a more general solution. > [...] Manlio Perillo From Alistair.Bayley at invesco.com Mon Mar 2 07:50:52 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Mon Mar 2 07:39:36 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <1235995593.7915.171.camel@localhost> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com><20090228225416.GG23790@whirlpool.galois.com><9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com><5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com><49ABBC62.4070408@libero.it><125EACD0CAE4D24ABDB4D148C4593DA911025ECD@GBLONXMB02.corp.amvescap.net> <1235995593.7915.171.camel@localhost> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025ED0@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Duncan Coutts > > This can still be done using withFile and hGetContents. You > just have to > put the consumer inside the scope of withFile. The consumer > can work in > a streaming fashion. With lazy bytestrings this can be both efficient, > work in constant memory and guarantee the file is closed. > > We guarantee the file is closed by using withFile. The only thing to > watch out for is a consumer that doesn't consume as much as you were > expecting before the file does get closed. You should notice > that pretty > quickly though since it should happen every time (whereas > resource leaks > are not so immediately visible). Sure. But this case is the one that typically causes problems for beginners, who have not yet had the educating experience of being bitten by lazy IO. The standard caf? response to "why do I get " errors here?" is "you're using hGetContents and you haven't forced/consumed all of your file". 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 dbueno at gmail.com Mon Mar 2 09:15:04 2009 From: dbueno at gmail.com (Denis Bueno) Date: Mon Mar 2 09:03:49 2009 Subject: [Haskell-cafe] Cabal and `main-is` field In-Reply-To: <1235933796.7915.146.camel@localhost> References: <49AAC193.60004@libero.it> <1235933796.7915.146.camel@localhost> Message-ID: <6dbd4d000903020615p4e11e493y6cd864d3874a42e2@mail.gmail.com> On Sun, Mar 1, 2009 at 11:56, Duncan Coutts wrote: > That's because it's a bug, not a feature. :-) > > Be careful of using this "feature" as we might fix it. I've wished for this feature, and have Cabal files right now that would be cleaner with it. Is there something technically wrong or undesirable about this feature that necessitates "fixing"? Denis From frigginfriggins at gmail.com Mon Mar 2 09:18:17 2009 From: frigginfriggins at gmail.com (friggin friggin) Date: Mon Mar 2 09:07:00 2009 Subject: [Haskell-cafe] shuffle error Message-ID: <6c5a7ce40903020618y3303c035p524b776bf267546e@mail.gmail.com> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=1989#a1990 Is the algorithm wrong ar am I using it wrong? Also, is the second argument to shuffle supposed to eb random numbers, ie the function should be used in the IO Monad? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090302/31be98ab/attachment.htm From jgoerzen at complete.org Mon Mar 2 09:20:31 2009 From: jgoerzen at complete.org (John Goerzen) Date: Mon Mar 2 09:09:17 2009 Subject: [Haskell-cafe] ANNOUNCE: tar 0.3.0.0 In-Reply-To: <1235931855.7915.145.camel@localhost> References: <1235931855.7915.145.camel@localhost> Message-ID: <49ABEB2F.40807@complete.org> Duncan Coutts wrote: > All, > > I'm pleased to announce a major new release of the tar package for > handling ".tar" archive files. Very nice! I'm curious -- what specific variants of the tar format can it read and write? * PAX? * GNU tar sparse files? * POSIX ustar * various pre-posix archives? * Solaris tar? * Binary and text numbers in numeric fields? -- John > From hjgtuyl at chello.nl Mon Mar 2 10:10:27 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Mon Mar 2 09:59:15 2009 Subject: [Haskell-cafe] shuffle error In-Reply-To: <6c5a7ce40903020618y3303c035p524b776bf267546e@mail.gmail.com> References: <6c5a7ce40903020618y3303c035p524b776bf267546e@mail.gmail.com> Message-ID: On Mon, 02 Mar 2009 15:18:17 +0100, friggin friggin wrote: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=1989#a1990 > > > Is the algorithm wrong ar am I using it wrong? > The second parameter of extractTree is of type Tree a, you didn't suply a line specifying what to do with the value (Leaf a), so you didn't cover all possibilities of this type; that's why you get the message "Non-exhaustive patterns in function extractTree". > Also, is the second argument to shuffle supposed to eb random numbers, ie > the function should be used in the IO Monad? If you supply a prefabricated random list of Integers, this function can be pure (i.e. not in the IO monad) -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From manlio_perillo at libero.it Mon Mar 2 10:10:41 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 09:59:31 2009 Subject: [Haskell-cafe] monadic MapReduce In-Reply-To: <20090301185817.GE15163@raven> References: <49AAD334.9090202@libero.it> <20090301185817.GE15163@raven> Message-ID: <49ABF6F1.60903@libero.it> Anish Muttreja ha scritto: > On Sun, Mar 01, 2009 at 07:25:56PM +0100, Manlio Perillo wrote: >> Hi. >> >> I have a function that do some IO (take a file path, read the file, >> parse, and return some data), and I would like to parallelize it, so >> that multiple files can be parsed in parallel. >> >> I would like to use the simple mapReduce function, >> from Real Word Haskell: >> >> mapReduce :: Strategy b -- evaluation strategy for mapping >> -> (a -> b) -- map function >> -> Strategy c -- evaluation strategy for reduction >> -> ([b] -> c) -- reduce function >> -> [a] -- list to map over >> -> c >> >> mapReduce mapStrat mapFunc reduceStrat reduceFunc input = >> mapResult `pseq` reduceResult >> where mapResult = parMap mapStrat mapFunc input >> reduceResult = reduceFunc mapResult `using` reduceStrat >> >> Is this possible? >> >> >> Thanks Manlio Perillo > > Would this work? I suspect that it will not work.. > Read in each file into a string (or byteString) using a lazy function > and then call mapReduce with the strings instead of file paths. > > import qualified Data.Bytestring.Lazy.Char8 as L > do > let handles = map (openFile ) files > strings <- mapM L.hGetContents handles > let result = mapReduce ... > > The actual work of reading in the file should happen on-demand inside the > parsing function called by mapReduce. > By doing this I will probably lose any control about file resources usage. Thanks Manlio From daniel.is.fischer at web.de Mon Mar 2 10:29:31 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Mar 2 10:18:17 2009 Subject: [Haskell-cafe] shuffle error In-Reply-To: <6c5a7ce40903020618y3303c035p524b776bf267546e@mail.gmail.com> References: <6c5a7ce40903020618y3303c035p524b776bf267546e@mail.gmail.com> Message-ID: <200903021629.31355.daniel.is.fischer@web.de> Am Montag, 2. M?rz 2009 15:18 schrieb friggin friggin: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=1989#a1990 > > > Is the algorithm wrong ar am I using it wrong? a) what if there are more random numbers than elements in the tree? I suggest shuffle' (Leaf e) _ = [e] b) You don't cater for the case when the number of the element to be extracted is larger than the size of the tree-1 I suggest giving a first case of extractTree n t@(Node c _ _) | c <= n = extractTree (n `mod` c) t to extractTree > > Also, is the second argument to shuffle supposed to eb random numbers, ie > the function should be used in the IO Monad? The function is pure. Whether you use it in the IO monad or not depends on whether the input lives inside the IO monad. From manlio_perillo at libero.it Mon Mar 2 10:30:51 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 10:19:39 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program Message-ID: <49ABFBAB.1050106@libero.it> Hi. After some work I have managed to implement two simple programs that parse the Netflix Prize data set. For details about the Netflix Prize, there was a post by Kenneth Hoste some time ago. I have cabalized the program, and made available here: http://haskell.mperillo.ath.cx/netflix-0.0.1.tar.gz The process-data-1 program parse the training data set, grouping ratings by movies. The process-data-2 program, instead, groups ratings by users. The structure of the two programs is similar: I create singletons IntMap and then use foldl + union to merge them together. The data structure used is: type Rating = Word32 :*: Word8 -- id, rating type MovieRatings = IntMap (UArr Rating) UArr is from uvector package. The training data set contains about 100 million ratings, so, in theory, the amount of memory required to store pairs of (id, rating) is about 480 MB. The process-data-1 program parse the entire dataset using about 1.4 GB of memory (3x increment). This is strange. The memory required is proportional to the number of ratings. It may be IntMap the culprit, or the garbage collector than does not release the memory to the operating system (or, worse, does not deallocate all used temporary memory). The process-data-2 has much more problems. When I try to parse *only* 500 movie ratings, the memory usage is 471 MB; 780 MB after all data has been fully evaluated (array concatenations). I'm using ghc 6.8.2 on Debian Etch. I would like to do some tests with recent GHC versions, but it may be a problem. Thanks Manlio Perillo From duncan at well-typed.com Mon Mar 2 10:54:44 2009 From: duncan at well-typed.com (Duncan Coutts) Date: Mon Mar 2 10:43:49 2009 Subject: [Haskell-cafe] ANNOUNCE: The Industrial Haskell Group Message-ID: <1236009284.7915.222.camel@localhost> We are pleased to announce the creation of the Industrial Haskell Group (IHG). The IHG is an organisation to support the needs of commercial users of the Haskell programming language. For more information, please see http://industry.haskell.org/ Currently, the main activity of the IHG is a collaborative development scheme, in which multiple companies fund work on the Haskell development platform to their mutual benefit. The scheme has started with three partners of the IHG, including Galois and Amgen. More details are available at http://industry.haskell.org/collab If your company is interested in joining then please e-mail info@industry.haskell.org -- Duncan Coutts, Haskell Consultant Well-Typed LLP, http://www.well-typed.com/ From allbery at ece.cmu.edu Mon Mar 2 11:08:01 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Mar 2 10:56:46 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <49ABD3C0.4050703@libero.it> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com> <49ABBC62.4070408@libero.it> <125EACD0CAE4D24ABDB4D148C4593DA911025ECD@GBLONXMB02.corp.amvescap.net> <49ABD3C0.4050703@libero.it> Message-ID: On 2009 Mar 2, at 7:40, Manlio Perillo wrote: > Bayley, Alistair ha scritto: >>> All the file is consumed, before the result is returned. >> This only works if the entire file can reasonably fit into memory. > > It's not the entire file, but only the parsed data structure. ...which, depending on what you're doing with it, can be larger than the original file (consider lists). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090302/e84e9a11/PGP.bin From allbery at ece.cmu.edu Mon Mar 2 11:10:25 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Mar 2 10:59:12 2009 Subject: [Haskell-cafe] shuffle error In-Reply-To: <6c5a7ce40903020618y3303c035p524b776bf267546e@mail.gmail.com> References: <6c5a7ce40903020618y3303c035p524b776bf267546e@mail.gmail.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090302/119cd255/PGP-0001.bin From duncan.coutts at worc.ox.ac.uk Mon Mar 2 11:15:02 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Mar 2 11:03:56 2009 Subject: [Haskell-cafe] ANNOUNCE: tar 0.3.0.0 In-Reply-To: <49ABEB2F.40807@complete.org> References: <1235931855.7915.145.camel@localhost> <49ABEB2F.40807@complete.org> Message-ID: <1236010502.7915.240.camel@localhost> On Mon, 2009-03-02 at 08:20 -0600, John Goerzen wrote: > Duncan Coutts wrote: > > All, > > > > I'm pleased to announce a major new release of the tar package for > > handling ".tar" archive files. > > Very nice! > > I'm curious -- what specific variants of the tar format can it read and > write? It can read and write basic Unix V7 format, POSIX ustar and gnu formats. > * PAX? PAX is a compatible extension of Posix ustar. It just standardises some extra tar entry types ('x' and 'g'). These archives can be read and written but there is no special support for them. You would match on entryContents = OtherEntryType 'x' paxHeader _ -> and then parse the paxHeader which is a utf-8 file containing name/value pairs. > * GNU tar sparse files? No support. They'll get matched as OtherEntryType 'S'. However unlike PAX, GNU sparse format puts the sparse info directly in the tar header and that is not parsed and the lib does not provide direct access to the data for you to be able to do it yourself. > * POSIX ustar This is the standard format the library generates. > * various pre-posix archives? Yes, at least the basic data from the V7 format. Data in the top half of the header is ignored. > * Solaris tar? In so far as it is standard posix ustar yes. Again it uses some extra entry types like 'X' for extended info. These are preserved and you can access them but there is no special support for parsing the body of these entry types. > * Binary and text numbers in numeric fields? Only text at the moment. Binary ones are currently recognised and rejected with an error saying binary ones are not supported. Adding support would not be terribly hard. Patches gladly accepted. I've only found one tarball that uses it (generated by the perl Archive::Tar lib). My main use case so far for the library is for software distribution with .tar.gz files, where portability is important. So I've tested with all the .tar.gz and .tar.bz files I could get my hands on (quite a few on a gentoo system). I've not looked at or tested use cases like backups where important things include large file support, preserving permissions, sparse files etc. I've tried the star program's tar torture tests, but this should be automated into a testsuite. I've done no performance tuning except to check that it works in constant space. On a cached 97m tarball (glibc) the timings on my machine are: GNU tar uncompressed: $ time tar -tf glibc-2.6.1.tar > /dev/null real 0m0.126s user 0m0.052s sys 0m0.068s Haskell tar uncompressed: $ time htar -tf glibc-2.6.1.tar > /dev/null real 0m0.617s user 0m0.572s sys 0m0.040s GNU tar compressed: $ time tar -tzf glibc-2.6.1.tar.gz > /dev/null real 0m0.938s user 0m0.880s sys 0m0.056s Haskell tar compressed: $ time htar -tzf glibc-2.6.1.tar.gz > /dev/null real 0m1.207s user 0m1.188s sys 0m0.016s So it's slower but still perfectly good. Duncan From duncan.coutts at worc.ox.ac.uk Mon Mar 2 11:16:49 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Mar 2 11:05:39 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025ED0@GBLONXMB02.corp.amvescap.net> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <5e0214850903012258w1ad684dep24be5b889a9d30fd@mail.gmail.com> <49ABBC62.4070408@libero.it> <125EACD0CAE4D24ABDB4D148C4593DA911025ECD@GBLONXMB02.corp.amvescap.net> <1235995593.7915.171.camel@localhost> <125EACD0CAE4D24ABDB4D148C4593DA911025ED0@GBLONXMB02.corp.amvescap.net> Message-ID: <1236010609.7915.241.camel@localhost> On Mon, 2009-03-02 at 12:50 +0000, Bayley, Alistair wrote: > > From: haskell-cafe-bounces@haskell.org > > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Duncan Coutts > > > > This can still be done using withFile and hGetContents. You > > just have to > > put the consumer inside the scope of withFile. The consumer > > can work in > > a streaming fashion. With lazy bytestrings this can be both efficient, > > work in constant memory and guarantee the file is closed. > > > > We guarantee the file is closed by using withFile. The only thing to > > watch out for is a consumer that doesn't consume as much as you were > > expecting before the file does get closed. You should notice > > that pretty > > quickly though since it should happen every time (whereas > > resource leaks > > are not so immediately visible). > > Sure. But this case is the one that typically causes problems for > beginners, who have not yet had the educating experience of being > bitten by lazy IO. The standard caf? response to "why do I get closed>" errors here?" is "you're using hGetContents and you haven't > forced/consumed all of your file". This is quite true, but I expect that's easier to explain to beginners than iterator IO, at least at the present time. Duncan From jgoerzen at complete.org Mon Mar 2 11:17:15 2009 From: jgoerzen at complete.org (John Goerzen) Date: Mon Mar 2 11:05:57 2009 Subject: [Haskell-cafe] Re: Basic problem in Haskell language design? In-Reply-To: <49b351060903010544o4c69e5c3x40cb4a9132534cf6@mail.gmail.com> References: <20090301143558.3a9b3f51@solaris> <49b351060903010544o4c69e5c3x40cb4a9132534cf6@mail.gmail.com> Message-ID: <49AC068B.5010007@complete.org> Stuart Cook wrote: > On Mon, Mar 2, 2009 at 12:35 AM, Achim Schneider wrote: >> -Wall? The number of -W options enabled should scale (at least) >> linearly with code size. > > To make this a little more clear: > > You should probably be using the -Wall compiler option, which will > produce a message for code constructs that the compiler finds > suspicious. > > In your case you should see three relevant warnings: > > 1. "moverFromWord8s" is defined but not used > 2. "moverFromWord8s" has no explicit type signature > 3. "movesFromWord8s" has a non-exhaustive pattern match And that warning #3 is the one that you really should care about. It'll save you. -- John > > > Stuart > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From gue.schmidt at web.de Mon Mar 2 11:19:08 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Mon Mar 2 11:08:00 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: References: Message-ID: Hi all, thanks again for the explanation. So I have the impression that this approach is something with recognized merit but in a way still considered work in progress as I do not really see it advertised for the general haskell audience. And there are some that study it further. Ok. My question now is: "Where do we take this from here?". Oleg seems to have published what he had to say on this years ago, takusen and hyena *use* it and beyond that there is only the occasional thread like this one. Anybody willing to take action so this stays on the radar? G?nther From bulat.ziganshin at gmail.com Mon Mar 2 11:14:35 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 2 11:10:15 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <49ABFBAB.1050106@libero.it> References: <49ABFBAB.1050106@libero.it> Message-ID: <1248049868.20090302191435@gmail.com> Hello Manlio, Monday, March 2, 2009, 6:30:51 PM, you wrote: > The process-data-1 program parse the entire dataset using about 1.4 GB > of memory (3x increment). > This is strange. > The memory required is proportional to the number of ratings. > It may be IntMap the culprit, or the garbage collector than does not > release the memory to the operating system (or, worse, does not > deallocate all used temporary memory). ghc has 2 garbage collectors. first is copying, usied by default (because it's faster): when previously allocated memory block overflows, it collects used data by copying them into *new* data block allocated from OS and then use old data block to satisfy further memory requests. let's calculate. if at GC moment your program has allocated 100 mb of memory and only 50 mb was not a garbage, then memory usage will be 150 mb another GC is compacting one - it's about 2x slower, but collects data in-place. moreover, you may set up"growing factor". with a g.f. of 1.5, for example, memory will be collected once heap will become 1.5x larger than real memory usage after last GC. this effectively guarantees that memory overhead will never be over this factor look at GHC manual, RTS switches section. and last - GHC never returns memory to the OS, there should be ticket on this -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From briqueabraque at yahoo.com Mon Mar 2 11:58:09 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Mon Mar 2 11:47:05 2009 Subject: [Haskell-cafe] Re: a newbies confusion with repositories - darcs or git In-Reply-To: References: Message-ID: > now that I'm finished with my haskell app I take the opportunity to > follow up on some things I hadn't quite understood in my so far short > venture into the haskell world. > > Means: Prepare for a number of naive posts to follow. We (most of we, actually) have all been there. Some of us (me, probably) are still there. > But since I have the ambition to become a real haskeller I was gonna > make myself acquainted with darcs. Should I skip that and head straight > for git? Whatever you choose, you'll take some time to get used to it. So, if you decided that in the end you'll use git, but you want to have a taste of darcs first, I recommend you to read the "Patch theory" of darcs manual instead: http://darcs.net/manual/node9.html There you'll find the best of darcs. If, instead, you just use darcs for a little amount of time, you'll only taste the beginner headache. Best, Maur?cio From manlio_perillo at libero.it Mon Mar 2 12:16:10 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 12:04:57 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <1248049868.20090302191435@gmail.com> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> Message-ID: <49AC145A.9080205@libero.it> Bulat Ziganshin ha scritto: > Hello Manlio, > > Monday, March 2, 2009, 6:30:51 PM, you wrote: > >> The process-data-1 program parse the entire dataset using about 1.4 GB >> of memory (3x increment). > >> This is strange. >> The memory required is proportional to the number of ratings. >> It may be IntMap the culprit, or the garbage collector than does not >> release the memory to the operating system (or, worse, does not >> deallocate all used temporary memory). > > ghc has 2 garbage collectors. > [...] I already tried to enable the compacting collection (-c RTS option). Here are some numbers (when parsing only 5000 movie files, with process-data-1): 1) With default collection algorithm, I have: real 1m4.599s user 0m49.131s sys 0m1.492s 409 MB 2) With -c option: real 1m45.197s user 0m59.248s sys 0m1.640s 418 MB So, nothing changed. > > moreover, you may set up"growing factor". with a g.f. of > 1.5, for example, memory will be collected once heap will become 1.5x > larger than real memory usage after last GC. this effectively > guarantees that memory overhead will never be over this factor > Thanks. This seems to be effective (but it also reduce performances). 3) With -F1 option real 9m59.789s user 9m41.844s sys 0m5.608s 264 MB I have to parse the whole data set, to check if memory usage is good. > look at GHC manual, RTS switches section. and last - GHC never returns > memory to the OS, there should be ticket on this > The same problem with Python. By the way: I have written the first version of the program to parse Netflix training data set in D. I also used ncpu * 1.5 threads, to parse files concurrently. However execution was *really* slow, due to garbage collection. I have also tried to disable garbage collection, and to manually run a garbage cycle from time to time (every 200 file parsed), but the performance were the same. Running the Haskell version with -F1 *seems* (I have to check) to be as slow as the D version. So, it seems that for this class of problems it is better to do manual memory management (and it is not even hard). When I find some time I will try to write a C++ version (I also have a Python version, but it is very memory inefficient). At least I hope that I can serialize the parsed data in a binary file, and then read it again, with optimized memory usage. Thanks Manlio Perillo From bulat.ziganshin at gmail.com Mon Mar 2 12:29:22 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 2 12:18:36 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <49AC145A.9080205@libero.it> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> Message-ID: <533308330.20090302202922@gmail.com> Hello Manlio, Monday, March 2, 2009, 8:16:10 PM, you wrote: > 1) With default collection algorithm, I have: > 2) With -c option: > So, nothing changed. you should look into +RTS -s stats. those 409 vs 418 mb is just somewhat random values, since GCs in those 2 inviocations are not synchronized. you should run program severaltimes with various sized datasets. and take a look into other RTS options, i think it would be better to fix heap size so that you will have maximum performance for the given amount of memory used. also try to make -A option close to L2 cache size -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Mon Mar 2 12:34:07 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 2 12:23:10 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <49AC145A.9080205@libero.it> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> Message-ID: <78614173.20090302203407@gmail.com> Hello Manlio, Monday, March 2, 2009, 8:16:10 PM, you wrote: > By the way: I have written the first version of the program to parse > Netflix training data set in D. > I also used ncpu * 1.5 threads, to parse files concurrently. > However execution was *really* slow, due to garbage collection. > I have also tried to disable garbage collection, and to manually run a > garbage cycle from time to time (every 200 file parsed), but the > performance were the same. may be it will be better to use somewhat like MapReduce and split your job into 100-file parts which are processed by ncpu concurrently executed scripts? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From manlio_perillo at libero.it Mon Mar 2 12:57:05 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 12:45:53 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <78614173.20090302203407@gmail.com> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> <78614173.20090302203407@gmail.com> Message-ID: <49AC1DF1.5070301@libero.it> Bulat Ziganshin ha scritto: > Hello Manlio, > > Monday, March 2, 2009, 8:16:10 PM, you wrote: > >> By the way: I have written the first version of the program to parse >> Netflix training data set in D. >> I also used ncpu * 1.5 threads, to parse files concurrently. > >> However execution was *really* slow, due to garbage collection. >> I have also tried to disable garbage collection, and to manually run a >> garbage cycle from time to time (every 200 file parsed), but the >> performance were the same. > > may be it will be better to use somewhat like MapReduce and split > your job into 100-file parts which are processed by ncpu concurrently > executed scripts? > For process-data-1 program there is no real need, since it is already fast enough (8 minutes on my laptop, and too memory usage is not a problem, unless it required more then 2 GB). For process-data-2 there is some code that is left unevaluated (the array concatenation). Simple file parsing is quite fast. Most of the time is spent (IMHO) concatenating arrays in foldl' (unionWith concatU), in the main function. This should be possible to run in parallel, with MapReduce; I have to check. But if parsing is so slow, there are only two solutions: 1) write the parser in C++, and then serialize the data in a compact binary format, to be read by Haskell [1] But, in this case, there are no reasons to write a piece of code in C++ and the other in Haskell ;-) 2) reimplement process-data-2 so that instead of grouping ratings by users in an IntMap, accumulate ratings in separate files (each per user, for a total of 480189 files [2]). This will avoid the need of array concatenation. Then parse the data again, and this should be more memory/GC friendly. [1] hoping that array creation from a stream is memory efficient. [2] versus 17770 files with ratings grouped by movies Regards Manlio Perillo From manlio_perillo at libero.it Mon Mar 2 13:13:51 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 13:02:39 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <49AC145A.9080205@libero.it> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> Message-ID: <49AC21DF.8050306@libero.it> Manlio Perillo ha scritto: > [...] > > moreover, you may set up"growing factor". with a g.f. of >> 1.5, for example, memory will be collected once heap will become 1.5x >> larger than real memory usage after last GC. this effectively >> guarantees that memory overhead will never be over this factor >> > > Thanks. > This seems to be effective (but it also reduce performances). > > 3) With -F1 option > [...] > I have to parse the whole data set, to check if memory usage is good. > Ok, done: real 49m7.369s user 45m21.642s sys 0m18.893s 814 MB used This is better memory usage, respect to: real 7m17.853s user 3m38.506s sys 0m7.612s 1586 MB used However, Kenneth Hoste reported (http://boegel.kejo.be/): 26 minutes, with 700 MB used. Maybe he was using the latest GHC version. I would also like to check how performances are with other functional languages. Regards Manlio Perillo From iavor.diatchki at gmail.com Mon Mar 2 13:19:03 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Mon Mar 2 13:07:45 2009 Subject: [Haskell-cafe] Re: a newbies confusion with repositories - darcs or git In-Reply-To: References: Message-ID: <5ab17e790903021019m2be9b37fxdff9b80962036817@mail.gmail.com> Hi, Just another point of information, when you make your decision: I work at a company where we frequently use Haskell and we use git for almost all of our projects (other VCSs that we use are mercurial and svn). Also, I use git for all of my open source projects and I find that it works very well. Darcs is a fine VCS (although I've had problems with it in the past) but you should not feel that you have to choose it so that you are considered a "real Haskeller" :-) Good luck, and welcome to the community! -Iavor On Mon, Mar 2, 2009 at 8:58 AM, Maur??cio wrote: >> now that I'm finished with my haskell app I take the opportunity to follow >> up on some things I hadn't quite understood in my so far short venture into >> the haskell world. >> >> Means: Prepare for a number of naive posts to follow. > > We (most of we, actually) have all been there. Some of > us (me, probably) are still there. > >> But since I have the ambition to become a real haskeller I was gonna make >> myself acquainted with darcs. Should I skip that and head straight for git? > > Whatever you choose, you'll take some time to get > used to it. So, if you decided that in the end you'll > use git, but you want to have a taste of darcs first, > I recommend you to read the "Patch theory" of darcs > manual instead: > > http://darcs.net/manual/node9.html > > There you'll find the best of darcs. If, instead, you > just use darcs for a little amount of time, you'll > only taste the beginner headache. > > Best, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From kenneth.hoste at ugent.be Mon Mar 2 15:14:27 2009 From: kenneth.hoste at ugent.be (Kenneth Hoste) Date: Mon Mar 2 15:03:11 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <49AC21DF.8050306@libero.it> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> <49AC21DF.8050306@libero.it> Message-ID: On Mar 2, 2009, at 19:13 , Manlio Perillo wrote: > Manlio Perillo ha scritto: >> [...] >> > moreover, you may set up"growing factor". with a g.f. of >>> 1.5, for example, memory will be collected once heap will become >>> 1.5x >>> larger than real memory usage after last GC. this effectively >>> guarantees that memory overhead will never be over this factor >>> >> Thanks. >> This seems to be effective (but it also reduce performances). >> 3) With -F1 option >> [...] I have to parse the whole data set, to check if memory usage >> is good. > > > Ok, done: > > real 49m7.369s > user 45m21.642s > sys 0m18.893s > > 814 MB used > > This is better memory usage, respect to: > > real 7m17.853s > user 3m38.506s > sys 0m7.612s > > 1586 MB used > > However, Kenneth Hoste reported (http://boegel.kejo.be/): > > 26 minutes, with 700 MB used. > > > Maybe he was using the latest GHC version. > I would also like to check how performances are with other > functional languages. The 26m/700MB I mentioned on my blog was on my ancient PowerBook G4 (1.5GHz PowerPC G4, 1.25G). I redid the same experiment on our iMac (Core2 Duo, 2.0 GHz, 3.0G), i.e.: - read in all the data - count the number of keys in the IntMap (which should be 17,770, i.e. the number of movies) - compute the mean overall movie rating (which should be 3.6033) That task was done in 3m42s, using just 632M of memory, using the following command: ./netflix ./training_set/ +RTS -A128M -s The -A option makes sure GC isn't cleaning up stuff too frequently, while -s just reports some statistics. The way in which I'm reading in the data is somewhat different from yours. I construct the IntMap from the ground up, i.e. starting with an empty IntMap and using foldM, together with a function readMovie with the following type: readMovie :: IntMap (UArray Int Int, UArray Int Word8) -> FilePath -> IO (IntMap (UArray Int Int, UArray Int Word8)) In readMovie, I'm using the 'insert' function provided by the IntMap module, which justs insert a new key-value pair in the existing IntMap. Your approach is very different: you create 17,770 IntMaps with a single key/value pair in them, and then use union to combine them all. I profiled your approach on the same iMac (using the same +RTS options), and it needed 4m33s to run, using 948M of memory. I think my approach is turning out better because I'm: - building up the IntMap using 'empty' and 'insert', instead of combining 17,770 'singleton' IntMaps (which probably results better GC behavior) - using UArray instead of Urr (although I don't know if that actually makes a difference here) I hope this helps you with figuring out what the bottleneck is on your side. It took me several days to come up with this approach, with the help from various Haskellers at IRC, so I'm surely no expert... I've thrown my current code online at http://boegel.kejo.be/files/Netflix_read-and-parse_24-02-2009.hs , let me know if it's helpful in any way... Also, I was indeed using GHC 6.10.1, although I'm unsure to what extent that matter. greetings, Kenneth -- Kenneth Hoste Paris research group - ELIS - Ghent University, Belgium email: kenneth.hoste@elis.ugent.be website: http://www.elis.ugent.be/~kehoste blog: http://boegel.kejo.be From bulat.ziganshin at gmail.com Mon Mar 2 15:18:01 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 2 15:06:58 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> <49AC21DF.8050306@libero.it> Message-ID: <905867829.20090302231801@gmail.com> Hello Kenneth, Monday, March 2, 2009, 11:14:27 PM, you wrote: > I think my approach is turning out better because I'm: > - building up the IntMap using 'empty' and 'insert', instead of > combining 17,770 'singleton' IntMaps > (which probably results better GC behavior) i don't read into details, but may be it will be better to use sort-and-group approach? OTOH, this makes interesting usecase for mapreduce technologies -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From itkovian at gmail.com Mon Mar 2 15:40:05 2009 From: itkovian at gmail.com (Andy Georges) Date: Mon Mar 2 15:28:49 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> <49AC21DF.8050306@libero.it> Message-ID: <4F7BBC1B-7196-4E1E-A374-233F535016B1@gmail.com> > Hi Kenneth, > I've thrown my current code online at http://boegel.kejo.be/files/Netflix_read-and-parse_24-02-2009.hs > , > let me know if it's helpful in any way... Maybe you could set up a darcs repo for this, such that we can submit patches against your code? -- Andy From mad.one at gmail.com Mon Mar 2 15:51:52 2009 From: mad.one at gmail.com (Austin Seipp) Date: Mon Mar 2 15:40:41 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <1248049868.20090302191435@gmail.com> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> Message-ID: <1236026092-sup-4491@existential.local> Excerpts from Bulat Ziganshin's message of Mon Mar 02 10:14:35 -0600 2009: > let's calculate. if at GC moment your program has allocated 100 mb of > memory and only 50 mb was not a garbage, then memory usage will be 150 > mb ? A copying collector allocates a piece of memory (say 10mb) which is used as the heap, and only one *half* of it ever has data in it. When a copy occurs, all live data is transferred from one half to the other half. So, if you have a 10mb heap initially, that means you have two sides of the heap, both which are 5mb big. If your program has 2mb of live data at the time of a GC, then those 2mb of data are copied over to the other 5mb side. This copying can be done with pointer arithmetic in a basic manner, so you don't need to allocate any more memory for a copy to occur. So the program never uses more than 10mb heap. GHC might be a little different (so correct me if I'm wrong in the case of GHC.) Copying collection has the advantage that for low-lived allocations, GC moments are pretty quick, because the time spent copying is proportional to the size of the live data. It gets slower if your program has lots of live data at once, not only because collections become more frequent, but because copies will become longer in time as well. Austin From cristiano.paris at gmail.com Mon Mar 2 15:52:30 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Mon Mar 2 15:41:12 2009 Subject: [Haskell-cafe] Zippers Message-ID: Hi, I'm trying to catch the connection between delimited continuations and zippers so I wrote a (kinda) zipper interface to a simple tree structure. Here's the code: ------- module Main where import Data.Maybe data Tree a = Leaf a | Fork (Tree a) (Tree a) deriving Show tree = Fork (Fork (Leaf 1) (Leaf 2)) (Fork (Leaf 3) (Fork (Leaf 4) (Leaf 5))) data ZContext a = ZContext { moveUp :: Maybe (ZContext a), moveLeft :: Maybe (ZContext a), moveRight :: Maybe (ZContext a), this :: Maybe a } initZ t = doInitZ Nothing t where doInitZ c (Leaf a) = ZContext c Nothing Nothing $ Just a doInitZ c t@(Fork l r) = ZContext c (Just $ doInitZ s l) (Just $ doInitZ s r) Nothing where s = Just $ doInitZ c t ------- You access the tree in the following way (session from ghci): *Main> this $ fromJust . moveLeft $ fromJust . moveLeft $ initZ tree I read Haskell book's Chapter about Zippers on Wikibooks and I think I understood the underlying concept even if the implementation still seems to me a bit arbitrary (i.e. different implementation can be provided even if the proposed one is neat thinking of differentiation). Hence, I decided to go experimenting myself and came up with the above solution. I know that the interface to a tree having values only on leaves is pointless as the main advantage of using a Zipper is to get O(1) performance on updating but I wanted to keep it as simple as possible. So, can you provide some comments on that implementation? Thank you all, as usual! -- Cristiano From bos at serpentine.com Mon Mar 2 15:55:43 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Mon Mar 2 15:44:25 2009 Subject: [Haskell-cafe] ANNOUNCE: text and text-icu, fast and comprehensive Unicode support using stream fusion In-Reply-To: <49AA8830.1000204@libero.it> References: <49AA8830.1000204@libero.it> Message-ID: On Sun, Mar 1, 2009 at 5:05 AM, Manlio Perillo wrote: > > This is interesting. > Any plans to write a pure Haskell package, using Unicode CLDR data? > http://unicode.org/cldr/ > Foundational l10n work, however important it may be, is an unrewarding slog, so it's the kind of work I'd do under contract, but not for fun. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090302/eea47297/attachment.htm From bulat.ziganshin at gmail.com Mon Mar 2 16:32:53 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 2 16:22:57 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <1236026092-sup-4491@existential.local> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <1236026092-sup-4491@existential.local> Message-ID: <55223260.20090303003253@gmail.com> Hello Austin, Monday, March 2, 2009, 11:51:52 PM, you wrote: >> let's calculate. if at GC moment your program has allocated 100 mb of >> memory and only 50 mb was not a garbage, then memory usage will be 150 >> mb > ? A copying collector allocates a piece of memory (say 10mb) which is > used as the heap, and only one *half* of it ever has data in it. When if you interested, i suggest you to run any memory-eater with +RTS -S switch. it's somewhat hard to decrypt, but finally you will see what i said. let's imagine that you have 10mb heap at moment of GC, and only 7 mb are live. when doing GC, ghc copies live data into new blocks allocated from the OS. so after GC program will occupy 10+7 mb. ghc can't return memory back to the OS, so it uses those 10 mb to fulfill further memory requests. as a result, next GC will occur when 17 mb will be consumed you have described some fixed-pool scheme which is probably simplified description of idea don't taking into account dynamic poll growth -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From manlio_perillo at libero.it Mon Mar 2 16:34:28 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 16:23:19 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> <49AC21DF.8050306@libero.it> Message-ID: <49AC50E4.6060308@libero.it> Kenneth Hoste ha scritto: > [...] > The 26m/700MB I mentioned on my blog was on my ancient PowerBook G4 > (1.5GHz PowerPC G4, 1.25G). > > I redid the same experiment on our iMac (Core2 Duo, 2.0 GHz, 3.0G), i.e.: > - read in all the data > - count the number of keys in the IntMap (which should be 17,770, i.e. > the number of movies) > - compute the mean overall movie rating (which should be 3.6033) > > That task was done in 3m42s, using just 632M of memory, using the > following command: > > ./netflix ./training_set/ +RTS -A128M -s > > The -A option makes sure GC isn't cleaning up stuff too frequently, > while -s just reports some statistics. > Ok, thanks. > The way in which I'm reading in the data is somewhat different from yours. > I construct the IntMap from the ground up, i.e. starting with an empty > IntMap and using foldM, > together with a function readMovie with the following type: > > readMovie :: IntMap (UArray Int Int, UArray Int Word8) -> FilePath -> IO > (IntMap (UArray Int Int, UArray Int Word8)) > > In readMovie, I'm using the 'insert' function provided by the IntMap > module, which justs insert a new key-value pair > in the existing IntMap. > This is the same thing I was doing in a previous version. Some tests showed me that the performances (and memory usage) were pratically the same, so I switched to the new implementation. > Your approach is very different: you create 17,770 IntMaps with a single > key/value pair in them, > and then use union to combine them all. > > I profiled your approach on the same iMac (using the same +RTS options), > and it needed 4m33s to run, using 948M of memory. > This is very strange, because in my tests I got very similar execution time and memory usage. Did you ran my program? Or did you just modified your code? > I think my approach is turning out better because I'm: > > - building up the IntMap using 'empty' and 'insert', instead of > combining 17,770 'singleton' IntMaps > (which probably results better GC behavior) > - using UArray instead of Urr (although I don't know if that actually > makes a difference here) > > I hope this helps you with figuring out what the bottleneck is on your > side. > It took me several days to come up with this approach, with the help > from various Haskellers at IRC, > so I'm surely no expert... > > I've thrown my current code online at > http://boegel.kejo.be/files/Netflix_read-and-parse_24-02-2009.hs , > let me know if it's helpful in any way... > Thanks for sharing! I have executed your program: real 6m6.394s user 1m6.444s sys 0m7.180s 640 MB usage So memory usage don't changes with new versions of GHC (did you tried the new parallel garbage collector?) As for running time, it is my Hard Disk that is slower (the CPU is the same, but I have 2G of RAM). After reading your code I have a suspect. I use ByteString.Lazy to read the file content, and you instead use a strict ByteString. So I have updated the code to use a strict ByteString (maybe an even better solution is to use bytestring-mmap? [1]) I have executed the program, using the same RTS flags as yours: real 6m13.523s user 0m53.931s sys 0m7.812s 815 MB usage This is an huge improvement! Now I have to check if using insert will further improve memory usage. It's unfortunate that GC is not friendly with singleton + union solution. > Also, I was indeed using GHC 6.10.1, although I'm unsure to what extent > that matter. > > greetings, > > Kenneth > [1] unfortunately with bytestring-mmap I'm not sure to have control over resources usage Regards Manlio From pbeadling at mail2web.com Mon Mar 2 16:38:03 2009 From: pbeadling at mail2web.com (Phil) Date: Mon Mar 2 16:26:53 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: <200903020056.08057.daniel.is.fischer@web.de> Message-ID: Thanks again - one quick question about lazy pattern matching below! On 01/03/2009 23:56, "Daniel Fischer" wrote: > > No, it's not that strict. If it were, we wouldn't need the bang on newStockSum > (but lots of applications needing some laziness would break). > > The Monad instance in Control.Monad.State.Strict is > > instance (Monad m) => Monad (StateT s m) where > return a = StateT $ \s -> return (a, s) > m >>= k = StateT $ \s -> do > (a, s') <- runStateT m s > runStateT (k a) s' > fail str = StateT $ \_ -> fail str > > (In the lazy instance, the second line of the >>= implementation is > ~(a,s') <- runStateT m s) > > The state will only be evaluated if "runStateT m" resp. "runStateT (k a)" > require it. However, it is truly separated from the return value a, which is > not the case in the lazy implementation. > The state is an expression of past states in both implementations, the > expression is just much more complicated for the lazy. >> I think I get this - so what the lazy monad is doing is delaying the evaluation of the *pattern* (a,s') until it is absolutely required. This means that each new (value,state) is just passed around as a thunk and not even evaluated to the point where a pair is constructed - it's just a blob, and could be anything as far as haskell is concerned. It follows that each new state cannot evaluated even if we make newStockSum strict as (by adding a bang) because the state tuple newStockSum is wrapped in is completely unevaluated - so even if newStockSum is evaluated INSIDE this blob, haskell will still keep the whole chain. Only when we actually print the result is each state required and then each pair is constructed and incremented as described by my transformer. This means that every tuple is held as a blob in memory right until the end of the full simulation. Now with the strict version each time a new state tuple is created, to check that the result of running the state is at least of the form (thunk,thunk). It won't actually see much improvement just doing this because even though you're constructing pairs on-the-fly we are still treating each state in a lazy fashion. Thus right at the end we still have huge memory bloat, and although we will not do all our pair construction in one go we will still value each state after ALL states have been created - performance improvement is therefore marginal, and I'd expect memory usage to be more or less the same as (thunk,thunk) and thunk must take up the same memory. So, we stick a bang on the state. This forces each state to evaluated at simulation time. This allows the garbage collector to throw away previous states as the present state is no longer a composite of previous states AND each state has been constructed inside it's pair - giving it Normal form. Assuming that is corrected, I think I've cracked it. One last question if we bang a variable i.e. !x = blah blah, can we assume that x will then ALWAYS be in Normal form or does it only evaluate to a given depth, giving us a stricter WHNF variable, but not necessarily absolutely valued? From manlio_perillo at libero.it Mon Mar 2 16:58:58 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 16:47:48 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <49AC50E4.6060308@libero.it> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> <49AC21DF.8050306@libero.it> <49AC50E4.6060308@libero.it> Message-ID: <49AC56A2.60400@libero.it> Manlio Perillo ha scritto: > [...] > I have executed the program, using the same RTS flags as yours: > > real 6m13.523s > user 0m53.931s > sys 0m7.812s > > 815 MB usage > > > This is an huge improvement! > > Now I have to check if using insert will further improve memory usage. And ... surprise! real 6m12.036s user 0m51.303s sys 0m8.433s 813 MB usage As I suspected (you just have to read the IntMap code), there is *no reason* why empty + insert should be better then singleton + union. So the culprit is elsewhere. It may be the use of uvector, or probably it is because you force strict evaluation more often then me. > [...] Regards Manlio From duncan.coutts at worc.ox.ac.uk Mon Mar 2 17:10:26 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Mar 2 16:59:23 2009 Subject: [Haskell-cafe] Cabal and `main-is` field In-Reply-To: <6dbd4d000903020615p4e11e493y6cd864d3874a42e2@mail.gmail.com> References: <49AAC193.60004@libero.it> <1235933796.7915.146.camel@localhost> <6dbd4d000903020615p4e11e493y6cd864d3874a42e2@mail.gmail.com> Message-ID: <1236031826.22402.16.camel@localhost> On Mon, 2009-03-02 at 07:15 -0700, Denis Bueno wrote: > On Sun, Mar 1, 2009 at 11:56, Duncan Coutts wrote: > > That's because it's a bug, not a feature. :-) > > > > Be careful of using this "feature" as we might fix it. > > I've wished for this feature, and have Cabal files right now that > would be cleaner with it. Is there something technically wrong or > undesirable about this feature that necessitates "fixing"? If it's supposed to work it should work consistently. It's a quirk that to support old-style .cabal files we allow build-depends but not other fields in the global section. If we do it properly we should either allow all fields there, or perhaps in an explicit "common" section or something. I hope we can address this and related limitations and quirks in the Cabal-1.8 development cycle. If you want to help out with that let me know and I can give you some pointers. Duncan From daniel.is.fischer at web.de Mon Mar 2 18:36:06 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Mar 2 18:24:52 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: References: Message-ID: <200903030036.06758.daniel.is.fischer@web.de> Am Montag, 2. M?rz 2009 22:38 schrieb Phil: > Thanks again - one quick question about lazy pattern matching below! > > On 01/03/2009 23:56, "Daniel Fischer" wrote: > > No, it's not that strict. If it were, we wouldn't need the bang on > > newStockSum (but lots of applications needing some laziness would break). > > > > The Monad instance in Control.Monad.State.Strict is > > > > instance (Monad m) => Monad (StateT s m) where > > return a = StateT $ \s -> return (a, s) > > m >>= k = StateT $ \s -> do > > (a, s') <- runStateT m s > > runStateT (k a) s' > > fail str = StateT $ \_ -> fail str > > > > (In the lazy instance, the second line of the >>= implementation is > > ~(a,s') <- runStateT m s) > > > > The state will only be evaluated if "runStateT m" resp. "runStateT (k a)" > > require it. However, it is truly separated from the return value a, which > > is not the case in the lazy implementation. > > The state is an expression of past states in both implementations, the > > expression is just much more complicated for the lazy. > > I think I get this - so what the lazy monad is doing is delaying the > evaluation of the *pattern* (a,s') until it is absolutely required. Yes, the lazy bind says give me anything, I'll look at it later (or not). Now it may be that 'k', the function 'm' is bound to, already inspects a, then the pair must be deconstructed, and unless it's a real pair with sufficiently defined first component, you get an error. Or it may be that 'runState(T) (k a)' inspects s', then it's analogous. But if neither really cares, it'll just remain whatever it is until it's needed or thrown away (if some point later in the chain - before anything demanded any evaluation - a 'put 1 >> return 2' appears, we don't need to look at it, so why bother?). A stupid example: ---------------------------------------------------------------------- module UhOh where import Control.Monad import Control.Monad.State.Lazy --import Control.Monad.State.Strict uhOh :: State s () uhOh = State $ \_ -> undefined uhOhT :: Monad m => StateT s m () uhOhT = StateT $ \_ -> return undefined uhOhT2 :: Monad m => StateT s m () uhOhT2 = StateT $ \_ -> undefined oy :: State s () oy = State $ \_ -> ((),undefined) oyT :: Monad m => StateT s m () oyT = StateT $ \_ -> return ((),undefined) hum :: State Int Int hum = do k <- get w <- uhOh put (k+2) return w return (k+1) humT :: Monad m => StateT Int m Int humT = do k <- get w <- uhOhT put (k+2) return w return (k+1) humT2 :: Monad m => StateT Int m Int humT2 = do k <- get w <- uhOhT2 put (k+2) return w return (k+1) whoa n = runState (replicateM_ n hum >> hum) 1 whoaT n = runStateT (replicateM_ n humT >> humT) 1 whoaT2 n = runStateT (replicateM_ n humT2 >> humT2) 1 yum :: State Int Int yum = do k <- get w <- oy put (k+2) return w return (k+1) yumT :: Monad m => StateT Int m Int yumT = do k <- get w <- oyT put (k+2) return w return (k+1) hoha n = runState (replicateM_ n yum >> yum) 1 hohaT n = runStateT (replicateM_ n yumT >> yumT) 1 oops m = runState m 1 ---------------------------------------------------------------------- What happens with whoa 10 hoha 10 oops (whoaT 10) oops (whoaT2 10) oops (hohaT 10) respectively when the Lazy or Strict library is imported? Answer first, then test whether you were right. > This means that each new (value,state) is just passed around as a thunk and > not even evaluated to the point where a pair is constructed - it's just a > blob, and could be anything as far as haskell is concerned. Not quite anything, it must have the correct type, but whether it's _|_, (_|_,_|_), (a,_|_), (_|_,s) or (a,s) (where a and s denote non-_|_ elements of the respective types), the (>>=) doesn't care. Whether any evaluation occurs is up to (>>=)'s arguments. > It follows that each new state cannot evaluated even if we make newStockSum > strict as (by adding a bang) because the state tuple newStockSum is wrapped > in is completely unevaluated - so even if newStockSum is evaluated INSIDE > this blob, haskell will still keep the whole chain. Well, even with the bang, newStockSum will only be evaluated if somebody looks at what mc delivers. In the Strict case, (>>=) does, so newStockSum is evaluated at each step. In the Lazy case, (>>=) doesn't, replicateM_ doesn't, so newStockSum won't be evaluated inside the blob, if it were, it would force the evaluation of the previous pair and almost everything else, then there would have been no problem. What the bang does in the lazy case is to keep the thunk for the evaluation of the states a little smaller and simpler, so the evaluation is a bit faster and uses less memory, but not much (further strictness elsewhere helps, too, as you've investigated). > Only when we actually print the result is each state required and then each > pair is constructed and incremented as described by my transformer. This > means that every tuple is held as a blob in memory right until the end of > the full simulation. > Now with the strict version each time a new state tuple is created, to > check that the result of running the state is at least of the form > (thunk,thunk). It won't actually see much improvement just doing this > because even though you're constructing pairs on-the-fly we are still > treating each state in a lazy fashion. Thus right at the end we still have > huge memory bloat, and although we will not do all our pair construction in > one go we will still value each state after ALL states have been created - > performance > improvement is therefore marginal, and I'd expect memory usage to be more > or less the same as (thunk,thunk) and thunk must take up the same memory. Yes. > > So, we stick a bang on the state. This forces each state to evaluated at > simulation time. This allows the garbage collector to throw away previous > states as the present state is no longer a composite of previous states AND > each state has been constructed inside it's pair - giving it Normal form. Weak head normal form, actually, but since the state is a Double, the two coincide. > > Assuming that is corrected, I think I've cracked it. > > One last question if we bang a variable i.e. !x = blah blah, can we assume > that x will then ALWAYS be in Normal form or does it only evaluate to a > given depth, giving us a stricter WHNF variable, but not necessarily > absolutely valued? Bang patterns and seq, as well as case x of { CTOR y -> ... } evaluate xto WHNF, if you want normal form, you must take sterner measures (e.g., (`using` rnf) from Control.Parallel.Strategies). From chak at cse.unsw.edu.au Mon Mar 2 18:39:35 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Mon Mar 2 18:28:19 2009 Subject: [Haskell-cafe] Status of Haskell under OsX In-Reply-To: <49A7938C.4040802@gmail.com> References: <49A7938C.4040802@gmail.com> Message-ID: BTW, there is a nice native version of GTK for Mac OS X as a proper framework: http://www.gtk-osx.org/ Unfortunately, it seems rather difficult to build gtk2hs with the GTK+ framework as the framework doesn't support pkg-config and gtk2hs knows nothing about Mac frameworks. However, GHC has support for frameworks; so, it should be possible to get this to work. Manuel Arne Dehli Halvorsen: > Manuel M T Chakravarty wrote: >>> I'm planning to purchase a MacBookPro so I'm wondering how well >>> Haskell is supported under this platform. >> >> At least two of the regular contributors to GHC work on Macs. That >> should ensure that Mac OS X is well supported. Installation is >> trivial with the Mac OS X installer package: >> >> http://haskell.org/ghc/download_ghc_6_10_1.html#macosxintel > Hi, following on from this point: > > How does one get gtk2hs running on a mac? > > I have a MacBook Pro, and I've had ghc installed for some time now. > > (first in 6.8.2 (packaged), > then 6.10.1 (packaged), > then 6.8.2 via macports 1.6 > then 6.10.1 via macports 1.7) > > I tried to install gtk2hs via macports, but it didn't work. > (0.9.12? on 6.8.2, then on 6.10.1) > Is there a recipe one could follow? > Can I get the preconditions via macports, and then use cabal to > install > gtk2hs 0.10? > > Grateful for assistance, > Arne D H >> >> Manuel From rmm-haskell at z.odi.ac Mon Mar 2 18:47:38 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Mon Mar 2 18:36:23 2009 Subject: [Haskell-cafe] Status of Haskell under OsX In-Reply-To: References: <49A7938C.4040802@gmail.com> Message-ID: <9E5D194D-FB2D-4502-8BC5-07545B812CF3@z.odi.ac> I use this configuration exclusively... it wasn't actually that hard to set up once I found out that the .pc files are shipped in a strange directory buried in the frameworks. I posted how I got it working back in December: http://sourceforge.net/mailarchive/message.php?msg_name=3E883695-30D3-4CBE-AD14-B08C24D343EF%40z.odi.ac -Ross On Mar 2, 2009, at 6:39 PM, Manuel M T Chakravarty wrote: > BTW, there is a nice native version of GTK for Mac OS X as a proper > framework: > > http://www.gtk-osx.org/ > > Unfortunately, it seems rather difficult to build gtk2hs with the GTK > + framework as the framework doesn't support pkg-config and gtk2hs > knows nothing about Mac frameworks. However, GHC has support for > frameworks; so, it should be possible to get this to work. > > Manuel > > Arne Dehli Halvorsen: >> Manuel M T Chakravarty wrote: >>>> I'm planning to purchase a MacBookPro so I'm wondering how well >>>> Haskell is supported under this platform. >>> >>> At least two of the regular contributors to GHC work on Macs. >>> That should ensure that Mac OS X is well supported. Installation >>> is trivial with the Mac OS X installer package: >>> >>> http://haskell.org/ghc/download_ghc_6_10_1.html#macosxintel >> Hi, following on from this point: >> >> How does one get gtk2hs running on a mac? >> >> I have a MacBook Pro, and I've had ghc installed for some time now. >> >> (first in 6.8.2 (packaged), >> then 6.10.1 (packaged), >> then 6.8.2 via macports 1.6 >> then 6.10.1 via macports 1.7) >> >> I tried to install gtk2hs via macports, but it didn't work. >> (0.9.12? on 6.8.2, then on 6.10.1) >> Is there a recipe one could follow? >> Can I get the preconditions via macports, and then use cabal to >> install >> gtk2hs 0.10? >> >> Grateful for assistance, >> Arne D H >>> >>> Manuel > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From anishmuttreja at gmail.com Mon Mar 2 18:57:44 2009 From: anishmuttreja at gmail.com (Anish Muttreja) Date: Mon Mar 2 18:45:52 2009 Subject: [Haskell-cafe] monadic MapReduce In-Reply-To: <49ABF6F1.60903@libero.it> References: <49AAD334.9090202@libero.it> <20090301185817.GE15163@raven> <49ABF6F1.60903@libero.it> Message-ID: <20090302235744.GA22350@amuttreja-dt> On Mon, Mar 02, 2009 at 04:10:41PM +0100, Manlio Perillo wrote: > Anish Muttreja ha scritto: >> On Sun, Mar 01, 2009 at 07:25:56PM +0100, Manlio Perillo wrote: >>> Hi. >>> >>> I have a function that do some IO (take a file path, read the file, >>> parse, and return some data), and I would like to parallelize it, so >>> that multiple files can be parsed in parallel. >>> >>> I would like to use the simple mapReduce function, >>> from Real Word Haskell: >>> >>> mapReduce :: Strategy b -- evaluation strategy for mapping >>> -> (a -> b) -- map function >>> -> Strategy c -- evaluation strategy for reduction >>> -> ([b] -> c) -- reduce function >>> -> [a] -- list to map over >>> -> c >>> >>> mapReduce mapStrat mapFunc reduceStrat reduceFunc input = >>> mapResult `pseq` reduceResult >>> where mapResult = parMap mapStrat mapFunc input >>> reduceResult = reduceFunc mapResult `using` reduceStrat >>> >>> Is this possible? >>> >>> >>> Thanks Manlio Perillo >> >> Would this work? > > I suspect that it will not work.. > >> Read in each file into a string (or byteString) using a lazy function >> and then call mapReduce with the strings instead of file paths. >> >> import qualified Data.Bytestring.Lazy.Char8 as L >> do >> let handles = map (openFile ) files >> strings <- mapM L.hGetContents handles >> let result = mapReduce ... >> >> The actual work of reading in the file should happen on-demand inside >> the parsing function called by mapReduce. >> > > By doing this I will probably lose any control about file resources usage. OK. How about this. Is there a reason why I can't replace the variables b and c in the type signature of mapReduce with with (IO b') and (IO c'). b and c can be any types. mapReduce :: Strategy (IO b') -- evaluation strategy for mapping -> (a -> IO b') -- map function -> Strategy (IO c') -- evaluation strategy for reduction -> ([IO b'] -> (IO c')) -- reduce function -> [a] -- list to map over -> (IO c') Just remember to wrap all values back in the IO monad. Anish > > > Thanks Manlio From john at repetae.net Mon Mar 2 19:15:25 2009 From: john at repetae.net (John Meacham) Date: Mon Mar 2 19:04:07 2009 Subject: [Haskell-cafe] Re: Hidden module? In-Reply-To: <1235948621.7915.163.camel@localhost> References: <200902271519.47968.daniel.is.fischer@web.de> <20090227215328.32a71c8d@solaris> <20090301210814.GA2631@sliver.repetae.net> <1235948621.7915.163.camel@localhost> Message-ID: <20090303001524.GB2631@sliver.repetae.net> On Sun, Mar 01, 2009 at 11:03:41PM +0000, Duncan Coutts wrote: > > They serve different purposes, hsc2hs is meant to run on the actual > > machine the library is being _built_ _for_ to obtain information that is > > only available on the final build architecture/operating system. as in, > > an hsc file is the lowest level portable code you can write. c2hs is > > more of a developers tool. If anything, I think c2hs should generate hsc > > files, which can then be portably distributed. > > Like hsc2hs, c2hs has to be run using the C headers for the target > machine. It needs these to calculate struct sizes like hsc2hs does. The > reason it cannot generate .hsc files and leave the rest to hsc2hs is > that it also generates Haskell ffi imports. It imports the C functions > at the correct Haskell types. If the C headers on a different platform > are quite different then we will get a type error at compile time. With > hsc2hs we'll just get a segfault. So c2hs and hsc2hs are in the same > class here. They both must be run for the target machine. It still seems like you can get almost all the way there by generating things like (#type guint) in the hsc file. You would not be able to work around APIs that actually differ between architectures, but those are not all that common beyond the inherent incompatabilities due to C calling conventions and structure layouts. As in, you should be able to produce portable hsc files for everything that we could have written portable C code for in the first place, which is a large percentage of libraries. The other reason it would be nice is then we have a clear seperation of concerns, c2hs would just need generic header files, while hsc2hs requires an actual target build environment. Allowing people to build projects that used c2hs with just hsc2hs and not having to install c2hs in the majority of cases. The other reason is that it means that cross compiler support only needs to be implemented in one place, whatever interprets the hsc file. For instance, jhc is a cross compiler by nature, a mac OSX binary created on a linux box is equivalent to one you would create sitting at the mac OSX box and compiling it natively. Generally, bringing this about is quite straightforward, ; jhc --progc i386-mingw32-gcc -mgeneric HelloWorld.hs -o HelloWorld.exe ; wine HelloWorld.exe Hello, World! but when you involve hsc files things get a bit trickier, since it requires not just having access to the appropriate compiler, but the ability to run the resulting program. I'd like to remove that requirement, my current plan was to have jhc natively and transparently handle hsc files just like hs files. a (#type guint) will propagate through all the passes and actually become a 'guint' in the generated C file, likewise, for (#const ..) and other hsc declarations. As in, I am treating hsc files as a sort of standard way to express cross platform C compatability that all compilers should support (either natively or via hsc2hs) rather than specific input to hsc2hs. John -- John Meacham - ?repetae.net?john? From manlio_perillo at libero.it Mon Mar 2 19:22:26 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 19:11:14 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <49AC56A2.60400@libero.it> References: <49ABFBAB.1050106@libero.it> <1248049868.20090302191435@gmail.com> <49AC145A.9080205@libero.it> <49AC21DF.8050306@libero.it> <49AC50E4.6060308@libero.it> <49AC56A2.60400@libero.it> Message-ID: <49AC7842.9000302@libero.it> Manlio Perillo ha scritto: > Manlio Perillo ha scritto: >> [...] >> I have executed the program, using the same RTS flags as yours: >> >> real 6m13.523s >> user 0m53.931s >> sys 0m7.812s >> >> 815 MB usage >> >> >> This is an huge improvement! >> Using UArray and empty + insert: real 5m40.732s user 0m58.620s sys 0m7.264s 660 MB usage Using singleton + union, memory usage is the same: 657 MB So, now: 1) I don't understand why using uvector leaks memory. I'm using the latest version found on Hackage. 2) Why your version of code, using singleton + union, consumes more memory. > [...] Regards Manlio Perillo From lemming at henning-thielemann.de Mon Mar 2 20:03:36 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 2 19:52:22 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <9979e72e0903020403s7e90582br5b0fbca58acebe8f@mail.gmail.com> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <9979e72e0903020403s7e90582br5b0fbca58acebe8f@mail.gmail.com> Message-ID: On Mon, 2 Mar 2009, John Lato wrote: > Hello, > > I am not a super-geek (at least, not compared to others on this list), > but I'll take a try at this anyway. The benefits of iteratees mostly > depend on differences between lazy and strict IO (see ch. 7 of Real > World Haskell for more on this). Maybe a good text for http://www.haskell.org/haskellwiki/Enumerator_and_iteratee ? While I think that the Iteratee pattern has benefits, I suspect that it can't be combined with regular lazy functions, e.g. of type [a] -> [a]. Say I have a chain of functions: read a file, parse it into a tag soup, parse that into an XML tree, transform that tree, format that into a string, write that to a file, and all of these functions are written in a lazy way, which is currently considered good style, I can't use them in conjunction with iteratees. This means, almost all Haskell libraries have to be rewritten or extended from lazy style to iteratee style. The question for me is then: Why having laziness in Haskell at all? Or at least, why having laziness by default, why not having laziness annotation instead of strictness annotation. From manlio_perillo at libero.it Mon Mar 2 20:12:44 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 20:01:30 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 Message-ID: <49AC840C.7060604@libero.it> Hi. In the "help optimizing memory usage for a program" I discovered some interesting things: 1) Using lazy ByteStrings to read files it not a good choice, since the garbage collector is not able to proper garbage cleanup. Running with -F1 RTS flag, however, keeps memory usage down. 2) UArr from uvector leaks memory. I'm rather sure about this. In fact the memory usage of my program is 815 MB, when: - I use lazy ByteString with -F1 flag or - if I use strict ByteString Using UArray and strict ByteString, memory usage is 660 MB. In total I have 17770 arrays, so there is a leak of about 9146 bytes per array. In another program, where I do a lot of array concatenations, memory leak is much more evident. Even using -F1 flag, memory usage grows too much. Is this a know bug? How can I verify if it is really a memory leak bug? pumpkin_ (on #haskell.it) suggested me to use a more recent version of uvector package, from http://patch-tag.com/publicrepos/pumpkin-uvector Using this version memory usage is, finally, 643 MB! (and execution if a bit faster, too). The other program, with a lot of array concatenations, still eats a lot of memory... Thanks Manlio Perillo From dons at galois.com Mon Mar 2 20:14:34 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 2 20:04:03 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AC840C.7060604@libero.it> References: <49AC840C.7060604@libero.it> Message-ID: <20090303011434.GC391@whirlpool.galois.com> manlio_perillo: > Hi. > > In the "help optimizing memory usage for a program" I discovered some > interesting things: > > > 2) UArr from uvector leaks memory. > I'm rather sure about this. Note it was just allocating more than was required, it wasn't "leaking" it in any sense (i.e. losing track of the memory). > Using this version memory usage is, finally, 643 MB! > (and execution if a bit faster, too). Yep, known bug, and closed last month. > The other program, with a lot of array concatenations, still eats a lot > of memory... Concatenating arrays generally copies data. Which uses memory. From seb at modelsciences.com Mon Mar 2 20:31:49 2009 From: seb at modelsciences.com (Simon Beaumont) Date: Mon Mar 2 20:20:30 2009 Subject: [Haskell-cafe] interaction between ghci and cudaBLAS library Message-ID: <22300813.post@talk.nabble.com> In my efforts to integrate this library into Haskell (I am working on OS X 10.5.6 with ghc-6.10.1 and CUDA 2.0) I am getting a bad interaction between the threads in ghci - when I call the library init function via the FFI, ghci will block in __semwait_signal. Of course if I build an executable which I guess has only one thread then all is well. AFAIK the CUDA library is re-entrant (or threadsafe) in that it will initialize a device context for each thread that calls it. I guess that might be part of the problem. Certainly there is a call to _pthread_getspecific in that library. This is show stopper for me as I want to use GHCI to call blas routines on the device (this lends itself very nicely to a monadic approach - leaving the matrices on the device until we are done applying sequential computations - and only then bringing them back into the "real" world). Since there is this association between the device context and the calling thread - is there a way to get a handle on the threading in ghci? (or just have a single thread) But why are we blocking? I would have expected completion or is ghci smart enough to prevent any non-deterministic behaviour that the current setup would entail? Any ideas or suggestions of how to proceed with this? The final work should it be successful will be offered to the community as a basis for doing high performance linear algebra on CUDA devices as well as get my haskell up to speed as a side effect :) -- View this message in context: http://www.nabble.com/interaction-between-ghci-and-cudaBLAS-library-tp22300813p22300813.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Mon Mar 2 20:35:12 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 2 20:24:40 2009 Subject: [Haskell-cafe] interaction between ghci and cudaBLAS library In-Reply-To: <22300813.post@talk.nabble.com> References: <22300813.post@talk.nabble.com> Message-ID: <20090303013512.GD391@whirlpool.galois.com> seb: > > In my efforts to integrate this library into Haskell (I am working on OS X > 10.5.6 with ghc-6.10.1 and CUDA 2.0) I am getting a bad interaction between > the threads in ghci - when I call the library init function via the FFI, > ghci will block in __semwait_signal. Of course if I build an executable > which I guess has only one thread then all is well. > > AFAIK the CUDA library is re-entrant (or threadsafe) in that it will > initialize a device context for each thread that calls it. I guess that > might be part of the problem. Certainly there is a call to > _pthread_getspecific in that library. > > This is show stopper for me as I want to use GHCI to call blas routines on > the device (this lends itself very nicely to a monadic approach - leaving > the matrices on the device until we are done applying sequential > computations - and only then bringing them back into the "real" world). > > Since there is this association between the device context and the calling > thread - is there a way to get a handle on the threading in ghci? (or just > have a single thread) > > But why are we blocking? I would have expected completion or is ghci smart > enough to prevent any non-deterministic behaviour that the current setup > would entail? > > Any ideas or suggestions of how to proceed with this? > The final work should it be successful will be offered to the community as a > basis for doing high performance linear algebra on CUDA devices as well as > get my haskell up to speed as a side effect :) > Do you get the same problem in compiled code? (GHCi is generally for exploratory work only). E.g. ghc -O2 --make .... or ghc -O2 --make -threaded .... -- Don From manlio_perillo at libero.it Mon Mar 2 21:00:07 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 2 20:48:59 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <20090303011434.GC391@whirlpool.galois.com> References: <49AC840C.7060604@libero.it> <20090303011434.GC391@whirlpool.galois.com> Message-ID: <49AC8F27.6040806@libero.it> Don Stewart ha scritto: > manlio_perillo: >> Hi. >> >> In the "help optimizing memory usage for a program" I discovered some >> interesting things: >> >> >> 2) UArr from uvector leaks memory. >> I'm rather sure about this. > > Note it was just allocating more than was required, it wasn't "leaking" > it in any sense (i.e. losing track of the memory). > >> Using this version memory usage is, finally, 643 MB! >> (and execution if a bit faster, too). > > Yep, known bug, and closed last month. > Ok. I should have checked the bug tracker. >> The other program, with a lot of array concatenations, still eats a lot >> of memory... > > Concatenating arrays generally copies data. Which uses memory. > Of course, but why the garbage collector does not "release" this temporary used memory? Note that I'm using the -F1 flag with the RST. Maybe it is a problem with IntMap, when there are a lot of keys? Thanks Manlio Perillo From seb at modelsciences.com Mon Mar 2 21:16:43 2009 From: seb at modelsciences.com (Simon Beaumont) Date: Mon Mar 2 21:05:24 2009 Subject: [Haskell-cafe] interaction between ghci and cudaBLAS library In-Reply-To: <20090303013512.GD391@whirlpool.galois.com> References: <22300813.post@talk.nabble.com> <20090303013512.GD391@whirlpool.galois.com> Message-ID: <22301274.post@talk.nabble.com> Don Stewart-2 wrote: > > > Do you get the same problem in compiled code? (GHCi is generally for > exploratory work only). > if I create an executable run it non-interactively. It works fine: $ ghc -O2 --make -threaded main.hs cublas.hs -lcublas -L${CUDA}/lib No matter whether is it compiled or interpreted it blocks in ghci (interactively), the threading option makes no difference in either case. -- View this message in context: http://www.nabble.com/interaction-between-ghci-and-cudaBLAS-library-tp22300813p22301274.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Mon Mar 2 21:22:46 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 2 21:12:12 2009 Subject: [Haskell-cafe] interaction between ghci and cudaBLAS library In-Reply-To: <22301274.post@talk.nabble.com> References: <22300813.post@talk.nabble.com> <20090303013512.GD391@whirlpool.galois.com> <22301274.post@talk.nabble.com> Message-ID: <20090303022246.GE391@whirlpool.galois.com> seb: > > > Don Stewart-2 wrote: > > > > > > Do you get the same problem in compiled code? (GHCi is generally for > > exploratory work only). > > > > if I create an executable run it non-interactively. It works fine: > > $ ghc -O2 --make -threaded main.hs cublas.hs -lcublas -L${CUDA}/lib > > No matter whether is it compiled or interpreted it blocks in ghci > (interactively), the threading option makes no difference in either case. > GHCi doesn't use the threaded runtime though. So given that: "To allow foreign calls to be made without blocking all the Haskell threads (with GHC), it is only necessary to use the -threaded option when linking your program, and to make sure the foreign import is not marked unsafe. " So I think this is expected? -- Don From ahunter at cs.hmc.edu Mon Mar 2 23:13:11 2009 From: ahunter at cs.hmc.edu (Andrew Hunter) Date: Mon Mar 2 23:01:53 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities Message-ID: <20090303041311.GL27223@knuth.cs.hmc.edu> Several times now I've had to define an EDSL for working with (vaguely) numeric expressions. For stuff like 2*X+Y, this is easy, looking pretty much like: > data Expr = Const Integer | Plus Expr Expr | Times Expr Expr > > instance Num Expr where > fromInterger = Const > (+) = Plus > (*) = Times &c. This lets me get a perfectly nice AST, which is what I want. When I want to be able to express and work with inequalities and equalities, this breaks. Suppose I want to write 2*X + Y < 3. I either have to: a) Hide Prelude.(<) and define a simple < that builds the AST term I want. b) Come up with a new symbol for it that doesn't look totally awful. Neither of these work decently well. Hiding Eq and Ord operators, which is what I effectively have to do for a), is pretty much a nonstarter--we'll have to use them too much for that to be practical. On the other hand, b) works...but is about as ugly as it gets. We have lots and lots of symbols that are already taken for important purposes that are syntactically "near" <,<=,==, and the like: << and >> and >>= for monads, >>> for arrows, etc. There...are not good choices that I know of for the symbols that don't defeat the purpose of making a nice clean EDSL for expressions; I might as well use 3*X + Y `lessthan` 3, which is just not cool. Does anyone know of a good solution, here? Are there good substitutions for all the six operators that are important (<,>,>=,<=,==,/=), that are close enough to be pretty-looking but not used for other important modules? Better yet, though a little harder, is there a nice type trick I'm not thinking of? This works for Num methods but not for Ord methods because: (+) :: (Num a) => a -> a -> a (<) :: (Ord a) => a -> a -> Bool i.e. the return type of comparisons is totally fixed. I don't suppose there's a good way to...well, I don't know what the *right* answer is, but maybe define a new typeclass with a more flexible type for < that lets both standard types return Bool and my expressions return Expr? Any good solution would be appreciated. Thanks, AHH From wren at freegeek.org Tue Mar 3 01:53:44 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Mar 3 01:42:26 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: <20090303041311.GL27223@knuth.cs.hmc.edu> References: <20090303041311.GL27223@knuth.cs.hmc.edu> Message-ID: <49ACD3F8.3030206@freegeek.org> Andrew Hunter wrote: > Several times now I've had to define an EDSL for working with > (vaguely) numeric expressions. For stuff like 2*X+Y, this is easy, > looking pretty much like: > >> data Expr = Const Integer | Plus Expr Expr | Times Expr Expr >> >> instance Num Expr where >> fromInterger = Const >> (+) = Plus >> (*) = Times > > Does anyone know of a good solution, here? Are there good > substitutions for all the six operators that are important > (<,>,>=,<=,==,/=), that are close enough to be pretty-looking but not > used for other important modules? If you're just wanting to build Exprs, then the canonical solution is to use ':' as in (:>), (:>=), (:==), (:/=), (:<=), (:<). The colon is considered a "capital symbol" and so it's what you use as the first letter of symbolic constructors. For symmetry, many folks will ad another colon at the end as well. > data Expr = Const Integer | Expr :+: Expr | Expr :*: Expr | Expr :>: Expr | ... -- Live well, ~wren From ahunter at cs.hmc.edu Tue Mar 3 02:17:28 2009 From: ahunter at cs.hmc.edu (Andrew Hunter) Date: Tue Mar 3 02:06:09 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: <49ACD3F8.3030206@freegeek.org> References: <20090303041311.GL27223@knuth.cs.hmc.edu> <49ACD3F8.3030206@freegeek.org> Message-ID: <20090303071728.GM27223@knuth.cs.hmc.edu> On Tue, Mar 03, 2009 at 01:53:44AM -0500, wren ng thornton wrote: > If you're just wanting to build Exprs, then the canonical solution is to > use ':' as in (:>), (:>=), (:==), (:/=), (:<=), (:<). The colon is > considered a "capital symbol" and so it's what you use as the first letter > of symbolic constructors. For symmetry, many folks will ad another colon at > the end as well. > > > data Expr = Const Integer | Expr :+: Expr | Expr :*: Expr | Expr :>: > Expr | ... > Alas, in several instances (too long to give here) it's impractical to write the DSL just as constructors--several of the operators have to do nontrivial computation. (Plus, I'd still call the :*: solution ugly, personally.) Is it possible to do better? AHH From lennart at augustsson.net Tue Mar 3 02:52:14 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Mar 3 02:40:56 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: <20090303041311.GL27223@knuth.cs.hmc.edu> References: <20090303041311.GL27223@knuth.cs.hmc.edu> Message-ID: I often hide the Prelude and import my own Prelude which reexports the old Prelude, but with these changes. It's still not ideal, by far. -- Lennart class Boolean b where false, true :: b (&&), (||) :: b -> b -> b not :: b -> b instance Boolean Bool where false = False true = True (&&) = (P.&&) (||) = (P.||) not = P.not class (Boolean b) => Eq a b where (==), (/=) :: a -> a -> b x /= y = not (x == y) instance (P.Eq a) => Eq a Bool where (==) = (P.==) (/=) = (P./=) class (Eq a b) => Ord a b where (<), (<=), (>), (>=) :: a -> a -> b instance (P.Ord a) => Ord a Bool where (<) = (P.<) (<=) = (P.<=) (>) = (P.>) (>=) = (P.>=) class (Boolean b) => Conditional a b where (?) :: b -> (a, a) -> a instance Conditional a Bool where c ? (t, e) = if c then t else e On Tue, Mar 3, 2009 at 4:13 AM, Andrew Hunter wrote: > Several times now I've had to define an EDSL for working with > (vaguely) numeric expressions. ?For stuff like 2*X+Y, this is easy, > looking pretty much like: > >> data Expr = Const Integer | Plus Expr Expr | Times Expr Expr >> >> instance Num Expr where >> fromInterger = Const >> (+) = Plus >> (*) = Times > > &c. ?This lets me get a perfectly nice AST, which is what I want. > When I want to be able to express and work with inequalities and > equalities, this breaks. ?Suppose I want to write 2*X + Y < 3. ?I > either have to: > > a) Hide Prelude.(<) and define a simple < that builds the AST term I want. > b) Come up with a new symbol for it that doesn't look totally awful. > > Neither of these work decently well. ?Hiding Eq and Ord operators, > which is what I effectively have to do for a), is pretty much a > nonstarter--we'll have to use them too much for that to be practical. > > On the other hand, b) works...but is about as ugly as it gets. ?We > have lots and lots of symbols that are already taken for important > purposes that are syntactically "near" <,<=,==, and the like: << and >>> and >>= for monads, >>> for arrows, etc. ?There...are not good > choices that I know of for the symbols that don't defeat the purpose > of making a nice clean EDSL for expressions; I might as well use 3*X + > Y `lessthan` 3, which is just not cool. > > Does anyone know of a good solution, here? ?Are there good > substitutions for all the six operators that are important > (<,>,>=,<=,==,/=), that are close enough to be pretty-looking but not > used for other important modules? > > Better yet, though a little harder, is there a nice type trick I'm not > thinking of? ?This works for Num methods but not for Ord methods > because: > > (+) :: (Num a) => a -> a -> a > (<) :: (Ord a) => a -> a -> Bool > > i.e. the return type of comparisons is totally fixed. ?I don't suppose > there's a good way to...well, I don't know what the *right* answer is, > but maybe define a new typeclass with a more flexible type for < that > lets both standard types return Bool and my expressions return Expr? > Any good solution would be appreciated. > > Thanks, > AHH > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Tue Mar 3 04:43:14 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Mar 3 04:31:56 2009 Subject: [Haskell-cafe] Theory about uncurried functions Message-ID: Lambda calculus is a nice theory in which every function always has one input and one output. Functions with multiple arguments can be simulated because functions are first class and hence a function can "return" a function. Multiple outputs cannot be done, one must embed these outputs in some data type, e.g. using a tuple, or one must use continuation passing style. Now, does a similar theory exist of functions that always have one input and one output, but these inputs and outputs are *always* tuples? Or maybe this does not make any sense? From bulat.ziganshin at gmail.com Tue Mar 3 04:50:14 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 3 04:43:28 2009 Subject: [Haskell-cafe] interaction between ghci and cudaBLAS library In-Reply-To: <20090303022246.GE391@whirlpool.galois.com> References: <22300813.post@talk.nabble.com> <20090303013512.GD391@whirlpool.galois.com> <22301274.post@talk.nabble.com> <20090303022246.GE391@whirlpool.galois.com> Message-ID: <289882192.20090303125014@gmail.com> Hello Don, Tuesday, March 3, 2009, 5:22:46 AM, you wrote: > GHCi doesn't use the threaded runtime though. So given that: Don, afair ghci compiled using threaded runtime since 6.6: Prelude> :m Control.Concurrent Prelude Control.Concurrent> rtsSupportsBoundThreads True -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From manlio_perillo at libero.it Tue Mar 3 05:10:48 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 3 04:59:45 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AC8F27.6040806@libero.it> References: <49AC840C.7060604@libero.it> <20090303011434.GC391@whirlpool.galois.com> <49AC8F27.6040806@libero.it> Message-ID: <49AD0228.9020102@libero.it> Manlio Perillo ha scritto: > [...] >>> The other program, with a lot of array concatenations, still eats a >>> lot of memory... >> >> Concatenating arrays generally copies data. Which uses memory. >> > > Of course, but why the garbage collector does not "release" this > temporary used memory? > Note that I'm using the -F1 flag with the RST. > > Maybe it is a problem with IntMap, when there are a lot of keys? > It *is* a problem with IntMap. I have changed the program to not use any array concatenation, and it still requires a lot of memory. Does esist a data structure that is able to store something like 480189 keys with efficient memory usage? Thanks Manlio Perillo From daniel.is.fischer at web.de Tue Mar 3 05:43:24 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Mar 3 05:32:08 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AD0228.9020102@libero.it> References: <49AC840C.7060604@libero.it> <49AC8F27.6040806@libero.it> <49AD0228.9020102@libero.it> Message-ID: <200903031143.24461.daniel.is.fischer@web.de> Am Dienstag, 3. M?rz 2009 11:10 schrieb Manlio Perillo: > Manlio Perillo ha scritto: > > [...] > > > >>> The other program, with a lot of array concatenations, still eats a > >>> lot of memory... > >> > >> Concatenating arrays generally copies data. Which uses memory. > > > > Of course, but why the garbage collector does not "release" this > > temporary used memory? > > Note that I'm using the -F1 flag with the RST. > > > > Maybe it is a problem with IntMap, when there are a lot of keys? > > It *is* a problem with IntMap. > I have changed the program to not use any array concatenation, and it > still requires a lot of memory. > > > Does esist a data structure that is able to store something like 480189 > keys with efficient memory usage? > An array? Might be complicated to write fast code, but the memory overhead should be small. > > Thanks Manlio Perillo From bugfact at gmail.com Tue Mar 3 05:47:44 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Mar 3 05:36:25 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AD0228.9020102@libero.it> References: <49AC840C.7060604@libero.it> <20090303011434.GC391@whirlpool.galois.com> <49AC8F27.6040806@libero.it> <49AD0228.9020102@libero.it> Message-ID: > Does esist a data structure that is able to store something like 480189 keys > with efficient memory usage? What is the range of your keys - do they use the full 32-bit of Int - and what type are the values? From bulat.ziganshin at gmail.com Tue Mar 3 05:50:48 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 3 05:43:29 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AD0228.9020102@libero.it> References: <49AC840C.7060604@libero.it> <20090303011434.GC391@whirlpool.galois.com> <49AC8F27.6040806@libero.it> <49AD0228.9020102@libero.it> Message-ID: <61946063.20090303135048@gmail.com> Hello Manlio, Tuesday, March 3, 2009, 1:10:48 PM, you wrote: > It *is* a problem with IntMap. > I have changed the program to not use any array concatenation, and it > still requires a lot of memory. it may be problem with something else. in particular, check that you don't have lazy thunks stored instead of values > Does esist a data structure that is able to store something like 480189 > keys with efficient memory usage? data.hashtable. at least, i can calculate its memory usage - it should be less than 100 bytes per key even with collecting GC. plus memory required for values ...but intmap should be the same. i still think that you have unforced thunks stored in map -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From davidmiani at gmail.com Tue Mar 3 05:57:57 2009 From: davidmiani at gmail.com (David Miani) Date: Tue Mar 3 05:46:47 2009 Subject: [Haskell-cafe] Difficulties in accessing inner elements of data types Message-ID: <200903032057.57448.davidmiani@gmail.com> Hi, I'm working on a Haskell library for interacting with emacs org files. For those that do not know, an org file is a structured outline style file that has nested headings, text, tables and other elements. For example: * Heading 1 Some text, more text. This is a subelement of Heading 1 1. You can also have list 1. and nested lists 2. more... ** Nested Heading (subelement of Heading 1) text... (subelement of Nested Heading) ** Another level 2 heading (subelement of Heading 1) | Desc | Value | |-----------+--------------------------------------| | Table | You can also have tables in the file | | another | row | | seperator | you can have seps as well, eg | |-----------+--------------------------------------| * Another top level heading There are many more features, see orgmode.org My library enables read and write access to a subset of this format (eg lists aren't parsed atm). The data structures used for writing are: data OrgFile = OrgFile [OrgFileElement] data OrgFileElement = Table OrgTable | Paragraph String | Heading OrgHeading -- heading level, title, subelements data OrgHeading = OrgHeading Int String [OrgFileElement] data OrgTable = OrgTable [OrgTableRow] data OrgTableRow = OrgTableRow [String] | OrgTableRowSep To write a file you contruct a OrgFile out of those elements, and pass it to a writeOrgFile func. Eg: writeOrg $ OrgFile [Heading (OrgHeading 1 "h1" [Paragraph "str"])] would produce: * h1 str I was going to use the same data structures for reading an org file, but it quickly became apparent that this would not be suitable, as you needed the position of the file of an element to be able to report errors. Eg if you needed to report an error that a number was expected, the message "'cat' is not a number" is not very useful, but "Line 2031: 'cat' is not a number" is. So the data structures I used were: data FilePosition = FilePosition Line Column data WithPos a = WithPos { filePos :: FilePosition, innerValue :: a } data OrgTableP = OrgTableP [WithPos OrgTableRow] data OrgFileElementP = TableP OrgTableP | ParagraphP String | HeadingP OrgHeadingP data OrgHeadingP = OrgHeadingP Int String [WithPos OrgFileElementP] data OrgFileP = OrgFileP [WithPos OrgFileElementP] Finally there is a function readOrg, which takes a string, and returns an OrgTableP. Now, this all works as expected (files are correctly being parsed and written), however I am having a lot of trouble trying to come up with a decent API to work with this. While writing an OrgFile is fairly easy, reading (and accessing inner parts) of an org file is very tedious, and modifying them is horrendous. For example, to read the description line for the project named "Project14" in the file: * 2007 Projects ** Project 1 Description: 1 Tags: None ** Project 2 Tags: asdf,fdsa Description: hello * 2008 Projects * 2009 Projects ** Project14 Tags: RightProject Description: we want this requires the code: type ErrorS = String listToEither str [] = Left str listToEither _ (x:_) = Right x get14 :: OrgFileP -> Either ErrorS String get14 (OrgFileP elements) = getDesc =<< (getRightProject . concatProjects) elements where concatProjects :: [WithPos OrgFileElementP] -> [OrgHeadingP] concatProjects [] = [] concatProjects ((WithPos _ (HeadingP h)) : rest) = h : concatProjects rest concatProjects (_ : rest) = concatProjects rest getRightProject :: [OrgHeadingP] -> Either ErrorS OrgHeadingP getRightProject = listToEither "Couldn't find project14" . filter (\(OrgHeadingP _ name _) -> name == "Project14") getDesc :: OrgHeadingP -> Either ErrorS String getDesc (OrgHeadingP _ _ children) = case filter paragraphWithDesc (map innerValue children) of [] -> Left $ show (filePos $ head children) ++ ": Couldn't find desc in project" ((ParagraphP str):_) -> Right str _ -> error "should not be possible" paragraphWithDesc :: OrgFileElementP -> Bool paragraphWithDesc (ParagraphP str) = str =~ "Description" paragraphWithDesc _ = False If you think that is bad, try writing a function that adds the Tag "Hard" to Project2 :( What I really need is a DSL that would allow sql like queries on an OrgFileP. For example: select (anyHeading `next` headingWithName "Project14" `withFailMsg` "couldn't find p14" `next` paragraphMatchingRegex "Description" `withFailMsg` "no desc") org `output` paragraphText would return a String OR select (anyHeading `next` headingWithName "Project2" `next` paragraphMatchingRegex "Tag:") org `modify` paragraphText (++ ",Hard") would return an OrgFile, with the new Hard tag added. However, I don't know if this is even possible, how to do it, or if there is a better alternative to this. I would really apreciate any hints with regards to this. It would be useful to know if there are other libraries that also face this problem, and how they solved it. Finally, I would be grateful for any other advice regarding my code. One thing that has bugged me is my solution for having file position info - my solution never seemed very elegant. Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/3115fb94/attachment.htm From manlio_perillo at libero.it Tue Mar 3 06:03:01 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 3 05:51:46 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: References: <49AC840C.7060604@libero.it> <20090303011434.GC391@whirlpool.galois.com> <49AC8F27.6040806@libero.it> <49AD0228.9020102@libero.it> Message-ID: <49AD0E65.1040402@libero.it> Peter Verswyvelen ha scritto: >> Does esist a data structure that is able to store something like 480189 keys >> with efficient memory usage? > > What is the range of your keys - do they use the full 32-bit of Int - > and what type are the values? > From Netflix Prize documentation: CustomerIDs range from 1 to 2649429, with gaps. There are 480189 users. The values are UArr (Word32 :*: Word 8), from uvector package. Thanks Manlio From ndmitchell at gmail.com Tue Mar 3 06:18:31 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Mar 3 06:07:17 2009 Subject: [Haskell-cafe] Difficulties in accessing inner elements of data types In-Reply-To: <200903032057.57448.davidmiani@gmail.com> References: <200903032057.57448.davidmiani@gmail.com> Message-ID: <404396ef0903030318t3b0e2263m606a39a058399230@mail.gmail.com> Hi David, What you are wanting to do is query and transform a reasonably large AST. Fortunately there are solutions, generic programming should do exactly what you want without too much hassle. I'd personally recommend taking a look at the Uniplate library, starting by reading the Haskell Workshop 2007 paper (its an academic paper, but for you the really useful stuff is in Section 2 which is more tutorial style) - http://www-users.cs.york.ac.uk/~ndm/uniplate/ I'm sure I could solve your particular queries using Uniplate, but I'll leave it for you to take a look and figure out. If you can't figure out how to do it after reading section 2 of the paper mail back and I'll take a closer look. Thanks Neil 2009/3/3 David Miani : > Hi, > I'm working on a Haskell library for interacting with emacs org files. For > those that do not know, an org file is a structured outline style file that > has nested headings, text, tables and other elements. For example: > > * Heading 1 > Some text, more text. This is a subelement of Heading 1 > 1. You can also have list > 1. and nested lists > 2. more... > > ** Nested Heading (subelement of Heading 1) > text... (subelement of Nested Heading) > > ** Another level 2 heading (subelement of Heading 1) > | Desc | Value | > |-----------+--------------------------------------| > | Table | You can also have tables in the file | > | another | row | > | seperator | you can have seps as well, eg | > |-----------+--------------------------------------| > > * Another top level heading > There are many more features, see orgmode.org > > My library enables read and write access to a subset of this format (eg > lists aren't parsed atm). > > The data structures used for writing are: > > data OrgFile = OrgFile [OrgFileElement] > data OrgFileElement = Table OrgTable > | Paragraph String > | Heading OrgHeading > > -- heading level, title, subelements > data OrgHeading = OrgHeading Int String [OrgFileElement] > > data OrgTable = OrgTable [OrgTableRow] > > data OrgTableRow = OrgTableRow [String] | OrgTableRowSep > > > To write a file you contruct a OrgFile out of those elements, and pass it to > a writeOrgFile func. Eg: > > writeOrg $ OrgFile [Heading (OrgHeading 1 "h1" [Paragraph "str"])] > would produce: > * h1 > str > > I was going to use the same data structures for reading an org file, but it > quickly became apparent that this would not be suitable, as you needed the > position of the file of an element to be able to report errors. Eg if you > needed to report an error that a number was expected, the message "'cat' is > not a number" is not very useful, but "Line 2031: 'cat' is not a number" is. > So the data structures I used were: > > data FilePosition = FilePosition Line Column > > data WithPos a = WithPos { > filePos :: FilePosition, > innerValue :: a > } > > data OrgTableP = OrgTableP [WithPos OrgTableRow] > > data OrgFileElementP = TableP OrgTableP > | ParagraphP String > | HeadingP OrgHeadingP > > data OrgHeadingP = OrgHeadingP Int String [WithPos OrgFileElementP] > > data OrgFileP = OrgFileP [WithPos OrgFileElementP] > > > Finally there is a function readOrg, which takes a string, and returns an > OrgTableP. > > > Now, this all works as expected (files are correctly being parsed and > written), however I am having a lot of trouble trying to come up with a > decent API to work with this. While writing an OrgFile is fairly easy, > reading (and accessing inner parts) of an org file is very tedious, and > modifying them is horrendous. > > For example, to read the description line for the project named "Project14" > in the file: > > * 2007 Projects > ** Project 1 > Description: 1 > Tags: None > ** Project 2 > Tags: asdf,fdsa > Description: hello > * 2008 Projects > * 2009 Projects > ** Project14 > Tags: RightProject > Description: we want this > > requires the code: > > type ErrorS = String > listToEither str [] = Left str > listToEither _ (x:_) = Right x > > get14 :: OrgFileP -> Either ErrorS String > get14 (OrgFileP elements) = getDesc =<< (getRightProject . concatProjects) > elements where > concatProjects :: [WithPos OrgFileElementP] -> [OrgHeadingP] > concatProjects [] = [] > concatProjects ((WithPos _ (HeadingP h)) : rest) = h : concatProjects rest > concatProjects (_ : rest) = concatProjects rest > > getRightProject :: [OrgHeadingP] -> Either ErrorS OrgHeadingP > getRightProject = listToEither "Couldn't find project14" . > filter (\(OrgHeadingP _ name _) -> name == "Project14") > > getDesc :: OrgHeadingP -> Either ErrorS String > getDesc (OrgHeadingP _ _ children) = > case filter paragraphWithDesc (map innerValue children) of > [] -> Left $ show (filePos $ head children) ++ > ": Couldn't find desc in project" > ((ParagraphP str):_) -> Right str > _ -> error "should not be possible" > > paragraphWithDesc :: OrgFileElementP -> Bool > paragraphWithDesc (ParagraphP str) = str =~ "Description" > paragraphWithDesc _ = False > > > If you think that is bad, try writing a function that adds the Tag "Hard" to > Project2 :( > > What I really need is a DSL that would allow sql like queries on an > OrgFileP. For example: > select (anyHeading `next` > headingWithName "Project14" `withFailMsg` "couldn't find p14" `next` > paragraphMatchingRegex "Description" `withFailMsg` "no desc") > org `output` paragraphText > > would return a String > OR > select (anyHeading `next` headingWithName "Project2" `next` > paragraphMatchingRegex "Tag:") org `modify` paragraphText (++ ",Hard") > > would return an OrgFile, with the new Hard tag added. > > However, I don't know if this is even possible, how to do it, or if there is > a better alternative to this. I would really apreciate any hints with > regards to this. It would be useful to know if there are other libraries > that also face this problem, and how they solved it. > > Finally, I would be grateful for any other advice regarding my code. One > thing that has bugged me is my solution for having file position info - my > solution never seemed very elegant. > > Thanks, > David > > > > > > > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From duncan.coutts at worc.ox.ac.uk Tue Mar 3 06:30:48 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Mar 3 06:19:46 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AC840C.7060604@libero.it> References: <49AC840C.7060604@libero.it> Message-ID: <1236079848.22402.82.camel@localhost> On Tue, 2009-03-03 at 02:12 +0100, Manlio Perillo wrote: > Hi. > > In the "help optimizing memory usage for a program" I discovered some > interesting things: > > > 1) Using lazy ByteStrings to read files it not a good choice, since the > garbage collector is not able to proper garbage cleanup. > > Running with -F1 RTS flag, however, keeps memory usage down. It is certainly possible to have proper garbage cleanup. I can write programs using lazy ByteStrings that process many megabytes of data and yet run in 1Mb of heap space. At first guess it sounds like you're holding onto too much, if not the whole stream perhaps bits within each chunk. Each chunk read from the file is 64k big and keeping any substring will force the whole chunk to be retained. If you're only keeping a fraction of each chunk you can use the ByteString.Lazy.copy function to make a deep copy and let the original 64k chunk get collected. Duncan From leather at cs.uu.nl Tue Mar 3 06:57:05 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Mar 3 06:45:47 2009 Subject: [Haskell-cafe] ANNOUNCE: Extensible and Modular Generics for the Masses: emgm-0.3 Message-ID: <3c6288ab0903030357y561cf9eei7c54d2b402192dde@mail.gmail.com> ============================================== Extensible and Modular Generics for the Masses ============================================== Extensible and Modular Generics for the Masses (EMGM) is a library for generic programming in Haskell using type classes and a sum-of-products view. ------- Updates ------- emgm-0.3 is the third major release, and it arrives a little over a month after emgm-0.2. Deriving is now greatly improved! Due to recent reports from users, we realized the current implementation just wasn't going to cut it. EMGM already supports a wide range of datatypes, so why not make the deriving code support just as many. Hopefully, it works well for you. Please let us know if your datatype is not supported. There are several new functions in the EMGM family. These include: cast (a type-safe, configurable, generic cast) and everywhere and everywhere' (functions similar to those of the same name in SYB that apply a transformation everywhere a certain type is found). ------- Changes ------- Changes from emgm-0.2 include: *? Improved deriving can now handle datatype collections like this one: ? http://www.haskell.org/pipermail/generics/2009-February/000429.html *? cast function > cast :: Rep (Map a) b => a -> b *? everywhere and everywhere' > everywhere :: Rep (Everywhere a) b => (a -> a) -> b -> b > everywhere' :: Rep (Everywhere' a) b => (a -> a) -> b -> b They both perform transformations on a-values in a b-value. The former does them bottom-up, the latter top-down. The names come from similar functions in SYB that use rank-2 types. Note the difference. > everywhere :: (forall a. Data a => a -> a) -> forall a. Data a => a -> a > everywhere' :: (forall a. Data a => a -> a) -> forall a. Data a => a -> a ------------ Known Issues ------------ Due to a problem with the template-haskell package and Cabal, you cannot cabal-install the emgm package with GHC 6.8. However, take heart! EMGM works very well with GHC 6.8. You merely have to download the tar.gz package from Hackage yourself, build it, and install it. Since it doesn't require any dependencies beyond what comes with GHC, installation is a breeze! ------------------- General Information ------------------- Visit the home page: ?http://www.cs.uu.nl/wiki/GenericProgramming/EMGM ---------------- General Features ---------------- The primary features of EMGM include: * ?Datatype-generic programming using sum-of-product views * ?Large collection of ready-to-use generic functions * ?Included support for standard datatypes: lists, Maybe, tuples * ?Easy to add support for new datatypes * ?Type classes make writing new functions straightforward in a structurally inductive style * ?Generic functions are extensible with ad-hoc cases for arbitrary datatypes * ?Good performance of generic functions The features of this distribution include: * ?The API is thoroughly documented with Haddock * ?Fully tested with QuickCheck and HUnit * ?Program coverage ensures that all useful code has been touched by tests * ?Tested on both Mac and Windows systems ------------ Requirements ------------ EMGM has the following requirements: * ?GHC 6.8.1 - It has been tested with versions 6.8.3 and 6.10.1 * ?Cabal library 1.2.1 - It has been tested with versions 1.2.4.0 and 1.6.0.1. ----------------- Download & Source ----------------- Use caball-install: ?cabal install emgm Get the package: ?http://hackage.haskell.org/cgi-bin/hackage-scripts/package/emgm Check out the current source with Subversion: ?svn checkout https://svn.cs.uu.nl:12443/repos/dgp-haskell/EMGM/trunk Or view it online: ? https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/trunk/ -------- Examples -------- Check out the examples: ?https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/trunk/examples/ -------------- Bugs & Support -------------- Report issues or request features: ? http://code.google.com/p/emgm/issues/list Discuss EMGM with the authors, maintainers, and other interested persons: ?http://www.haskell.org/mailman/listinfo/generics ------- Credits ------- The research for EMGM originated with Ralf Hinze. It was extended with work by Bruno Oliveira and Andres L?h. More details of the library functionality were explored by Alexey Rodriguez. We are very grateful to all of these people for the foundation on which this library was built. The current authors and maintainers of EMGM are: * ?Sean Leather * ?Jos? Pedro Magalh?es * ?Alexey Rodriguez * ?Andres L?h From john at n-brain.net Tue Mar 3 07:15:00 2009 From: john at n-brain.net (John A. De Goes) Date: Tue Mar 3 07:03:52 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: References: <20090303041311.GL27223@knuth.cs.hmc.edu> Message-ID: <4616ED53-1D5D-4700-9455-4A7738219244@n-brain.net> Workarounds for the lack of linguistic overloading. :-) Regards, John A. De Goes N-BRAIN, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Mar 3, 2009, at 12:52 AM, Lennart Augustsson wrote: > I often hide the Prelude and import my own Prelude which reexports the > old Prelude, but with these changes. > It's still not ideal, by far. > > -- Lennart > > class Boolean b where > false, true :: b > (&&), (||) :: b -> b -> b > not :: b -> b > > instance Boolean Bool where > false = False > true = True > (&&) = (P.&&) > (||) = (P.||) > not = P.not > > class (Boolean b) => Eq a b where > (==), (/=) :: a -> a -> b > x /= y = not (x == y) > > instance (P.Eq a) => Eq a Bool where > (==) = (P.==) > (/=) = (P./=) > > class (Eq a b) => Ord a b where > (<), (<=), (>), (>=) :: a -> a -> b > > instance (P.Ord a) => Ord a Bool where > (<) = (P.<) > (<=) = (P.<=) > (>) = (P.>) > (>=) = (P.>=) > > class (Boolean b) => Conditional a b where > (?) :: b -> (a, a) -> a > > instance Conditional a Bool where > c ? (t, e) = if c then t else e > > > On Tue, Mar 3, 2009 at 4:13 AM, Andrew Hunter > wrote: >> Several times now I've had to define an EDSL for working with >> (vaguely) numeric expressions. For stuff like 2*X+Y, this is easy, >> looking pretty much like: >> >>> data Expr = Const Integer | Plus Expr Expr | Times Expr Expr >>> >>> instance Num Expr where >>> fromInterger = Const >>> (+) = Plus >>> (*) = Times >> >> &c. This lets me get a perfectly nice AST, which is what I want. >> When I want to be able to express and work with inequalities and >> equalities, this breaks. Suppose I want to write 2*X + Y < 3. I >> either have to: >> >> a) Hide Prelude.(<) and define a simple < that builds the AST term >> I want. >> b) Come up with a new symbol for it that doesn't look totally awful. >> >> Neither of these work decently well. Hiding Eq and Ord operators, >> which is what I effectively have to do for a), is pretty much a >> nonstarter--we'll have to use them too much for that to be practical. >> >> On the other hand, b) works...but is about as ugly as it gets. We >> have lots and lots of symbols that are already taken for important >> purposes that are syntactically "near" <,<=,==, and the like: << and >>>> and >>= for monads, >>> for arrows, etc. There...are not good >> choices that I know of for the symbols that don't defeat the purpose >> of making a nice clean EDSL for expressions; I might as well use >> 3*X + >> Y `lessthan` 3, which is just not cool. >> >> Does anyone know of a good solution, here? Are there good >> substitutions for all the six operators that are important >> (<,>,>=,<=,==,/=), that are close enough to be pretty-looking but not >> used for other important modules? >> >> Better yet, though a little harder, is there a nice type trick I'm >> not >> thinking of? This works for Num methods but not for Ord methods >> because: >> >> (+) :: (Num a) => a -> a -> a >> (<) :: (Ord a) => a -> a -> Bool >> >> i.e. the return type of comparisons is totally fixed. I don't >> suppose >> there's a good way to...well, I don't know what the *right* answer >> is, >> but maybe define a new typeclass with a more flexible type for < that >> lets both standard types return Bool and my expressions return Expr? >> Any good solution would be appreciated. >> >> Thanks, >> AHH >> _______________________________________________ >> 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 manlio_perillo at libero.it Tue Mar 3 07:18:21 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 3 07:07:26 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <1236079848.22402.82.camel@localhost> References: <49AC840C.7060604@libero.it> <1236079848.22402.82.camel@localhost> Message-ID: <49AD200D.5060102@libero.it> Duncan Coutts ha scritto: > On Tue, 2009-03-03 at 02:12 +0100, Manlio Perillo wrote: >> Hi. >> >> In the "help optimizing memory usage for a program" I discovered some >> interesting things: >> >> >> 1) Using lazy ByteStrings to read files it not a good choice, since the >> garbage collector is not able to proper garbage cleanup. >> >> Running with -F1 RTS flag, however, keeps memory usage down. > > It is certainly possible to have proper garbage cleanup. I can write > programs using lazy ByteStrings that process many megabytes of data and > yet run in 1Mb of heap space. > > At first guess it sounds like you're holding onto too much, if not the > whole stream perhaps bits within each chunk. It is possible. I split the string in lines, then map some functions on each line to parse the data, and finally calling toU, for converting to an UArr. > [...] Thanks Manlio Perillo From john at n-brain.net Tue Mar 3 07:38:52 2009 From: john at n-brain.net (John A. De Goes) Date: Tue Mar 3 07:27:37 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <9979e72e0903020403s7e90582br5b0fbca58acebe8f@mail.gmail.com> Message-ID: <5660FA1A-E8D9-441E-B490-AB6C2C9AB7FD@n-brain.net> Lazy IO is a complete disaster for "interactive IO", such as network and process IO. Moreover, it's somewhat of a failure even for non- interactive IO such as the use case you described, because it's very easy for partial evaluation to lead to unclosed files and lazy evaluation to lead to delayed resource acquisition. I can imagine a few use cases that might benefit from it, but the evidence suggests that most developers trying to solve "real world" problems work extra hard to get their programs working properly with lazy IO. Elsewhere, laziness can be a real boon, so I don't understand your question, "Why have laziness in Haskell at all?" Regards, John A. De Goes N-BRAIN, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Mar 2, 2009, at 6:03 PM, Henning Thielemann wrote: > > On Mon, 2 Mar 2009, John Lato wrote: > >> Hello, >> >> I am not a super-geek (at least, not compared to others on this >> list), >> but I'll take a try at this anyway. The benefits of iteratees mostly >> depend on differences between lazy and strict IO (see ch. 7 of Real >> World Haskell for more on this). > > Maybe a good text for > http://www.haskell.org/haskellwiki/Enumerator_and_iteratee > ? > > While I think that the Iteratee pattern has benefits, I suspect that > it can't be combined with regular lazy functions, e.g. of type [a] - > > [a]. Say I have a chain of functions: read a file, parse it into a > tag soup, parse that into an XML tree, transform that tree, format > that into a string, write that to a file, and all of these functions > are written in a lazy way, which is currently considered good style, > I can't use them in conjunction with iteratees. This means, almost > all Haskell libraries have to be rewritten or extended from lazy > style to iteratee style. The question for me is then: Why having > laziness in Haskell at all? Or at least, why having laziness by > default, why not having laziness annotation instead of strictness > annotation. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From kenneth.hoste at ugent.be Tue Mar 3 08:12:43 2009 From: kenneth.hoste at ugent.be (Kenneth Hoste) Date: Tue Mar 3 08:01:38 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AD0228.9020102@libero.it> References: <49AC840C.7060604@libero.it> <20090303011434.GC391@whirlpool.galois.com> <49AC8F27.6040806@libero.it> <49AD0228.9020102@libero.it> Message-ID: <97F3E455-8249-4279-87D6-3B30C8C6E3D5@ugent.be> On Mar 3, 2009, at 11:10 , Manlio Perillo wrote: > Manlio Perillo ha scritto: >> [...] >>>> The other program, with a lot of array concatenations, still eats >>>> a lot of memory... >>> >>> Concatenating arrays generally copies data. Which uses memory. >>> >> Of course, but why the garbage collector does not "release" this >> temporary used memory? >> Note that I'm using the -F1 flag with the RST. >> Maybe it is a problem with IntMap, when there are a lot of keys? > > It *is* a problem with IntMap. > I have changed the program to not use any array concatenation, and > it still requires a lot of memory. > > > Does esist a data structure that is able to store something like > 480189 keys with efficient memory usage? I ran into the same problem when I first organized the IntMap to use user IDs as keys... The problem is the huge amount of keys, and the small UArrays as values. The overhead of both the IntMap and the UArray data types is just way too big with 480k different keys... I never looked into it thoroughly, but if you look at the definition of IntMap, each key causes several words of overhead, along with one word or so for each UArray. K. -- Kenneth Hoste Paris research group - ELIS - Ghent University, Belgium email: kenneth.hoste@elis.ugent.be website: http://www.elis.ugent.be/~kehoste blog: http://boegel.kejo.be From claus.reinke at talk21.com Tue Mar 3 08:19:15 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Mar 3 08:08:00 2009 Subject: [Haskell-cafe] ANNOUNCE: Extensible and Modular Generics for theMasses: emgm-0.3 References: <3c6288ab0903030357y561cf9eei7c54d2b402192dde@mail.gmail.com> Message-ID: <8CC13A1027C44F039BACA935E98CF749@cr3lt> >Due to a problem with the template-haskell package and Cabal, you >cannot cabal-install the emgm package with GHC 6.8. However, take >heart! EMGM works very well with GHC 6.8. You merely have to download >the tar.gz package from Hackage yourself, build it, and install it. I thought I had seen you mention a workaround for that issue, but if not, perhaps you might want to add your experience to http://hackage.haskell.org/trac/hackage/ticket/326 Cabal should support Cabal-version-dependent Setup.hs There's a sketched hack-around at the end, using Setup.hs only to call to separate Setup-version.hs files, to circumvent Cabal API instabilities. Not nice, but perhaps better than to bypass Cabal alltogether? One would also have to pass parameters, and the Process API has changed in the meantime.., which I why I still think Cabal itself should simply be able to pick cabal-versioned configuration and setup files, if they exist. Claus From claus.reinke at talk21.com Tue Mar 3 08:23:01 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Mar 3 08:11:46 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 References: <49AC840C.7060604@libero.it> <1236079848.22402.82.camel@localhost> <49AD200D.5060102@libero.it> Message-ID: <7DD8072CCCD84A96B408871A394A42D8@cr3lt> >> At first guess it sounds like you're holding onto too much, if not the >> whole stream perhaps bits within each chunk. > > It is possible. > > I split the string in lines, then map some functions on each line to > parse the data, and finally calling toU, for converting to an UArr. Just to make sure (code fragments or, better, reduced examples would make it easier to see what the discussion is about): are you forcing the UArr to be constructed before putting it into the Map? Claus From leather at cs.uu.nl Tue Mar 3 08:42:02 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Mar 3 08:30:43 2009 Subject: [Haskell-cafe] ANNOUNCE: Extensible and Modular Generics for theMasses: emgm-0.3 In-Reply-To: <8CC13A1027C44F039BACA935E98CF749@cr3lt> References: <3c6288ab0903030357y561cf9eei7c54d2b402192dde@mail.gmail.com> <8CC13A1027C44F039BACA935E98CF749@cr3lt> Message-ID: <3c6288ab0903030542x5f4aaf2ayfb31337e0d38ff@mail.gmail.com> > Due to a problem with the template-haskell package and Cabal, you >> cannot cabal-install the emgm package with GHC 6.8. However, take >> heart! EMGM works very well with GHC 6.8. You merely have to download >> the tar.gz package from Hackage yourself, build it, and install it. >> > > I thought I had seen you mention a workaround for that issue, but > if not, perhaps you might want to add your experience to > > http://hackage.haskell.org/trac/hackage/ticket/326 > Cabal should support Cabal-version-dependent Setup.hs > I thought I had worked around it, too. Unfortunately, I can only test once I upload it to Hackage. Once I had, I discovered it wasn't fixed, yet. :-/ It's a problem with cabal-install/Cabal dealing with the lack of version dependencies in template-haskell. Even though I have template-haskell >= 2.2 in my build-depends, cabal-install insists on trying to install 2.3, which of course fails when you're using GHC 6.8. Perhaps my problem cannot be fixed within the Setup.lhs? Maybe cabal-install/Cabal is resolving dependencies solely based on the .cabal file? I don't know. There's a sketched hack-around at the end, using Setup.hs only to call to > separate Setup-version.hs files, to circumvent Cabal API > instabilities. Not nice, but perhaps better than to bypass Cabal > alltogether? One would also have to pass parameters, and the > Process API has changed in the meantime.., which I why I still > think Cabal itself should simply be able to pick cabal-versioned > configuration and setup files, if they exist. > I like the hack in that ticket. Very nice. ;) Though it apparently fails for multiple versions of Cabal. I just checked my system and it produced: $ ghc-pkg field Cabal version version: 1.6.0.1 version: 1.6.0.2 Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/296718df/attachment.htm From derek.a.elkins at gmail.com Tue Mar 3 09:00:20 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue Mar 3 08:49:06 2009 Subject: [Haskell-cafe] Theory about uncurried functions In-Reply-To: References: Message-ID: <1236088820.5820.6.camel@derek-laptop> On Tue, 2009-03-03 at 10:43 +0100, Peter Verswyvelen wrote: > Lambda calculus is a nice theory in which every function always has > one input and one output. Functions with multiple arguments can be > simulated because functions are first class and hence a function can > "return" a function. Multiple outputs cannot be done, one must embed > these outputs in some data type, e.g. using a tuple, or one must use > continuation passing style. > > Now, does a similar theory exist of functions that always have one > input and one output, but these inputs and outputs are *always* > tuples? Or maybe this does not make any sense? There's the kappa calculus and also the related Freyd categories which are related to arrows. Theres also the theory induced by cartesian categories or the theory induced by (symmetric) monoidal categories (which are strengthenings of Freyd categories). You could probably also formalize such a language yourself. From manlio_perillo at libero.it Tue Mar 3 09:35:33 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 3 09:24:19 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <7DD8072CCCD84A96B408871A394A42D8@cr3lt> References: <49AC840C.7060604@libero.it> <1236079848.22402.82.camel@localhost> <49AD200D.5060102@libero.it> <7DD8072CCCD84A96B408871A394A42D8@cr3lt> Message-ID: <49AD4035.6010009@libero.it> Claus Reinke ha scritto: >>> At first guess it sounds like you're holding onto too much, if not the >>> whole stream perhaps bits within each chunk. >> >> It is possible. >> >> I split the string in lines, then map some functions on each line to >> parse the data, and finally calling toU, for converting to an UArr. > > Just to make sure (code fragments or, better, reduced examples > would make it easier to see what the discussion is about): are you > forcing the UArr to be constructed before putting it into the Map? > parse handle = contents <- S.hGetContents handle let v = map singleton' $ ratings contents let m = foldl1' (unionWith appendU) v v `seq` return $! m where -- Build a Map with a single movie rating singleton' :: (Word32, Word8) -> MovieRatings singleton' (id, rate) = singleton (fromIntegral $ id) (singletonU $ pairS (id, rate)) This function gets called over each file, with r <- mapM parse' [1..17770] let movieRatings = foldl1' (unionWith appendU) r The `ratings` function parse each line of the file, and return a tuple. For each line of the file I build an IntMap, then merge them together; The IntMaps, are then further merged in the main function. NOTE that the memory usage is the same if I remove array concatenation. There are 100,000,000 ratings, so I create 100,000,000 arrays containing only one element. However, memory usage is 1 GB just after 800 files. The data type is: type Rating = Word32 :*: Word8 type MovieRatings = IntMap (UArr Rating) -- UArr from uvector Code is here: http://haskell.mperillo.ath.cx/netflix-0.0.1.tar.gz but it is an old version (where I used lazy ByteString). Thanks Manlio Perillo From daniel.is.fischer at web.de Tue Mar 3 09:47:36 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Mar 3 09:36:19 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AD4035.6010009@libero.it> References: <49AC840C.7060604@libero.it> <7DD8072CCCD84A96B408871A394A42D8@cr3lt> <49AD4035.6010009@libero.it> Message-ID: <200903031547.36118.daniel.is.fischer@web.de> Am Dienstag, 3. M?rz 2009 15:35 schrieb Manlio Perillo: > Claus Reinke ha scritto: > >>> At first guess it sounds like you're holding onto too much, if not the > >>> whole stream perhaps bits within each chunk. > >> > >> It is possible. > >> > >> I split the string in lines, then map some functions on each line to > >> parse the data, and finally calling toU, for converting to an UArr. > > > > Just to make sure (code fragments or, better, reduced examples > > would make it easier to see what the discussion is about): are you > > forcing the UArr to be constructed before putting it into the Map? > > parse handle = > contents <- S.hGetContents handle > let v = map singleton' $ ratings contents > let m = foldl1' (unionWith appendU) v > v `seq` return $! m The (v `seq` ) is completely useless. Maybe (size m) `seq` return m would help? > > where > -- Build a Map with a single movie rating > singleton' :: (Word32, Word8) -> MovieRatings > singleton' (id, rate) = > singleton (fromIntegral $ id) (singletonU $ pairS (id, rate)) From bulat.ziganshin at gmail.com Tue Mar 3 09:53:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 3 09:42:45 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <49AD4035.6010009@libero.it> References: <49AC840C.7060604@libero.it> <1236079848.22402.82.camel@localhost> <49AD200D.5060102@libero.it> <7DD8072CCCD84A96B408871A394A42D8@cr3lt> <49AD4035.6010009@libero.it> Message-ID: <1581481873.20090303175347@gmail.com> Hello Manlio, Tuesday, March 3, 2009, 5:35:33 PM, you wrote: > There are 100,000,000 ratings, so I create 100,000,000 arrays containing > only one element. every array needs ~30 bytes - it's a minimal memory block ghc can alloc for variable-sized objects. multiple this by 3 to account for copying GC behavior -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Tue Mar 3 09:57:55 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 3 09:46:49 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <200903031547.36118.daniel.is.fischer@web.de> References: <49AC840C.7060604@libero.it> <7DD8072CCCD84A96B408871A394A42D8@cr3lt> <49AD4035.6010009@libero.it> <200903031547.36118.daniel.is.fischer@web.de> Message-ID: <3010425927.20090303175755@gmail.com> Hello Daniel, Tuesday, March 3, 2009, 5:47:36 PM, you wrote: >> let v = map singleton' $ ratings contents >> let m = foldl1' (unionWith appendU) v >> v `seq` return $! m > The (v `seq` ) is completely useless. > Maybe > (size m) `seq` return m > would help? i suggest return $! length v return $! size m (if size really scans tree instead of using stored value :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From manlio_perillo at libero.it Tue Mar 3 10:00:55 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 3 09:49:48 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <200903031547.36118.daniel.is.fischer@web.de> References: <49AC840C.7060604@libero.it> <7DD8072CCCD84A96B408871A394A42D8@cr3lt> <49AD4035.6010009@libero.it> <200903031547.36118.daniel.is.fischer@web.de> Message-ID: <49AD4627.8070502@libero.it> Daniel Fischer ha scritto: > Am Dienstag, 3. M?rz 2009 15:35 schrieb Manlio Perillo: >> Claus Reinke ha scritto: >>>>> At first guess it sounds like you're holding onto too much, if not the >>>>> whole stream perhaps bits within each chunk. >>>> It is possible. >>>> >>>> I split the string in lines, then map some functions on each line to >>>> parse the data, and finally calling toU, for converting to an UArr. >>> Just to make sure (code fragments or, better, reduced examples >>> would make it easier to see what the discussion is about): are you >>> forcing the UArr to be constructed before putting it into the Map? >> parse handle = >> contents <- S.hGetContents handle >> let v = map singleton' $ ratings contents >> let m = foldl1' (unionWith appendU) v >> v `seq` return $! m > > The (v `seq` ) is completely useless. > Maybe > (size m) `seq` return m > would help? > In one of my tests I did: rnf v `seq` rnf m `seq` return m Memory usage was the same -- XXX these are missing from uvector package instance (NFData a, NFData b) => NFData (a :*: b) where -- NOTE: (:*:) is already strict rnf (a :*: b) = a `seq` b `seq` () instance NFData a => NFData (UArr a) where -- NOTE: UArr is already strict rnf array = array `seq` () Regards Manlio From claus.reinke at talk21.com Tue Mar 3 10:17:33 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Mar 3 10:06:20 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 References: <49AC840C.7060604@libero.it> <1236079848.22402.82.camel@localhost><49AD200D.5060102@libero.it><7DD8072CCCD84A96B408871A394A42D8@cr3lt> <49AD4035.6010009@libero.it> Message-ID: <3DBD09D6D09F4936AB63F37257E8EC9A@cr3lt> >>> I split the string in lines, then map some functions on each line to >>> parse the data, and finally calling toU, for converting to an UArr. >> >> Just to make sure (code fragments or, better, reduced examples >> would make it easier to see what the discussion is about): are you >> forcing the UArr to be constructed before putting it into the Map? > > parse handle = > contents <- S.hGetContents handle > let v = map singleton' $ ratings contents > let m = foldl1' (unionWith appendU) v > v `seq` return $! m > > where > -- Build a Map with a single movie rating > singleton' :: (Word32, Word8) -> MovieRatings > singleton' (id, rate) = > singleton (fromIntegral $ id) (singletonU $ pairS (id, rate)) That helps to make things clearer, I think. One issue is the nature of Maps (strict in keys, non-strict in values). - neither singleton nor unionWith are strict in the Map values, so nothing here forces the evaluation of rate or construction of UArr Prelude Data.IntMap> (unionWith (++) (singleton 1 undefined) (singleton 2 undefined)) `seq` () () - singletonU is strict, but that only means that it will evaluate its parameter if it is evaluated itself (which it isn't, because singleton isn't strict) - seq on a list only forces the first node of the list ((:),[],_|_), so (v `seq`) isn't likely to help much. Also, you probably do not want to force the whole list of singletons before builing the Map, you want the singletons to be constructed and consumed incrementally. - forcing a Map doesn't force any of the values, nor does it force more than the top-level node of whatever the internal Map representation is, so (return $! m) isn't much help, either (by nature of unionWith and foldl1', it'll force all keys before it can say anything much about the Map, but the values remain untouched, burried further under unevaluated (++)s) > type Rating = Word32 :*: Word8 > type MovieRatings = IntMap (UArr Rating) -- UArr from uvector A standard trick to keep Map values evaluated by construction is to make the availability of keys dependent on their values, eg (singleton key) $! value. That won't help with unionWith and the appendUs, but it should allow the source string references to be dropped early, as the singletons are constructed. Hth, Claus From seb at modelsciences.com Tue Mar 3 10:28:13 2009 From: seb at modelsciences.com (Simon Beaumont) Date: Tue Mar 3 10:16:52 2009 Subject: Re[Haskell-cafe] [2]: interaction between ghci and cudaBLAS library In-Reply-To: <289882192.20090303125014@gmail.com> References: <22300813.post@talk.nabble.com> <20090303013512.GD391@whirlpool.galois.com> <22301274.post@talk.nabble.com> <20090303022246.GE391@whirlpool.galois.com> <289882192.20090303125014@gmail.com> Message-ID: <22310841.post@talk.nabble.com> Bulat Ziganshin-2 wrote: > > Hello Don, > > Tuesday, March 3, 2009, 5:22:46 AM, you wrote: > >> GHCi doesn't use the threaded runtime though. So given that: > > Don, afair ghci compiled using threaded runtime since 6.6: > > Prelude> :m Control.Concurrent > Prelude Control.Concurrent> rtsSupportsBoundThreads > True > That's what I thought - the problem seems to be with the interaction between ghci threads (there are four OS threads running on my machine). I read the conc-ffi paper by Simon Marlow, Simon Peyton-Jones and Wolfgang Thaller and whilst that explained the situation regarding bound threads (and indeed how to ensure running a bunch of actions within the same thread context - which gave me some hope), I am still no wiser as to what is going on here and how it can be fixed. It at all. -- View this message in context: http://www.nabble.com/interaction-between-ghci-and-cudaBLAS-library-tp22300813p22310841.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From seb at modelsciences.com Tue Mar 3 10:48:50 2009 From: seb at modelsciences.com (Simon Beaumont) Date: Tue Mar 3 10:37:31 2009 Subject: Re[Haskell-cafe] [2]: interaction between ghci and cudaBLAS library In-Reply-To: <22310841.post@talk.nabble.com> References: <22300813.post@talk.nabble.com> <20090303013512.GD391@whirlpool.galois.com> <22301274.post@talk.nabble.com> <20090303022246.GE391@whirlpool.galois.com> <289882192.20090303125014@gmail.com> <22310841.post@talk.nabble.com> Message-ID: <22311236.post@talk.nabble.com> Simon Beaumont wrote: > > > Bulat Ziganshin-2 wrote: >> >> Hello Don, >> >> Tuesday, March 3, 2009, 5:22:46 AM, you wrote: >> >>> GHCi doesn't use the threaded runtime though. So given that: >> >> Don, afair ghci compiled using threaded runtime since 6.6: >> >> Prelude> :m Control.Concurrent >> Prelude Control.Concurrent> rtsSupportsBoundThreads >> True >> > > That's what I thought - the problem seems to be with the interaction > between ghci threads (there are four OS threads running on my machine). I > read the conc-ffi paper by Simon Marlow, Simon Peyton-Jones and Wolfgang > Thaller and whilst that explained the situation regarding bound threads > (and indeed how to ensure running a bunch of actions within the same > thread context - which gave me some hope), I am still no wiser as to what > is going on here and how it can be fixed. It at all. > > BTW if I wrap a forkOS around this I get control back in the ghci - which confirms the threadedness of that at least but still the ffi call blocks. I'm going to take a closer look inside with gdb again, this feels like some kind of deadlock. Given that in the conc-ffi paper this kind of interaction was anticipated we are not outside the design envelope of ghc(i) so there must be a way to solve this. -- View this message in context: http://www.nabble.com/interaction-between-ghci-and-cudaBLAS-library-tp22300813p22311236.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From mwinter at brocku.ca Tue Mar 3 12:09:21 2009 From: mwinter at brocku.ca (mwinter@brocku.ca) Date: Tue Mar 3 11:57:51 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation Message-ID: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca> Hi, I tried a get into concurrent Haskell using multiple cores. The program below creates 2 task in different threads, executes them, synchronizes the threads using MVar () and calculates the time needed. import System.CPUTime import Control.Concurrent import Control.Concurrent.MVar myTask1 = do return $! fac 60000 print "Task1 done!" where fac 0 = 1 fac n = n * fac (n-1) myTask2 = do return $! fac' 60000 1 1 print "Task2 done!" where fac' n m p = if m>n then p else fac' n (m+1) (m*p) main = do mvar <- newEmptyMVar pico1 <- getCPUTime forkIO (myTask1 >> putMVar mvar ()) myTask2 takeMVar mvar pico2 <- getCPUTime print (pico2 - pico1) I compiled the code using $ ghc FirstFork.hs -threaded and executed it by $ main +RTS -N1 resp. $ main +RTS -N2 I use GHC 6.8.3 on Vista with an Intel Dual Core processor. Instead of getting a speed up when using 2 cores I get as significant slow down, even though there is no sharing in my code above (at least none I am aware of. BTW, that was reason that I use 2 different local factorial functions). On my computer the 1-core version takes about 8.3sec and the 2-core version 12.8sec. When I increase the numbers from 60000 to 100000 the time difference gets even worse (30sec vs 51 sec). Can anybody give me an idea what I am doing wrong? Thanks, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/d8265b50/attachment.htm From lrpalmer at gmail.com Tue Mar 3 12:18:34 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Mar 3 12:07:13 2009 Subject: [Haskell-cafe] Theory about uncurried functions In-Reply-To: References: Message-ID: <7ca3f0160903030918x3e688601t537881c99c11fa58@mail.gmail.com> On Tue, Mar 3, 2009 at 2:43 AM, Peter Verswyvelen wrote: > Lambda calculus is a nice theory in which every function always has > one input and one output. Functions with multiple arguments can be > simulated because functions are first class and hence a function can > "return" a function. Multiple outputs cannot be done, one must embed > these outputs in some data type, e.g. using a tuple, or one must use > continuation passing style. > > Now, does a similar theory exist of functions that always have one > input and one output, but these inputs and outputs are *always* > tuples? Or maybe this does not make any sense? Well, this is not quite an answer to your question, but the curried multiple arguments convention in Haskell is exactly that: a convention. For example, in ML, most functions which take multiple arguments take them in the form of a tuple. They could just as well be curried, but the culture prefers tuples. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/ff0892f9/attachment.htm From allbery at ece.cmu.edu Tue Mar 3 12:19:54 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Mar 3 12:08:44 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: <20090303041311.GL27223@knuth.cs.hmc.edu> References: <20090303041311.GL27223@knuth.cs.hmc.edu> Message-ID: <3841DD8D-86FE-466C-B5A9-3E2651C3F886@ece.cmu.edu> On 2009 Mar 2, at 23:13, Andrew Hunter wrote: > a) Hide Prelude.(<) and define a simple < that builds the AST term I > want. > b) Come up with a new symbol for it that doesn't look totally awful. I guess aesthetics differ; I'd use e.g. $<$, where the $ (to me, from other contexts) means "symbolic". -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/eb7b3cda/PGP.bin From manlio_perillo at libero.it Tue Mar 3 12:20:47 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 3 12:09:34 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <3DBD09D6D09F4936AB63F37257E8EC9A@cr3lt> References: <49AC840C.7060604@libero.it> <1236079848.22402.82.camel@localhost><49AD200D.5060102@libero.it><7DD8072CCCD84A96B408871A394A42D8@cr3lt> <49AD4035.6010009@libero.it> <3DBD09D6D09F4936AB63F37257E8EC9A@cr3lt> Message-ID: <49AD66EF.7060601@libero.it> Claus Reinke ha scritto: >>>> I split the string in lines, then map some functions on each line to >>>> parse the data, and finally calling toU, for converting to an UArr. >>> >>> Just to make sure (code fragments or, better, reduced examples >>> would make it easier to see what the discussion is about): are you >>> forcing the UArr to be constructed before putting it into the Map? >> >> parse handle = >> contents <- S.hGetContents handle >> let v = map singleton' $ ratings contents >> let m = foldl1' (unionWith appendU) v >> v `seq` return $! m >> >> where >> -- Build a Map with a single movie rating >> singleton' :: (Word32, Word8) -> MovieRatings >> singleton' (id, rate) = >> singleton (fromIntegral $ id) (singletonU $ pairS (id, rate)) > > That helps to make things clearer, I think. One issue is > the nature of Maps (strict in keys, non-strict in values). > > - neither singleton nor unionWith are strict in the Map values, so > nothing here forces the evaluation of rate or construction of UArr > But, as I have written, in one of my tests I also tried rnf to force evaluation: rnf v `seq` rnf m `seq` return m where: instance NFData a => NFData (Data.IntMap.IntMap a) where rnf = rnf . Data.IntMap.toList Isn't this sufficient? > [...] > - seq on a list only forces the first node of the list ((:),[],_|_), > so (v `seq`) isn't likely to help much. Also, you probably > do not want to force the whole list of singletons before > builing the Map, you want the singletons to be constructed and > consumed incrementally. > Right, thanks. > >> type Rating = Word32 :*: Word8 >> type MovieRatings = IntMap (UArr Rating) -- UArr from uvector > > A standard trick to keep Map values evaluated by construction > is to make the availability of keys dependent on their values, eg > (singleton key) $! value. That won't help with unionWith and > the appendUs, but it should allow the source string references > to be dropped early, as the singletons are constructed. > Tried; but, even using union instead of unionWith, the memory grows fast as before. Just to check if the culprit is IntMap, isn't possible to write a test program that build a big IntMap (UArr Int) ? Right now I don't have the time. Manlio From bulat.ziganshin at gmail.com Tue Mar 3 12:21:33 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 3 12:10:31 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca> References: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca> Message-ID: <992728526.20090303202133@gmail.com> Hello mwinter, Tuesday, March 3, 2009, 8:09:21 PM, you wrote: > anybody give me an idea what I am doing wrong? 1. add -O2 to compile command 2. add +RTS -s to run commands your program execution time may be dominated by GCs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From wagner.andrew at gmail.com Tue Mar 3 12:25:12 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue Mar 3 12:13:53 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: <20090303041311.GL27223@knuth.cs.hmc.edu> References: <20090303041311.GL27223@knuth.cs.hmc.edu> Message-ID: Not to hijack the thread, but I thought I was the only one that used unix notation for statements like {in,}equalities. I like it! On Mon, Mar 2, 2009 at 11:13 PM, Andrew Hunter wrote: > Several times now I've had to define an EDSL for working with > (vaguely) numeric expressions. For stuff like 2*X+Y, this is easy, > looking pretty much like: > > > data Expr = Const Integer | Plus Expr Expr | Times Expr Expr > > > > instance Num Expr where > > fromInterger = Const > > (+) = Plus > > (*) = Times > > &c. This lets me get a perfectly nice AST, which is what I want. > When I want to be able to express and work with inequalities and > equalities, this breaks. Suppose I want to write 2*X + Y < 3. I > either have to: > > a) Hide Prelude.(<) and define a simple < that builds the AST term I want. > b) Come up with a new symbol for it that doesn't look totally awful. > > Neither of these work decently well. Hiding Eq and Ord operators, > which is what I effectively have to do for a), is pretty much a > nonstarter--we'll have to use them too much for that to be practical. > > On the other hand, b) works...but is about as ugly as it gets. We > have lots and lots of symbols that are already taken for important > purposes that are syntactically "near" <,<=,==, and the like: << and > >> and >>= for monads, >>> for arrows, etc. There...are not good > choices that I know of for the symbols that don't defeat the purpose > of making a nice clean EDSL for expressions; I might as well use 3*X + > Y `lessthan` 3, which is just not cool. > > Does anyone know of a good solution, here? Are there good > substitutions for all the six operators that are important > (<,>,>=,<=,==,/=), that are close enough to be pretty-looking but not > used for other important modules? > > Better yet, though a little harder, is there a nice type trick I'm not > thinking of? This works for Num methods but not for Ord methods > because: > > (+) :: (Num a) => a -> a -> a > (<) :: (Ord a) => a -> a -> Bool > > i.e. the return type of comparisons is totally fixed. I don't suppose > there's a good way to...well, I don't know what the *right* answer is, > but maybe define a new typeclass with a more flexible type for < that > lets both standard types return Bool and my expressions return Expr? > Any good solution would be appreciated. > > Thanks, > AHH > _______________________________________________ > 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/20090303/3f3272fd/attachment-0001.htm From newsham at lava.net Tue Mar 3 12:27:35 2009 From: newsham at lava.net (Tim Newsham) Date: Tue Mar 3 12:16:16 2009 Subject: [Haskell-cafe] monadic MapReduce In-Reply-To: <20090302235744.GA22350@amuttreja-dt> References: <49AAD334.9090202@libero.it> <20090301185817.GE15163@raven> <49ABF6F1.60903@libero.it> <20090302235744.GA22350@amuttreja-dt> Message-ID: > How about this. Is there a reason why I can't > replace the variables b and c in the type signature of mapReduce with with (IO b') > and (IO c'). b and c can be any types. > > mapReduce :: Strategy (IO b') -- evaluation strategy for mapping > -> (a -> IO b') -- map function > -> Strategy (IO c') -- evaluation strategy for reduction > -> ([IO b'] -> (IO c')) -- reduce function > -> [a] -- list to map over > -> (IO c') > > Just remember to wrap all values back in the IO monad. Remember, the idea of map-reduce is to provide a very restrictive programming interface so that you have a lot of flexibility in your execution strategy. If you start loosening the interface you will still be able to execute the program, but you may not be able to perform all the great optimizations you want to perform. For example, if you are using IO actions that are stateful, what are the semantics? Can one map action affect other map actions? Does this imply an ordering of the map functions? Does this imply they all run on the same machine or at least have state communicated between the machines on which they run? The austere interface precludes any of these issues, and therein lies the beauty. > Anish Btw. I prefer the sawzall formulation over the map-reduce formulation. A sawzall program just specifies how to map some data to a monoid and the system is free to mappend the monoid values in whatever order it wants (by applying associativity). Tim Newsham http://www.thenewsh.com/~newsham/ From mwinter at brocku.ca Tue Mar 3 12:31:12 2009 From: mwinter at brocku.ca (mwinter@brocku.ca) Date: Tue Mar 3 12:19:43 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <992728526.20090303202133@gmail.com> References: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca>, <992728526.20090303202133@gmail.com> Message-ID: <49AD2310.28901.CDCF8F@mwinter.brocku.ca> In both runs the same computations are done (sequentially resp. parallel), so the gc should be the same. But still using 2 cores is much slower than using 1 core (same program - no communication). On 3 Mar 2009 at 20:21, Bulat Ziganshin wrote: > Hello mwinter, > > Tuesday, March 3, 2009, 8:09:21 PM, you wrote: > > > anybody give me an idea what I am doing wrong? > > 1. add -O2 to compile command > 2. add +RTS -s to run commands > > your program execution time may be dominated by GCs > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com From sebastian.sylvan at gmail.com Tue Mar 3 12:32:51 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Tue Mar 3 12:21:31 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD2310.28901.CDCF8F@mwinter.brocku.ca> References: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca> <992728526.20090303202133@gmail.com> <49AD2310.28901.CDCF8F@mwinter.brocku.ca> Message-ID: <3d96ac180903030932p248dc219s93732a714d4920f@mail.gmail.com> On Tue, Mar 3, 2009 at 5:31 PM, wrote: > In both runs the same computations are done (sequentially resp. > parallel), so the gc should be the same. But still using 2 cores is > much slower than using 1 core (same program - no communication). Might there not be contention in the allocator/GC that's worsened by having two threads? What happens with -O2? -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/a78830c8/attachment.htm From mwinter at brocku.ca Tue Mar 3 12:36:53 2009 From: mwinter at brocku.ca (mwinter@brocku.ca) Date: Tue Mar 3 12:25:22 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <3d96ac180903030932p248dc219s93732a714d4920f@mail.gmail.com> References: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca>, <49AD2310.28901.CDCF8F@mwinter.brocku.ca>, <3d96ac180903030932p248dc219s93732a714d4920f@mail.gmail.com> Message-ID: <49AD2465.28006.D300F7@mwinter.brocku.ca> It gets a bit faster in general but the problem remains. I have two threads in both runs, once I use 1 core and then 2 cores. The second run is much slower. On 3 Mar 2009 at 17:32, Sebastian Sylvan wrote: > > > > On Tue, Mar 3, 2009 at 5:31 PM, wrote: > In both runs the same computations are done (sequentially resp. > parallel), so the gc should be the same. But still using 2 cores is > much slower than using 1 core (same program - no communication). > > Might there not be contention in the allocator/GC that's worsened by having two threads? > What happens with -O2? > -- > Sebastian Sylvan > +44(0)7857-300802 > UIN: 44640862 > From allbery at ece.cmu.edu Tue Mar 3 12:36:39 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Mar 3 12:25:32 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: References: <20090303041311.GL27223@knuth.cs.hmc.edu> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/fd0291a0/PGP.bin From allbery at ece.cmu.edu Tue Mar 3 12:38:31 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Mar 3 12:27:12 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD2310.28901.CDCF8F@mwinter.brocku.ca> References: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca>, <992728526.20090303202133@gmail.com> <49AD2310.28901.CDCF8F@mwinter.brocku.ca> Message-ID: On 2009 Mar 3, at 12:31, mwinter@brocku.ca wrote: > In both runs the same computations are done (sequentially resp. > parallel), so the gc should be the same. But still using 2 cores is > much slower than using 1 core (same program - no communication). The same GCs are done, but GC has to be done on a single core (currently; parallel GC is in development) so you will see a lot more lock contention when the GC kicks in. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/3fd28d5e/PGP.bin From bulat.ziganshin at gmail.com Tue Mar 3 12:39:05 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 3 12:28:02 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD2310.28901.CDCF8F@mwinter.brocku.ca> References: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca>, <992728526.20090303202133@gmail.com> <49AD2310.28901.CDCF8F@mwinter.brocku.ca> Message-ID: <129327808.20090303203905@gmail.com> Hello mwinter, Tuesday, March 3, 2009, 8:31:12 PM, you wrote: not same :) when you perform two computations at the same time, you have 2x more memory allocated that means that each GC will need more time. and don't forget that GC is single-threaded > In both runs the same computations are done (sequentially resp. > parallel), so the gc should be the same. But still using 2 cores is > much slower than using 1 core (same program - no communication). > On 3 Mar 2009 at 20:21, Bulat Ziganshin wrote: >> Hello mwinter, >> >> Tuesday, March 3, 2009, 8:09:21 PM, you wrote: >> >> > anybody give me an idea what I am doing wrong? >> >> 1. add -O2 to compile command >> 2. add +RTS -s to run commands >> >> your program execution time may be dominated by GCs >> >> >> -- >> Best regards, >> Bulat mailto:Bulat.Ziganshin@gmail.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From wagner.andrew at gmail.com Tue Mar 3 12:39:30 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue Mar 3 12:28:12 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: References: <20090303041311.GL27223@knuth.cs.hmc.edu> Message-ID: Err, I was actually talking about the thread subject, where he actually has the word "{in,}equalities", short for "inequalities and equalities" (more or less). AFAIK, that's unix notation. On Tue, Mar 3, 2009 at 12:36 PM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > On 2009 Mar 3, at 12:25, Andrew Wagner wrote: > > Not to hijack the thread, but I thought I was the only one that used unix > notation for statements like {in,}equalities. I like it! > > > It's actually closer to Windows notation with the bracket on both sides > (and I actually considered making it %<% but to me that looks more > cluttered, plus the S-curve in $ can be a mnemonic for "symbolic" for those > who don't live their lives on Unix). > > -- > 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/20090303/ca074292/attachment.htm From dons at galois.com Tue Mar 3 12:40:48 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 3 12:30:17 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca> References: <49AD1DF1.13044.B9CBD7@mwinter.brocku.ca> Message-ID: <20090303174048.GB3944@whirlpool.galois.com> mwinter: > Hi, > > I tried a get into concurrent Haskell using multiple cores. The program below > creates 2 task in different threads, executes them, synchronizes the threads > using MVar () and calculates the time needed. > > import System.CPUTime > import Control.Concurrent > import Control.Concurrent.MVar > > myTask1 = do > return $! fac 60000 > print "Task1 done!" > where fac 0 = 1 > fac n = n * fac (n-1) > > myTask2 = do > return $! fac' 60000 1 1 > print "Task2 done!" > where fac' n m p = if m>n then p else fac' n (m+1) (m*p) > > main = do > mvar <- newEmptyMVar > pico1 <- getCPUTime > forkIO (myTask1 >> putMVar mvar ()) > myTask2 > takeMVar mvar > pico2 <- getCPUTime > print (pico2 - pico1) > > > I compiled the code using > $ ghc FirstFork.hs -threaded > and executed it by > $ main +RTS -N1 resp. $ main +RTS -N2 > I use GHC 6.8.3 on Vista with an Intel Dual Core processor. Instead of getting > a speed up when using 2 cores I get as significant slow down, even though there > is no sharing in my code above (at least none I am aware of. BTW, that was > reason > that I use 2 different local factorial functions). On my computer the 1-core > version > takes about 8.3sec and the 2-core version 12.8sec. When I increase the numbers > from 60000 to 100000 the time difference gets even worse (30sec vs 51 sec). Can > anybody give me an idea what I am doing wrong? If you just want to check that your machine can do multicore, here's the "hello world" I've been using: import Control.Parallel main = a `par` b `par` c `pseq` print (a + b + c) where a = ack 3 10 b = fac 42 c = fib 34 fac 0 = 1 fac n = n * fac (n-1) ack 0 n = n+1 ack m 0 = ack (m-1) 1 ack m n = ack (m-1) (ack m (n-1)) fib 0 = 0 fib 1 = 1 fib n = fib (n-1) + fib (n-2) To be run as: $ ghc -O2 -threaded --make hello.hs [1 of 1] Compiling Main ( hello.hs, hello.o ) Linking hello ... $ time ./hello +RTS -N2 1405006117752879898543142606244511569936384005711076 ./hello +RTS -N2 2.29s user 0.01s system 152% cpu 1.505 total ^^^^ -- Don From dons at galois.com Tue Mar 3 12:41:44 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 3 12:31:17 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: References: <992728526.20090303202133@gmail.com> <49AD2310.28901.CDCF8F@mwinter.brocku.ca> Message-ID: <20090303174144.GC3944@whirlpool.galois.com> allbery: > On 2009 Mar 3, at 12:31, mwinter@brocku.ca wrote: >> In both runs the same computations are done (sequentially resp. >> parallel), so the gc should be the same. But still using 2 cores is >> much slower than using 1 core (same program - no communication). > > The same GCs are done, but GC has to be done on a single core > (currently; parallel GC is in development) so you will see a lot more > lock contention when the GC kicks in. > Assuming he is using GHC 6.10, the parallel GC is enabled by default when you use -Nn where n > 1. That's is -N4 will use -g4 (4 cores to collect). So GC should be the same or a little faster. -- Don From svein.ove at aas.no Tue Mar 3 12:46:20 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Mar 3 12:34:59 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <20090303174144.GC3944@whirlpool.galois.com> References: <992728526.20090303202133@gmail.com> <49AD2310.28901.CDCF8F@mwinter.brocku.ca> <20090303174144.GC3944@whirlpool.galois.com> Message-ID: <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> On Tue, Mar 3, 2009 at 6:41 PM, Don Stewart wrote: > allbery: >> On 2009 Mar 3, at 12:31, mwinter@brocku.ca wrote: >>> In both runs the same computations are done (sequentially resp. >>> parallel), so the gc should be the same. But still using 2 cores is >>> much slower than using 1 core (same program - no communication). >> >> The same GCs are done, but GC has to be done on a single core >> (currently; parallel GC is in development) so you will see a lot more >> lock contention when the GC kicks in. >> > > Assuming he is using GHC 6.10, the parallel GC is enabled by default > when you use -Nn where n > 1. That's is -N4 will use -g4 ? (4 cores to > collect). So GC should be the same or a little faster. > Further, GHC (6.10 at least) uses one allocation area per thread, meaning there's no contention on allocation. I'd echo the request to try it with -O2, though. From mwinter at brocku.ca Tue Mar 3 12:54:27 2009 From: mwinter at brocku.ca (mwinter@brocku.ca) Date: Tue Mar 3 12:42:56 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> References: <992728526.20090303202133@gmail.com>, <20090303174144.GC3944@whirlpool.galois.com>, <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> Message-ID: <49AD2883.21481.E31944@mwinter.brocku.ca> I am using GHC 6.8.3. The -O2 option made both runs faster but the 2 core run is still much slower that the 1 core version. Will switching to 6.10 make the difference? On 3 Mar 2009 at 18:46, Svein Ove Aas wrote: > On Tue, Mar 3, 2009 at 6:41 PM, Don Stewart wrote: > > allbery: > >> On 2009 Mar 3, at 12:31, mwinter@brocku.ca wrote: > >>> In both runs the same computations are done (sequentially resp. > >>> parallel), so the gc should be the same. But still using 2 cores is > >>> much slower than using 1 core (same program - no communication). > >> > >> The same GCs are done, but GC has to be done on a single core > >> (currently; parallel GC is in development) so you will see a lot more > >> lock contention when the GC kicks in. > >> > > > > Assuming he is using GHC 6.10, the parallel GC is enabled by default > > when you use -Nn where n > 1. That's is -N4 will use -g4 ? (4 cores to > > collect). So GC should be the same or a little faster. > > > Further, GHC (6.10 at least) uses one allocation area per thread, > meaning there's no contention on allocation. > > I'd echo the request to try it with -O2, though. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From allbery at ece.cmu.edu Tue Mar 3 13:11:41 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Mar 3 13:00:36 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD2883.21481.E31944@mwinter.brocku.ca> References: <992728526.20090303202133@gmail.com>, <20090303174144.GC3944@whirlpool.galois.com>, <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> Message-ID: <6949F60E-4787-4863-A24A-F4F22B997567@ece.cmu.edu> On 2009 Mar 3, at 12:54, mwinter@brocku.ca wrote: > I am using GHC 6.8.3. The -O2 option made both runs faster but the 2 > core run > is still much slower that the 1 core version. Will switching to 6.10 > make the difference? If GC contention is the issue, it should. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/20a35a87/PGP.bin From svein.ove at aas.no Tue Mar 3 13:16:28 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Mar 3 13:05:09 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD2883.21481.E31944@mwinter.brocku.ca> References: <992728526.20090303202133@gmail.com> <20090303174144.GC3944@whirlpool.galois.com> <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> Message-ID: <221b53ab0903031016j4943624dy1a045fb571189615@mail.gmail.com> On Tue, Mar 3, 2009 at 6:54 PM, wrote: > I am using GHC 6.8.3. The -O2 option made both runs faster but the 2 core run > is still much slower that the 1 core version. Will switching to 6.10 make the difference? > There are a lot of improvements; it's certainly worth a try. For what it's worth, I tried it myself on 6.10.. details follow, but overall impression is that while you lose some time to overhead, it's still 50% faster than unthreaded. While trying to optimize it, I ran "./test +RTS -N2 -H64m -M64m"; the program promptly ate all my memory, invoking the OOM killer and messing up my system something fierce. This has to be a bug. GC time only accounts for 10% of the time used, but as I read these, the parallell GC didn't do any good. ..I'm stumped. ==== time ./test +RTS -N1 -s ==== "Task1 done!" "Task2 done!" 5750000000000 22,712,520 bytes allocated in the heap 2,982,440 bytes copied during GC 1,983,288 bytes maximum residency (2 sample(s)) 30,208 bytes maximum slop 636 MB total memory in use (58 MB lost due to fragmentation) Generation 0: 42 collections, 0 parallel, 0.12s, 0.13s elapsed Generation 1: 2 collections, 0 parallel, 0.00s, 0.01s elapsed Task 0 (worker) : MUT time: 2.85s ( 6.09s elapsed) GC time: 0.07s ( 0.08s elapsed) Task 1 (worker) : MUT time: 0.00s ( 6.09s elapsed) GC time: 0.00s ( 0.00s elapsed) Task 2 (worker) : MUT time: 2.66s ( 6.09s elapsed) GC time: 0.05s ( 0.06s elapsed) INIT time 0.00s ( 0.00s elapsed) MUT time 4.78s ( 6.09s elapsed) GC time 0.12s ( 0.14s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 4.81s ( 6.23s elapsed) %GC time 2.5% (2.3% elapsed) Alloc rate 4,842,754 bytes per MUT second Productivity 97.5% of total user, 75.3% of total elapsed recordMutableGen_sync: 0 gc_alloc_block_sync: 0 whitehole_spin: 0 gen[0].steps[0].sync_todo: 0 gen[0].steps[0].sync_large_objects: 0 gen[0].steps[1].sync_todo: 0 gen[0].steps[1].sync_large_objects: 0 gen[1].steps[0].sync_todo: 0 gen[1].steps[0].sync_large_objects: 0 real 0m6.319s user 0m4.810s sys 0m0.920s ==== time ./test +RTS -N2 -s ==== "Task2 done!" "Task1 done!" 6860000000000 22,734,040 bytes allocated in the heap 2,926,160 bytes copied during GC 1,976,240 bytes maximum residency (2 sample(s)) 117,584 bytes maximum slop 1234 MB total memory in use (107 MB lost due to fragmentation) Generation 0: 32 collections, 13 parallel, 0.47s, 0.43s elapsed Generation 1: 2 collections, 0 parallel, 0.01s, 0.01s elapsed Parallel GC work balance: 1.00 (4188 / 4188, ideal 2) Task 0 (worker) : MUT time: 0.00s ( 0.00s elapsed) GC time: 0.00s ( 0.00s elapsed) Task 1 (worker) : MUT time: 0.00s ( 0.00s elapsed) GC time: 0.00s ( 0.00s elapsed) Task 2 (worker) : MUT time: 3.10s ( 3.82s elapsed) GC time: 0.09s ( 0.05s elapsed) Task 3 (worker) : MUT time: 2.96s ( 3.82s elapsed) GC time: 0.39s ( 0.39s elapsed) Task 4 (worker) : MUT time: 0.00s ( 3.82s elapsed) GC time: 0.00s ( 0.00s elapsed) INIT time 0.00s ( 0.00s elapsed) MUT time 5.23s ( 3.82s elapsed) GC time 0.48s ( 0.44s elapsed) EXIT time 0.01s ( 0.00s elapsed) Total time 5.72s ( 4.26s elapsed) %GC time 8.4% (10.4% elapsed) Alloc rate 4,338,557 bytes per MUT second Productivity 91.6% of total user, 123.0% of total elapsed recordMutableGen_sync: 0 gc_alloc_block_sync: 0 whitehole_spin: 0 gen[0].steps[0].sync_todo: 0 gen[0].steps[0].sync_large_objects: 0 gen[0].steps[1].sync_todo: 0 gen[0].steps[1].sync_large_objects: 0 gen[1].steps[0].sync_todo: 0 gen[1].steps[0].sync_large_objects: 0 real 0m4.345s user 0m5.680s sys 0m1.250s From andrewcoppin at btinternet.com Tue Mar 3 13:21:42 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Mar 3 13:10:05 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <6949F60E-4787-4863-A24A-F4F22B997567@ece.cmu.edu> References: <992728526.20090303202133@gmail.com>, <20090303174144.GC3944@whirlpool.galois.com>, <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> <6949F60E-4787-4863-A24A-F4F22B997567@ece.cmu.edu> Message-ID: <49AD7536.2070703@btinternet.com> Brandon S. Allbery KF8NH wrote: > On 2009 Mar 3, at 12:54, mwinter@brocku.ca wrote: >> I am using GHC 6.8.3. The -O2 option made both runs faster but the 2 >> core run >> is still much slower that the 1 core version. Will switching to 6.10 >> make the difference? > > > If GC contention is the issue, it should. I just tried it with GHC 6.10.1. Two capabilities is still slower. (See attachments. Compiled with -O2 -threaded.) In both cases, GC time is miniscule. -------------- next part -------------- [("GHC RTS", "Yes") ,("GHC version", "6.10.1") ,("RTS way", "rts_thr") ,("Host platform", "i386-unknown-mingw32") ,("Build platform", "i386-unknown-mingw32") ,("Target platform", "i386-unknown-mingw32") ,("Compiler unregisterised", "NO") ,("Tables next to code", "YES") ] -------------- next part -------------- Cores1 +RTS -N1 -s 16,918,324 bytes allocated in the heap 1,055,836 bytes copied during GC 1,005,356 bytes maximum residency (1 sample(s)) 29,760 bytes maximum slop 1260 MB total memory in use (112 MB lost due to fragmentation) Generation 0: 32 collections, 0 parallel, 0.03s, 0.03s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed Task 0 (worker) : MUT time: 2.53s ( 5.11s elapsed) GC time: 0.02s ( 0.02s elapsed) Task 1 (worker) : MUT time: 0.00s ( 5.11s elapsed) GC time: 0.00s ( 0.00s elapsed) Task 2 (worker) : MUT time: 2.30s ( 5.11s elapsed) GC time: 0.02s ( 0.02s elapsed) INIT time 0.02s ( 0.00s elapsed) MUT time 4.83s ( 5.11s elapsed) GC time 0.03s ( 0.03s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 4.88s ( 5.14s elapsed) %GC time 0.6% (0.6% elapsed) Alloc rate 3,492,815 bytes per MUT second Productivity 99.0% of total user, 93.9% of total elapsed recordMutableGen_sync: 0 gc_alloc_block_sync: 0 whitehole_spin: 0 gen[0].steps[0].sync_todo: 0 gen[0].steps[0].sync_large_objects: 0 gen[0].steps[1].sync_todo: 0 gen[0].steps[1].sync_large_objects: 0 gen[1].steps[0].sync_todo: 0 gen[1].steps[0].sync_large_objects: 0 -------------- next part -------------- Cores1 +RTS -N2 -s 16,926,532 bytes allocated in the heap 1,243,560 bytes copied during GC 794,980 bytes maximum residency (2 sample(s)) 12,012 bytes maximum slop 1927 MB total memory in use (160 MB lost due to fragmentation) Generation 0: 23 collections, 8 parallel, 0.00s, 0.00s elapsed Generation 1: 2 collections, 0 parallel, 0.02s, 0.02s elapsed Parallel GC work balance: 1.00 (1267 / 1267, ideal 2) Task 0 (worker) : MUT time: 0.00s ( 0.00s elapsed) GC time: 0.00s ( 0.00s elapsed) Task 1 (worker) : MUT time: 3.63s ( 4.67s elapsed) GC time: 0.00s ( 0.00s elapsed) Task 2 (worker) : MUT time: 0.00s ( 4.67s elapsed) GC time: 0.00s ( 0.00s elapsed) Task 3 (worker) : MUT time: 3.42s ( 4.67s elapsed) GC time: 0.02s ( 0.02s elapsed) Task 4 (worker) : MUT time: 0.00s ( 4.67s elapsed) GC time: 0.00s ( 0.00s elapsed) INIT time 0.02s ( 0.00s elapsed) MUT time 7.05s ( 4.67s elapsed) GC time 0.02s ( 0.02s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 7.08s ( 4.69s elapsed) %GC time 0.2% (0.3% elapsed) Alloc rate 2,396,677 bytes per MUT second Productivity 99.6% of total user, 150.3% of total elapsed recordMutableGen_sync: 0 gc_alloc_block_sync: 0 whitehole_spin: 0 gen[0].steps[0].sync_todo: 0 gen[0].steps[0].sync_large_objects: 0 gen[0].steps[1].sync_todo: 0 gen[0].steps[1].sync_large_objects: 0 gen[1].steps[0].sync_todo: 0 gen[1].steps[0].sync_large_objects: 0 From svein.ove at aas.no Tue Mar 3 13:23:19 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Mar 3 13:11:58 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD7536.2070703@btinternet.com> References: <992728526.20090303202133@gmail.com> <20090303174144.GC3944@whirlpool.galois.com> <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> <6949F60E-4787-4863-A24A-F4F22B997567@ece.cmu.edu> <49AD7536.2070703@btinternet.com> Message-ID: <221b53ab0903031023u6406c1dcg16af31b30529e573@mail.gmail.com> I feel the need to point something out here. Both for me and Andrew, the program tops out at allocating ~22MB of memory - in total, over its whole run. Why, then, is max heap size over a gigabyte? From andrewcoppin at btinternet.com Tue Mar 3 13:28:30 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Mar 3 13:16:53 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <221b53ab0903031016j4943624dy1a045fb571189615@mail.gmail.com> References: <992728526.20090303202133@gmail.com> <20090303174144.GC3944@whirlpool.galois.com> <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> <221b53ab0903031016j4943624dy1a045fb571189615@mail.gmail.com> Message-ID: <49AD76CE.1090004@btinternet.com> Svein Ove Aas wrote: > For what it's worth, I tried it myself on 6.10.. details follow, but > overall impression is that while you lose some time to overhead, it's > still 50% faster than unthreaded. > Damn. Somebody beat me to it. :-) > While trying to optimize it, I ran "./test +RTS -N2 -H64m -M64m"; the > program promptly ate all my memory, invoking the OOM killer and > messing up my system something fierce. This has to be a bug. > I should point out that approximately 50% of the time, the -N2 version exits with "Cores1: out of memory" rather than running to completion. The -N1 version never does this. I hadn't looked at RAM usage, but it does appear that both programs use... rather a lot of this. (Measurable in gigabytes.) Space leak, anyone? (Presumably in fac or fac'.) From barsoap at web.de Tue Mar 3 13:34:09 2009 From: barsoap at web.de (Achim Schneider) Date: Tue Mar 3 13:23:01 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions References: Message-ID: <20090303193409.1ef0c8cf@solaris> Peter Verswyvelen wrote: > Lambda calculus is a nice theory in which every function always has > one input and one output. Functions with multiple arguments can be > simulated because functions are first class and hence a function can > "return" a function. Multiple outputs cannot be done, one must embed > these outputs in some data type, e.g. using a tuple, or one must use > continuation passing style. > Both input- and output currying are completely orthogonal, for a sufficiently bent definition of orthogonal: forall f :: (a, b) -> c exists g :: a -> b -> c "likewise": forall f :: a -> (b, c) exists (g :: a -> c, h :: a -> c) This is, of course, abstract nonsense[1]: Usually, splitting a function with multiple retvals into two is just a crime against efficiency, if not clarity. I doubt any compiler could be decisive enough to get Sufficiently Smart in this context. > Now, does a similar theory exist of functions that always have one > input and one output, but these inputs and outputs are *always* > tuples? Or maybe this does not make any sense? > I fear it doesn't, at least if the functions are allowed to be passed and return tuples containing bottom or unit, as you'd be left with syntactically awkward versions of single-argument functions, or unary tuples, whatever. Generally speaking, functions are more fundamental than product types[2]: cons :: a -> b -> ((a -> b -> c) -> c) cons a b m = m a b car :: ((a -> b -> a) -> c) -> c) car z = z (\p q -> p) cdr :: ((a -> b -> b) -> c) -> c) cdr z = z (\p q -> q) ...as a comparison, try to define eval and apply in terms of tuples. OTOH, you might be thinking of things like applicative functors, which are product types[2] and can't (necessarily) be escaped from, and not collapsed, either, as would be the case with monads. These are things that are described in terms of a theory, not a theory themselves, though. The important notion is that inside a specific functor, one part of its type always stays the same (or it wouldn't be that functor anymore... duh.) So, to conclude: You aren't likely to find any fundamental theory restricting inputs and outputs to tuples, but you are going to find fundamental theories that enable you to say very interesting things about functions which have their inputs and outputs restricted to arbitrary types, be it sums or products. [1] Specifically, distilled from http://golem.ph.utexas.edu/category/2008/03/computer_scientists_needed_now.html , which is a _very_ good and enlightening read [2] Stolen straight from Exercise 2.4 in the Wizard Book [3] Of a type tag and a value. Stop nitpicking. Tagged lists spoiled me. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From dons at galois.com Tue Mar 3 13:38:39 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 3 13:28:07 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD76CE.1090004@btinternet.com> References: <992728526.20090303202133@gmail.com> <20090303174144.GC3944@whirlpool.galois.com> <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> <221b53ab0903031016j4943624dy1a045fb571189615@mail.gmail.com> <49AD76CE.1090004@btinternet.com> Message-ID: <20090303183839.GD3944@whirlpool.galois.com> andrewcoppin: > Svein Ove Aas wrote: >> For what it's worth, I tried it myself on 6.10.. details follow, but >> overall impression is that while you lose some time to overhead, it's >> still 50% faster than unthreaded. On a quad core, ghc 6.10 snapshot from today: Single threaded whirlpool$ ghc-6.10.1.20090302 -O2 A.hs --make -fforce-recomp [1 of 1] Compiling Main ( A.hs, A.o ) Linking A ... whirlpool$ time ./A "Task2 done!" "Task1 done!" 4000249000000 ./A 3.99s user 0.01s system 99% cpu 4.001 total -threaded, with various N whirlpool$ ghc-6.10.1.20090302 -O2 A.hs -threaded --make [1 of 1] Compiling Main ( A.hs, A.o ) Linking A ... N=1 whirlpool$ time ./A +RTS -N1 -sstderr ./A +RTS -N1 -sstderr "Task2 done!" "Task1 done!" 5908369000000 6,468,629,288 bytes allocated in the heap 128,647,752 bytes copied during GC 1,996,320 bytes maximum residency (563 sample(s)) 426,512 bytes maximum slop 7 MB total memory in use (1 MB lost due to fragmentation) %GC time 61.0% (62.1% elapsed) ^^^^^^^^^^^^^^^^^^^^^ Alloc rate 2,699,611,953 bytes per MUT second Productivity 39.0% of total user, 39.8% of total elapsed ./A +RTS -N1 -sstderr 6.14s user 0.06s system 102% cpu 6.016 total So 61% of time spent in GC. N=2 whirlpool$ time ./A +RTS -N2 -sstderr ./A +RTS -N2 -sstderr "Task2 done!" "Task1 done!" 6360397000000 6,511,269,512 bytes allocated in the heap 3,684,592 bytes copied during GC 1,566,800 bytes maximum residency (3 sample(s)) 34,496 bytes maximum slop 5 MB total memory in use (1 MB lost due to fragmentation) %GC time 43.1% (63.5% elapsed) Alloc rate 1,384,112,532 bytes per MUT second Productivity 56.9% of total user, 82.8% of total elapsed ./A +RTS -N2 -sstderr 8.26s user 0.09s system 146% cpu 5.681 total Getting rid of the space leaky version of fac: whirlpool$ time ./A +RTS -N2 -H50M -sstderr ./A +RTS -N2 -H50M -sstderr "Task1 done!" "Task2 done!" 5700355000000 6,512,828,504 bytes allocated in the heap 1,224,488 bytes copied during GC 6,656 bytes maximum residency (1 sample(s)) 116,136 bytes maximum slop 50 MB total memory in use (1 MB lost due to fragmentation) %GC time 60.6% (76.4% elapsed) Alloc rate 2,778,330,289 bytes per MUT second Productivity 39.4% of total user, 49.5% of total elapsed ./A +RTS -N2 -H50M -sstderr 6.30s user 0.42s system 141% cpu 4.737 total I'm not sure there's anything weird going on here, other than just naive implementations of factorial making my cores hot. From bulat.ziganshin at gmail.com Tue Mar 3 13:40:20 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 3 13:29:25 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <49AD7536.2070703@btinternet.com> References: <992728526.20090303202133@gmail.com>, <20090303174144.GC3944@whirlpool.galois.com>, <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> <6949F60E-4787-4863-A24A-F4F22B997567@ece.cmu.edu> <49AD7536.2070703@btinternet.com> Message-ID: <585299920.20090303214020@gmail.com> Hello Andrew, Tuesday, March 3, 2009, 9:21:42 PM, you wrote: > I just tried it with GHC 6.10.1. Two capabilities is still slower. (See > attachments. Compiled with -O2 -threaded.) i don't think so: Total time 4.88s ( 5.14s elapsed) Total time 7.08s ( 4.69s elapsed) so with 1 thread wall clock time is 5 seconds, with 2 thread wall time is 4.7 seconds cpu time spent increased with 2 threads - this indicates that you either use hyperthreaded/SMT-capable cpu or speed is limited by memory access operations so, my conclusion - this benchmark limited by memory latencies so it cannot be efficiently multithreaded -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From svein.ove at aas.no Tue Mar 3 13:48:58 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Mar 3 13:37:37 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <585299920.20090303214020@gmail.com> References: <992728526.20090303202133@gmail.com> <20090303174144.GC3944@whirlpool.galois.com> <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> <6949F60E-4787-4863-A24A-F4F22B997567@ece.cmu.edu> <49AD7536.2070703@btinternet.com> <585299920.20090303214020@gmail.com> Message-ID: <221b53ab0903031048p5dff6e70t90eded5d27bcb71@mail.gmail.com> So, apparently the 6.10.1 code runs amiss of this bug: http://hackage.haskell.org/trac/ghc/ticket/2747 I'll be upgrading to HEAD now. If no-one else gets around to it first, I'll probably post some more benchmarks afterwards. From andrewcoppin at btinternet.com Tue Mar 3 14:10:52 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Mar 3 13:59:24 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <585299920.20090303214020@gmail.com> References: <992728526.20090303202133@gmail.com>, <20090303174144.GC3944@whirlpool.galois.com>, <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> <6949F60E-4787-4863-A24A-F4F22B997567@ece.cmu.edu> <49AD7536.2070703@btinternet.com> <585299920.20090303214020@gmail.com> Message-ID: <49AD80BC.1020402@btinternet.com> Bulat Ziganshin wrote: > Hello Andrew, > > Tuesday, March 3, 2009, 9:21:42 PM, you wrote: > > >> I just tried it with GHC 6.10.1. Two capabilities is still slower. (See >> attachments. Compiled with -O2 -threaded.) >> > > i don't think so: > > Total time 4.88s ( 5.14s elapsed) > > Total time 7.08s ( 4.69s elapsed) > Damnit. Foiled again! It turns out Process Explorer is reporting CPU time, not wall time. Sorry about that... (This is the second time I've tripped over that one. There doesn't seem to be a way to get it to report wall time either, unfortunately.) > so with 1 thread wall clock time is 5 seconds, with 2 thread wall time > is 4.7 seconds > So a small speedup then. > so, my conclusion - this benchmark limited by memory latencies so it > cannot be efficiently multithreaded > Probably. From haberg at math.su.se Tue Mar 3 14:45:52 2009 From: haberg at math.su.se (Hans Aberg) Date: Tue Mar 3 14:35:21 2009 Subject: [Haskell-cafe] Theory about uncurried functions In-Reply-To: References: Message-ID: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> On 3 Mar 2009, at 10:43, Peter Verswyvelen wrote: > Lambda calculus is a nice theory in which every function always has > one input and one output. Functions with multiple arguments can be > simulated because functions are first class and hence a function can > "return" a function. Multiple outputs cannot be done, one must embed > these outputs in some data type, e.g. using a tuple, or one must use > continuation passing style. > > Now, does a similar theory exist of functions that always have one > input and one output, but these inputs and outputs are *always* > tuples? Or maybe this does not make any sense? I think most of the replies have already described it, but the Church's lambda-calculus is just a minimal theory describing a way to construct functions, which turns out to be quite general, including all algorithms. The first lambda-calculus he describes in his book does not even include the constant functions - for some reason it is convenient. So if you want to have more, just add it. That is why functional computer languages like Haskell can exist. As for currying, it builds on the fact that in the category of sets (but others may not have it) one has a natural equivalence (arguments can also be functions) psi: Hom(A x B, C) --> Hom(A, Hom(B, C)) f |-> (a |-> (b |-> f(a, b))) ((a, b) |-> g(a)(b)) <-| g So it simply means that set-theoretic products can be rewritten into iterated functions. (Strictly speaking, currying involves a choice of natural equivalence psi.) In axiomatic set theory, it is common to construct tuplets (i.e., set- theoretic products) so that (x) = x, (x_1, ..., x_n) = ((x_1, ..., x_(n-1), x_n), and one might set () to the empty set (so that, for example, the real R^0 has only one point). The recursive formula has slipped into functional languages. Pure math, unless there are special requirements, uses naive set theory in which that recursion formula would not be used: in computer lingo, it corresponds to the implementation (axiomatic set theory), and is not part of the interface (naive set theory). By contrast, in lists, [x] is not the same as x. (If S is a set, the set of lists with elements from S is the free monoid on S.) But you might view f() as passing the object () to f, f(x) passes x to f, and f(x_1, ..., x_n) passes (x_1, ..., x_n) to f. So the only addition needed is to add the objects (x_1, ..., x_n), n = 0, 1, 2, ..., to your language. You can still curry the functions if you like to - a convention, just as already noted. Hans Aberg From kolar at fit.vutbr.cz Tue Mar 3 15:28:12 2009 From: kolar at fit.vutbr.cz (=?ISO-8859-2?Q?Du=B9an_Kol=E1=F8?=) Date: Tue Mar 3 15:16:08 2009 Subject: [Haskell-cafe] Threading and Mullticore Computation In-Reply-To: <585299920.20090303214020@gmail.com> References: <992728526.20090303202133@gmail.com>, <20090303174144.GC3944@whirlpool.galois.com>, <221b53ab0903030946o26b69856odfef0a55bc5fb4bf@mail.gmail.com> <49AD2883.21481.E31944@mwinter.brocku.ca> <6949F60E-4787-4863-A24A-F4F22B997567@ece.cmu.edu> <49AD7536.2070703@btinternet.com> <585299920.20090303214020@gmail.com> Message-ID: <49AD92DC.7000003@fit.vutbr.cz> Hello, IMO, the conclusion about instant cache misses due to several threads sharing memory and/or performing large memory consumption is very highly probable, especially on Intel CPUs with shared L2 cache. I have several examples, where threading means significant time consumption increase ( = * ). My personal conclusion - use linear recursive functions only (so that they could be optimized), Int instead of Integer, if possible, no data structure traversal (unless such a structure is very small, L2 caches are several MBs only). Such a way cache misses are minimized for both/all threads. Moreover, OS needs some time instantly (=> cache refill/misses), thus, I've devoted one core for OS, others for computation (quad core), which brings certain improvement and more accurate measurements. Regards Dusan Bulat Ziganshin wrote: > Hello Andrew, > > Tuesday, March 3, 2009, 9:21:42 PM, you wrote: > > >> I just tried it with GHC 6.10.1. Two capabilities is still slower. (See >> attachments. Compiled with -O2 -threaded.) >> > > i don't think so: > > Total time 4.88s ( 5.14s elapsed) > > Total time 7.08s ( 4.69s elapsed) > > so with 1 thread wall clock time is 5 seconds, with 2 thread wall time > is 4.7 seconds > > cpu time spent increased with 2 threads - this indicates that you > either use hyperthreaded/SMT-capable cpu or speed is limited by memory > access operations > > so, my conclusion - this benchmark limited by memory latencies so it > cannot be efficiently multithreaded > > > From vanenkj at gmail.com Tue Mar 3 16:47:46 2009 From: vanenkj at gmail.com (John Van Enk) Date: Tue Mar 3 16:36:27 2009 Subject: [Haskell-cafe] Relying on GCC as the hsc2hs C compiler Message-ID: While working on my new bindings project (using hsc2hs) I came across the __alignof__() statement available in GNU's C compiler. As it turns out, having this computed for me in Storable instances using something like this would be great: instance Storable Foo where .... sizeOf _ = #{const sizeof(CFoo)} alignment _ = #{const __alignof__(CFoo)} .... Can I rely on hsc2hs using GCC? How many people will hate me if I depend on GCC-specific extensions? Legal? Acceptable? Infuriating? /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090303/e4212911/attachment-0001.htm From lazycat.manatee at gmail.com Tue Mar 3 16:52:16 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue Mar 3 16:43:53 2009 Subject: [Haskell-cafe] How to build sourceview depend for gtk2hs? Message-ID: <87zlg2i8a7.fsf@debian.domain> Hi all, I use Debian testing. I have install GHC 6.10.1 binary package. When i use "autoreconf && ./configure --enable-docs" to config gtk2hs ************************************************** * Configuration completed successfully. * * The following packages will be built: * * glib : yes * gtk : yes * gio : yes * glade : yes * cairo : yes * svgcairo : yes * gtkglext : yes * gconf : yes * sourceview : no * gtksourceview2 : yes * mozembed : yes * soegtk : yes * gnomevfs : yes * gstreamer : yes * documentation : yes * * Now do "(g)make" followed by "(g)make install" ************************************************** But "sourceview" is not pass, have anyone successful? I have install below packages: libglade2-dev libgtksourceview-dev libgconf2-dev librsvg2-dev libgstreamer-plugins-base0.10-dev libgstreamer0.10-dev libgtkglext1-dev libgnomevfs2-dev xulrunner-dev So i need install which depend package to fix above problem? Thanks! Below is the detail config information. checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking for style of include used by make... GNU checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking dependency style of gcc... none checking how to run the C preprocessor... gcc -E checking for a BSD-compatible install... /usr/bin/install -c checking whether ln -s works... yes checking for ar... /usr/bin/ar checking for ld... /usr/bin/ld checking for basename... /usr/bin/basename checking for grep that handles long lines and -e... /bin/grep checking for gzip... /bin/gzip checking for a sed that does not truncate output... /bin/sed checking for cut... /usr/bin/cut checking for tar... /bin/tar checking for touch... /usr/bin/touch checking for ranlib... ranlib checking for xargs... /usr/bin/xargs checking for ghc... /usr/local/bin/ghc checking version of GHC... 6.10.1 checking for ghc-pkg... /usr/local/bin/ghc-pkg checking whether to build deprecated bindings... yes checking whether to build deprecated packages (gnomevfs, sourceview)... yes checking for the GHC package "base"... yes, version 4.0.0.0 checking for the GHC package "haskell98"... yes, version 1.0.1.0 checking for the GHC package "mtl"... yes, version 1.1.0.2 checking for the GHC package "bytestring"... yes, version 0.9.1.4 checking for the GHC package "containers"... yes, version 0.2.0.0 checking for the GHC package "array"... yes, version 0.2.0.0 checking for the GHC package "old-time"... yes, version 1.0.0.1 checking for the GHC package "pretty"... yes, version 1.0.1.0 checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for GLIB... yes checking for GTK... yes checking whether to build gtk package... yes checking for GIO... yes checking whether to build gio package... yes checking for LIBGLADE... yes checking whether to build glade package... yes checking for GCONF... yes checking whether to build gconf package... yes checking for GTKSOURCEVIEW2... yes checking whether to build gtksourceview2 package... yes checking whether to build sourceview package... no checking for MOZILLA_MOZEMBED... yes checking whether to build mozembed package... yes checking for SEAMONKEY_MOZEMBED... no checking whether to build mozembed package... no checking for FIREFOX_MOZEMBED... no checking whether to build mozembed package... no checking for XULRUNNER_MOZEMBED... no checking whether to build mozembed package... no checking for CAIRO... yes checking whether to build cairo package... yes checking for SVGCAIRO... yes checking whether to build svgcairo package... yes checking for GTKGLEXT... yes checking whether to build gtkglext package... yes checking for GNOMEVFS... yes checking whether to build gnomevfs package... yes checking for GSTREAMER... yes checking whether to build gstreamer package... yes checking for hsc2hs... /usr/local/bin/hsc2hs checking for happy... /usr/local/bin/happy checking version of happy... 1.18.2 checking for alex... /usr/local/bin/alex checking for haddock... /usr/local/bin/haddock checking version of haddock... 2.4.1 configure: creating ./config.status config.status: creating Makefile config.status: creating gtk2hs.spec config.status: creating mk/chsDepend config.status: creating mk/link-splitobjs.sh config.status: creating mk/fix-package-conf.sh config.status: creating docs/prologue.txt config.status: creating glib/glib.package.conf config.status: creating glib/glib.cabal config.status: creating gtk/gtk.package.conf config.status: creating gtk/gtk.cabal config.status: creating gio/gio.package.conf config.status: creating gio/gio.cabal config.status: creating glade/glade.package.conf config.status: creating glade/glade.cabal config.status: creating gconf/gconf.package.conf config.status: creating gconf/gconf.cabal config.status: creating sourceview/sourceview.package.conf config.status: creating sourceview/sourceview.cabal config.status: creating gtksourceview2/gtksourceview2.package.conf config.status: creating gtksourceview2/gtksourceview2.cabal config.status: creating mozembed/mozembed.package.conf config.status: creating mozembed/mozembed.cabal config.status: creating cairo/cairo.package.conf config.status: creating cairo/cairo.cabal config.status: creating svgcairo/svgcairo.package.conf config.status: creating svgcairo/svgcairo.cabal config.status: creating gtkglext/gtkglext.package.conf config.status: creating gtkglext/gtkglext.cabal config.status: creating soegtk/soegtk.package.conf config.status: creating soegtk/soegtk.cabal config.status: creating gnomevfs/gnomevfs.package.conf config.status: creating gnomevfs/gnomevfs.cabal config.status: creating gstreamer/gstreamer.package.conf config.status: creating gstreamer/gstreamer.cabal config.status: creating gtk2hs-config.h config.status: gtk2hs-config.h is unchanged config.status: executing depfiles commands config.status: executing default commands ************************************************** * Configuration completed successfully. * * The following packages will be built: * * glib : yes * gtk : yes * gio : yes * glade : yes * cairo : yes * svgcairo : yes * gtkglext : yes * gconf : yes * sourceview : no * gtksourceview2 : yes * mozembed : yes * soegtk : yes * gnomevfs : yes * gstreamer : yes * documentation : yes * * Now do "(g)make" followed by "(g)make install" ************************************************** -- Andy From allbery at ece.cmu.edu Tue Mar 3 16:57:24 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Mar 3 16:46:05 2009 Subject: [Haskell-cafe] How to build sourceview depend for gtk2hs? In-Reply-To: <87zlg2i8a7.fsf@debian.domain> References: <87zlg2i8a7.fsf@debian.domain> Message-ID: <1DC77D21-4BF9-4857-B4D8-D212BF4D843E@ece.cmu.edu> On Mar 3, 2009, at 16:52 , Andy Stewart wrote: > * sourceview : no > * gtksourceview2 : yes I'm pretty sure you can have only one or the other, not both; as such you want gtksourceview2 if you have 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 lazycat.manatee at gmail.com Tue Mar 3 17:04:50 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue Mar 3 16:53:53 2009 Subject: [Haskell-cafe] Re: How to build sourceview depend for gtk2hs? References: <87zlg2i8a7.fsf@debian.domain> <1DC77D21-4BF9-4857-B4D8-D212BF4D843E@ece.cmu.edu> Message-ID: <87vdqqi7p9.fsf@debian.domain> "Brandon S. Allbery KF8NH" writes: > On Mar 3, 2009, at 16:52 , Andy Stewart wrote: >> * sourceview : no >> * gtksourceview2 : yes > > > I'm pretty sure you can have only one or the other, not both; as such you want gtksourceview2 if you > have both. So i can use SourceView if i have config pass "sourceview" or "gtksourceview2"? Can you explain the difference between "sourceview" and "gtksourceview2"? Thank you very much! -- Andy From allbery at ece.cmu.edu Tue Mar 3 17:14:17 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Mar 3 17:02:58 2009 Subject: [Haskell-cafe] Re: How to build sourceview depend for gtk2hs? In-Reply-To: <87vdqqi7p9.fsf@debian.domain> References: <87zlg2i8a7.fsf@debian.domain> <1DC77D21-4BF9-4857-B4D8-D212BF4D843E@ece.cmu.edu> <87vdqqi7p9.fsf@debian.domain> Message-ID: On Mar 3, 2009, at 17:04 , Andy Stewart wrote: > "Brandon S. Allbery KF8NH" writes: >> On Mar 3, 2009, at 16:52 , Andy Stewart wrote: >>> * sourceview : no >>> * gtksourceview2 : yes >> >> >> I'm pretty sure you can have only one or the other, not both; as >> such you want gtksourceview2 if you >> have both. > So i can use SourceView if i have config pass "sourceview" or > "gtksourceview2"? > Can you explain the difference between "sourceview" and > "gtksourceview2"? gtksourceview2 is a newer version (2.x vs. 1.x), They're not 100% compatible (API changes) so you have to pick one when building Gtk2hs; if they were independent packages as with the C versions it would be possible to build both and pick one when building an application. -- 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 pbeadling at mail2web.com Tue Mar 3 17:28:13 2009 From: pbeadling at mail2web.com (Phil) Date: Tue Mar 3 17:17:37 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: <200903030036.06758.daniel.is.fischer@web.de> Message-ID: I've had a look at your example - it's raised yet more questions in my mind! On 02/03/2009 23:36, "Daniel Fischer" wrote: > A stupid example: > ---------------------------------------------------------------------- > module UhOh where > > import Control.Monad > import Control.Monad.State.Lazy > --import Control.Monad.State.Strict > > > uhOh :: State s () > uhOh = State $ \_ -> undefined > > uhOhT :: Monad m => StateT s m () > uhOhT = StateT $ \_ -> return undefined > > uhOhT2 :: Monad m => StateT s m () > uhOhT2 = StateT $ \_ -> undefined > > oy :: State s () > oy = State $ \_ -> ((),undefined) > > oyT :: Monad m => StateT s m () > oyT = StateT $ \_ -> return ((),undefined) > > hum :: State Int Int > hum = do > k <- get > w <- uhOh > put (k+2) > return w > return (k+1) > > humT :: Monad m => StateT Int m Int > humT = do > k <- get > w <- uhOhT > put (k+2) > return w > return (k+1) > > > humT2 :: Monad m => StateT Int m Int > humT2 = do > k <- get > w <- uhOhT2 > put (k+2) > return w > return (k+1) > > > whoa n = runState (replicateM_ n hum >> hum) 1 > > whoaT n = runStateT (replicateM_ n humT >> humT) 1 > > whoaT2 n = runStateT (replicateM_ n humT2 >> humT2) 1 > > yum :: State Int Int > yum = do > k <- get > w <- oy > put (k+2) > return w > return (k+1) > > yumT :: Monad m => StateT Int m Int > yumT = do > k <- get > w <- oyT > put (k+2) > return w > return (k+1) > > hoha n = runState (replicateM_ n yum >> yum) 1 > > hohaT n = runStateT (replicateM_ n yumT >> yumT) 1 > > oops m = runState m 1 > ---------------------------------------------------------------------- > > What happens with > > whoa 10 > hoha 10 > oops (whoaT 10) > oops (whoaT2 10) > oops (hohaT 10) > > respectively when the Lazy or Strict library is imported? > Answer first, then test whether you were right. OK, I had a think about this - I'm not 100% clear but: UhOh - OK for lazy, Bad for Strict. "undefined" 'could' be of the form (a,s) so the lazy accepts it, but the strict version tries to produce (a,s) out of undefined and fails. Oy - Both are OK here. The pair form is retained and neither will go as far as to analyse the contents of either element of the pair, as neither is used. UhOhT - OK for lazy, Bad for Strict. Same as Oh UhOh, but as we have transformer we return inside a Monad. UhOhT2 - Bad for both - transformers should return a Monad. OyT - Same as Oy, but returned inside a monad. The thing which confuses me is why we care about these functions at all hum, yum, etc. Although these inspect the State Monads above they stick the values in to 'w' which is never used (I think), because the first return statement just produces "M w" which is not returned because of the return (k+1) afterwards?? Because lazy and strict are only separated by the laziness on the bind between contiguous hum and yum states, I would have thought that laziness on w would have been the same on both. Hmmm. But I suppose each call to hum and yum is increment stating in it's corresponding UhOh and Oy function. Thus causing these to be strictly evaluated one level deeper.... In which case I do understand. We have: hum >> hum >> hum ..... And At each stage we are also doing UhOh >> UhOh >> UhOh inside the hums? Is this right, I'm not so sure? I'm in danger of going a bit cross-eyed here! > >> This means that each new (value,state) is just passed around as a thunk and >> not even evaluated to the point where a pair is constructed - it's just a >> blob, and could be anything as far as haskell is concerned. > > Not quite anything, it must have the correct type, but whether it's > _|_, (_|_,_|_), (a,_|_), (_|_,s) or (a,s) (where a and s denote non-_|_ > elements of the respective types), the (>>=) doesn't care. Whether any > evaluation occurs is up to (>>=)'s arguments. > By correct type you mean that it must *feasibly* be a pair... But the lazy pattern matching doesn't verify that it *is* a pair. Thus if we returned something that could never be a pair, it will fail to compile, but if it is of the form X or (X,X) it won't check any further than that, but if it was say [X] that wouldn't work even for lazy - haskell doesn't trust us that much!? >> It follows that each new state cannot evaluated even if we make newStockSum >> strict as (by adding a bang) because the state tuple newStockSum is wrapped >> in is completely unevaluated - so even if newStockSum is evaluated INSIDE >> this blob, haskell will still keep the whole chain. > > Well, even with the bang, newStockSum will only be evaluated if somebody looks > at what mc delivers. In the Strict case, (>>=) does, so newStockSum is > evaluated at each step. When you say 'looks' at it do you mean it is the final print state on the result that ultimately causes the newStockSum to be evaluated in the lazy version? Thus we are saying we evaluate it only because we know it is needed. However in the strict case, the fact that newStockSum is used to evaluate the NEXT newStockSum in the subsequent state (called via the bind) is enough to force evaluation, even if the result of the subsequent state is not used? > In the Lazy case, (>>=) doesn't, replicateM_ doesn't, > so newStockSum won't be evaluated inside the blob, if it were, it would force > the evaluation of the previous pair and almost everything else, then there > would have been no problem. What the bang does in the lazy case is to keep > the thunk for the evaluation of the states a little smaller and simpler, so > the evaluation is a bit faster and uses less memory, but not much (further > strictness elsewhere helps, too, as you've investigated). > So in the lazy state the bang will evaluate things that are local to THIS state calculation, but it won't force evaluation of previous states. Thus expression remaining could be simplified as far as possible without requiring the previous MonteCarlo state or the previous BoxMuller state. From dave at zednenem.com Tue Mar 3 18:20:53 2009 From: dave at zednenem.com (David Menendez) Date: Tue Mar 3 18:09:35 2009 Subject: [Haskell-cafe] monadic MapReduce In-Reply-To: <20090302235744.GA22350@amuttreja-dt> References: <49AAD334.9090202@libero.it> <20090301185817.GE15163@raven> <49ABF6F1.60903@libero.it> <20090302235744.GA22350@amuttreja-dt> Message-ID: <49a77b7a0903031520i67c74213sfd0f474b1f2a6d01@mail.gmail.com> On Mon, Mar 2, 2009 at 6:57 PM, Anish Muttreja wrote: > How about this. Is there a reason why I can't > replace the variables b and c in the type signature of mapReduce with with (IO b') > and (IO c'). b and c ?can be any types. > > mapReduce :: Strategy (IO b') ? ?-- evaluation strategy for mapping > ? ? ? ? ? -> (a -> IO b') ? ? ?-- map function > ? ? ? ? ? -> Strategy (IO c') ? ?-- evaluation strategy for reduction > ? ? ? ? ? -> ([IO b'] -> (IO c')) ? ?-- reduce function > ? ? ? ? ? -> [a] ? ? ? ? ? -- list to map over > ? ? ? ? ? -> (IO c') > > Just remember to wrap all values back in the IO monad. This is possible, but it probably won't do what you want. The input to the reduce function will be a list of "IO a" values, not the results of performing the IO. -- Dave Menendez From bugfact at gmail.com Tue Mar 3 18:27:14 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Mar 3 18:15:53 2009 Subject: [Haskell-cafe] Theory about uncurried functions In-Reply-To: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> References: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> Message-ID: Thank you all for this information. It was very enlightening. Too bad I don't know category theory, since I think it would give me a better view on the different forms and essence of "computing". Maybe this raises a new question: does understanding category theory makes you a better *programmer*? On Tue, Mar 3, 2009 at 8:45 PM, Hans Aberg wrote: > On 3 Mar 2009, at 10:43, Peter Verswyvelen wrote: > >> Lambda calculus is a nice theory in which every function always has >> one input and one output. Functions with multiple arguments can be >> simulated because functions are first class and hence a function can >> "return" a function. Multiple outputs cannot be done, one must embed >> these outputs in some data type, e.g. using a tuple, or one must use >> continuation passing style. >> >> Now, does a similar theory exist of functions that always have one >> input and one output, but these inputs and outputs are *always* >> tuples? Or maybe this does not make any sense? > > I think most of the replies have already described it, but the Church's > lambda-calculus is just a minimal theory describing a way to construct > functions, which turns out to be quite general, including all algorithms. > The first lambda-calculus he describes in his book does not even include the > constant functions - for some reason it is convenient. > > So if you want to have more, just add it. That is why functional computer > languages like Haskell can exist. > > As for currying, it builds on the fact that in the category of sets (but > others may not have it) one has a natural equivalence (arguments can also be > functions) > ? ? ?psi: Hom(A x B, C) --> Hom(A, Hom(B, C)) > ? ? ? ? ? ? ? ? f ? ? ? |-> (a |-> (b |-> f(a, b))) > ? ?((a, b) |-> g(a)(b)) <-| ? ? ?g > So it simply means that set-theoretic products can be rewritten into > iterated functions. (Strictly speaking, currying involves a choice of > natural equivalence psi.) > > In axiomatic set theory, it is common to construct tuplets (i.e., > set-theoretic products) so that (x) = x, (x_1, ..., x_n) = ((x_1, ..., > x_(n-1), x_n), and one might set () to the empty set (so that, for example, > the real R ?^0 has only one point). The recursive formula has slipped into > functional languages. Pure math, unless there are special requirements, uses > naive set theory in which that recursion formula would not be used: in > computer lingo, it corresponds to the implementation (axiomatic set theory), > and is not part of the interface (naive set theory). > > By contrast, in lists, [x] is not the same as x. (If S is a set, the set of > lists with elements from S is the free monoid on S.) > > But you might view f() as passing the object () to f, f(x) passes x to f, > and f(x_1, ..., x_n) passes (x_1, ..., x_n) to f. > > So the only addition needed is to add the objects (x_1, ..., x_n), n = 0, 1, > 2, ..., to your language. You can still curry the functions if you like to - > a convention, just as already noted. > > ?Hans Aberg > > > From claus.reinke at talk21.com Tue Mar 3 18:29:17 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Mar 3 18:18:02 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 References: <49AC840C.7060604@libero.it><1236079848.22402.82.camel@localhost><49AD200D.5060102@libero.it><7DD8072CCCD84A96B408871A394A42D8@cr3lt><49AD4035.6010009@libero.it><3DBD09D6D09F4936AB63F37257E8EC9A@cr3lt> <49AD66EF.7060601@libero.it> Message-ID: >> That helps to make things clearer, I think. One issue is >> the nature of Maps (strict in keys, non-strict in values). >> >> - neither singleton nor unionWith are strict in the Map values, so >> nothing here forces the evaluation of rate or construction of UArr >> > But, as I have written, in one of my tests I also tried rnf to force > evaluation: > rnf v `seq` rnf m `seq` return m > Isn't this sufficient? It will force the Map that results from the repeated unioning, but does not ensure that this is done in an efficient way. >> A standard trick to keep Map values evaluated by construction >> is to make the availability of keys dependent on their values, eg >> (singleton key) $! value. That won't help with unionWith and >> the appendUs, but it should allow the source string references >> to be dropped early, as the singletons are constructed. > > Tried; but, even using union instead of unionWith, the memory > grows fast as before. Strange. I built myself a small wrapper to make your code fragment compilable, and just replacing (unionWith appendU) with (union) makes a drastic difference - as it should. It is rather annoying that Data.IntMap doesn't provide a strict form of unionWith or insertWith (Data.Map does at least provide insertWith'). But we can define our own, at the cost of an extra lookup. We can then foldl' that insertWith' directly over the ratings list, bypassing the non-strict parts of the Data.IntMap API (see code below). Claus (who still thinks that all Maps should be parameterized over their key-value pair type constructor, so that the default non-strict Maps would result from using non-strict pairs type IntMap = IntMapP (,) while the often desired element-strict Maps would result from using strict pairs, with no other change in API type IntMapStrict = IntMapP (:*:) ) ------------------------------------------------------- {-# LANGUAGE TypeOperators #-} import qualified Data.ByteString.Lazy as L import Data.Array.Vector import qualified Data.IntMap as IM import Data.List import Data.Word import qualified Data.ByteString.Lazy.Char8 as L8 import Data.Maybe import System.IO -- don't use this for real, test wrapper only ratings :: L.ByteString -> [(Word32,Word8)] ratings = map (\[i,r]->(fromIntegral $ fst $ fromJust $ L8.readInt i ,fromIntegral $ fst $ fromJust $ L8.readInt r)) . map L8.words . L8.lines parse handle = do contents <- L.hGetContents handle let v = map singleton' $ ratings contents let m = foldl' (\m (kw,v)->insertWith' appendU (fromIntegral kw,v) m) IM.empty v -- let m = foldl1' (IM.unionWith appendU) v -- let m = foldl1' (IM.union) v return $! m where -- Build a Map with a single movie rating singleton' :: (Word32, Word8) -> (Int,UArr Rating) singleton' (id, rate) = ((fromIntegral $ id), (singletonU $ pairS (id, rate))) -- (IM.singleton (fromIntegral $ id)) $ (singletonU $ pairS (id, rate)) insertWith' op (k,v) m = maybe (IM.insert k v m) (\old->((IM.insert k) $! (v `op` old)) m) (IM.lookup k m) type Rating = Word32 :*: Word8 type MovieRatings = IM.IntMap (UArr Rating) -- UArr from uvector -- more test wrapper, some trivial input data generate = withFile "in.data" WriteMode $ \h-> mapM_ (\(i,r)->hPutStrLn h $ show i++" "++show r) $ take 1000000 $ cycle [(i,i)|i<-[0..100]] main = withFile "in.data" ReadMode parse >>= print From schlepptop at henning-thielemann.de Tue Mar 3 19:18:04 2009 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Tue Mar 3 18:58:21 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <5660FA1A-E8D9-441E-B490-AB6C2C9AB7FD@n-brain.net> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <9979e72e0903020403s7e90582br5b0fbca58acebe8f@mail.gmail.com> <5660FA1A-E8D9-441E-B490-AB6C2C9AB7FD@n-brain.net> Message-ID: <49ADC8BC.10101@henning-thielemann.de> John A. De Goes schrieb: > Elsewhere, laziness can be a real boon, so I don't understand your > question, "Why have laziness in Haskell at all?" As I have written, many libaries process their data lazily (or could be changed to do so without altering their interface) but their interface can forbid application to data that is fetched from the outside world. Say you are used to 'map', 'filter', 'foldr' - you cannot use them on data fetched by the iteratee/enumerator approach. Actually, Lazy I/O and exceptions can work together if you drop the exceptions that are baked into IO monad and use explicit exceptions (synchronous and asynchronous ones) as I develop them in the explicit-exception package. I'm however still searching for a good set of combinators. From lemming at henning-thielemann.de Tue Mar 3 19:31:44 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Mar 3 19:20:24 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: <3841DD8D-86FE-466C-B5A9-3E2651C3F886@ece.cmu.edu> References: <20090303041311.GL27223@knuth.cs.hmc.edu> <3841DD8D-86FE-466C-B5A9-3E2651C3F886@ece.cmu.edu> Message-ID: On Tue, 3 Mar 2009, Brandon S. Allbery KF8NH wrote: > On 2009 Mar 2, at 23:13, Andrew Hunter wrote: >> a) Hide Prelude.(<) and define a simple < that builds the AST term I want. >> b) Come up with a new symbol for it that doesn't look totally awful. > > I guess aesthetics differ; I'd use e.g. $<$, where the $ (to me, from other > contexts) means "symbolic". ... like escaping '<' in LaTeX. Funny! From westondan at imageworks.com Tue Mar 3 19:34:00 2009 From: westondan at imageworks.com (Dan Weston) Date: Tue Mar 3 19:22:44 2009 Subject: [Haskell-cafe] Theory about uncurried functions In-Reply-To: References: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> Message-ID: <49ADCC78.4060408@imageworks.com> Not a better programmer, just a better human being. Peter Verswyvelen wrote: > Thank you all for this information. It was very enlightening. > > Too bad I don't know category theory, since I think it would give me a > better view on the different forms and essence of "computing". > > Maybe this raises a new question: does understanding category theory > makes you a better *programmer*? From lemming at henning-thielemann.de Tue Mar 3 19:35:38 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Mar 3 19:24:19 2009 Subject: [Haskell-cafe] Theory about uncurried functions In-Reply-To: References: Message-ID: On Tue, 3 Mar 2009, Peter Verswyvelen wrote: > Now, does a similar theory exist of functions that always have one > input and one output, but these inputs and outputs are *always* > tuples? Or maybe this does not make any sense? I don't think one can forbid currying. It's just a question, whether people use it commonly or not. But that was already said in this thread. Somehow related: http://haskell.org/haskellwiki/Composing_functions_with_multiple_values From jonathanccast at fastmail.fm Tue Mar 3 19:37:57 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Tue Mar 3 19:31:03 2009 Subject: [Haskell-cafe] Theory about uncurried functions In-Reply-To: References: Message-ID: <1236127077.22686.10.camel@jcchost> On Wed, 2009-03-04 at 01:35 +0100, Henning Thielemann wrote: > On Tue, 3 Mar 2009, Peter Verswyvelen wrote: > > > Now, does a similar theory exist of functions that always have one > > input and one output, but these inputs and outputs are *always* > > tuples? Or maybe this does not make any sense? > > I don't think one can forbid currying. Sure you can, just work in a category with finite products (and possibly finite co-products) but not exponentials. Of course, then your language is first order --- and this doesn't do anything to stop partial application, which is still easy --- but it's quite possible. jcc From tobsan at gmail.com Tue Mar 3 19:44:04 2009 From: tobsan at gmail.com (Tobias Olausson) Date: Tue Mar 3 19:32:44 2009 Subject: [Haskell-cafe] Memory usage when passing arrays in state Message-ID: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> Hello all. I am currently implementing an emulation of a CPU, in which the CPU's RAM is part of the internal state that is passed around in the program using a state monad. However, the program performs unexpectingly bad, and some profiling information makes us believe that the problem is the high memory usage of the program. The program below is similar to our main program used when testing a sorting algorithm in this CPU: module Main where import Control.Monad.State.Lazy import Data.Word import Data.Array.Diff import Control.Concurrent (threadDelay) data LoopState = LoopState { intVal :: Integer , diff :: DiffUArray Word8 Word8 } initState :: LoopState initState = LoopState 0 (array (0x00,0xFF) [(idx,0)|idx<-[0x00..0xFF]]) main :: IO () main = do execStateT looper initState >>= putStrLn . show . intVal looper :: StateT LoopState IO () looper = do st <- get let res = intVal st + 1 idx = fromIntegral res put $ st { intVal = res, diff = (diff st) // [(idx,idx)] } if res == 13000000 then return () else looper Of course our program does more than updating a counter ;-) Compiling and running this program yields the following result: [~]:[olaussot] >> ghc --make -O2 -o array ArrayPlay.hs [~]:[olaussot] >> ./array +RTS -sstderr ./array +RTS -sstderr 13000000 313,219,740 bytes allocated in the heap 1,009,986,984 bytes copied during GC 200,014,828 bytes maximum residency (8 sample(s)) 4,946,648 bytes maximum slop 393 MB total memory in use (3 MB lost due to fragmentation) Generation 0: 590 collections, 0 parallel, 3.06s, 3.09s elapsed Generation 1: 8 collections, 0 parallel, 3.56s, 4.21s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 0.27s ( 0.27s elapsed) GC time 6.62s ( 7.30s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 6.89s ( 7.57s elapsed) %GC time 96.1% (96.4% elapsed) Alloc rate 1,155,958,754 bytes per MUT second Productivity 3.9% of total user, 3.6% of total elapsed Why does the program spend 96.1% of its total running time collecting garbage? Any tips to make this program perform better are appreciated. Please do tell if anything is unclear. -- Tobias Olausson tobsan@gmail.com From bugfact at gmail.com Tue Mar 3 19:57:04 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Mar 3 19:45:43 2009 Subject: [Haskell-cafe] OpenVG: Linker errors with ghc --make, but not with ghci? Message-ID: I followed the instructions on how to build OpenVG on Windows. It works fine when I run the examples using "GHCi -lopenvg32", but when compiling it with "GHC --make -lopenvg32" I get a bunch of linker errors, like C:\Program Files\Haskell\OpenVG-0.1\ghc-6.10.1/libHSOpenVG-0.1.a(Paths.o):fake:(.text+0x82): undefined reference to `vgInterpolatePath' C:\Program Files\Haskell\OpenVG-0.1\ghc-6.10.1/libHSOpenVG-0.1.a(Paths.o):fake:(.text+0x40d): undefined reference to `vgModifyPathCoords' etc However it does seem that the libopenvg32.a file contains all these undefined references, and it is in the gcc-lib directory of GHC. I'm a stuck. Any hints? Thanks, Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090304/39276156/attachment.htm From twd2 at dockerz.net Tue Mar 3 20:00:21 2009 From: twd2 at dockerz.net (Tim Docker) Date: Tue Mar 3 19:49:00 2009 Subject: [Haskell-cafe] Difficulties in accessing inner elements of data types In-Reply-To: <200903032057.57448.davidmiani@gmail.com> References: <200903032057.57448.davidmiani@gmail.com> Message-ID: <33884.203.185.215.144.1236128421.squirrel@dockerz.net> > While writing an OrgFile is fairly easy, reading (and > accessing inner parts) of an org file is very tedious, > and modifying them is horrendous. Have you looked at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor It's something I've used successfully when wanting to manipulate the internals of complex types. Tim From pumpkingod at gmail.com Tue Mar 3 20:15:28 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue Mar 3 20:04:07 2009 Subject: [Haskell-cafe] Memory usage when passing arrays in state In-Reply-To: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> References: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> Message-ID: This may be completely unrelated to your problem, but there's a ticket in the GHC trac saying that DiffArray is unusably slow: http://hackage.haskell.org/trac/ghc/ticket/2727 . It doesn't analyze the cause of the slowness, so it's quite possible that it may be related to GC as in your case. Cheers, Dan On Tue, Mar 3, 2009 at 7:44 PM, Tobias Olausson wrote: > Hello all. > I am currently implementing an emulation of a CPU, in which the CPU's > RAM is part of the internal state > that is passed around in the program using a state monad. However, the > program performs > unexpectingly bad, and some profiling information makes us believe > that the problem is the high > memory usage of the program. > > The program below is similar to our main program used when testing a > sorting algorithm in this CPU: > > module Main where > > import Control.Monad.State.Lazy > import Data.Word > import Data.Array.Diff > import Control.Concurrent (threadDelay) > > data LoopState = LoopState > ? ?{ intVal :: Integer > ? ?, diff ? :: DiffUArray Word8 Word8 > ? ?} > > initState :: LoopState > initState = LoopState 0 (array (0x00,0xFF) [(idx,0)|idx<-[0x00..0xFF]]) > > main :: IO () > main = do > ? ?execStateT looper initState >>= putStrLn . show . intVal > > looper :: StateT LoopState IO () > looper = do > ? ?st <- get > ? ?let res = intVal st + 1 > ? ? ? ?idx = fromIntegral res > ? ?put $ st { intVal = res, diff = (diff st) // [(idx,idx)] } > ? ?if res == 13000000 > ? ? ? ?then return () > ? ? ? ?else looper > > Of course our program does more than updating a counter ;-) > Compiling and running this program yields the following result: > > [~]:[olaussot] >> ghc --make -O2 -o array ArrayPlay.hs > [~]:[olaussot] >> ./array +RTS -sstderr > ./array +RTS -sstderr > 13000000 > ? ? 313,219,740 bytes allocated in the heap > ? 1,009,986,984 bytes copied during GC > ? ? 200,014,828 bytes maximum residency (8 sample(s)) > ? ? ? 4,946,648 bytes maximum slop > ? ? ? ? ? ? 393 MB total memory in use (3 MB lost due to fragmentation) > > ?Generation 0: ? 590 collections, ? ? 0 parallel, ?3.06s, ?3.09s elapsed > ?Generation 1: ? ? 8 collections, ? ? 0 parallel, ?3.56s, ?4.21s elapsed > > ?INIT ?time ? ?0.00s ?( ?0.00s elapsed) > ?MUT ? time ? ?0.27s ?( ?0.27s elapsed) > ?GC ? ?time ? ?6.62s ?( ?7.30s elapsed) > ?EXIT ?time ? ?0.00s ?( ?0.00s elapsed) > ?Total time ? ?6.89s ?( ?7.57s elapsed) > > ?%GC time ? ? ?96.1% ?(96.4% elapsed) > > ?Alloc rate ? ?1,155,958,754 bytes per MUT second > > ?Productivity ? 3.9% of total user, 3.6% of total elapsed > > Why does the program spend 96.1% of its total running time collecting garbage? > Any tips to make this program perform better are appreciated. > Please do tell if anything is unclear. > > -- > Tobias Olausson > tobsan@gmail.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tobsan at gmail.com Tue Mar 3 20:30:34 2009 From: tobsan at gmail.com (Tobias Olausson) Date: Tue Mar 3 20:19:13 2009 Subject: [Haskell-cafe] Memory usage when passing arrays in state In-Reply-To: References: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> Message-ID: <65c9dbea0903031730n614b42aar162b7a7b564cd5a8@mail.gmail.com> Thank you Daniel. As I understood it DiffArrays are supposed to be faster than the regular Array due to the fact that it doesnt copy the entire Array, but just updates the position that changes, and keeps some kind of "changelog" on the array. But when looking at the statistics for my sample program, it seems that it allocates a lot more than what should be needed, which would indicate that maybe the array is copied anyway. At this point, the DiffArray/DiffUArray are the only functional arrays, right? I mean, I can add two and two together and see that it equals...four, and if the only functional array is sort of broken, that means so is my program. Are there any alternatives that are fast aswell? //Tobias 2009/3/4 Daniel Peebles : > This may be completely unrelated to your problem, but there's a ticket > in the GHC trac saying that DiffArray is unusably slow: > http://hackage.haskell.org/trac/ghc/ticket/2727 . It doesn't analyze > the cause of the slowness, so it's quite possible that it may be > related to GC as in your case. > > Cheers, > Dan > > On Tue, Mar 3, 2009 at 7:44 PM, Tobias Olausson wrote: >> Hello all. >> I am currently implementing an emulation of a CPU, in which the CPU's >> RAM is part of the internal state >> that is passed around in the program using a state monad. However, the >> program performs >> unexpectingly bad, and some profiling information makes us believe >> that the problem is the high >> memory usage of the program. >> >> The program below is similar to our main program used when testing a >> sorting algorithm in this CPU: >> >> module Main where >> >> import Control.Monad.State.Lazy >> import Data.Word >> import Data.Array.Diff >> import Control.Concurrent (threadDelay) >> >> data LoopState = LoopState >> ? ?{ intVal :: Integer >> ? ?, diff ? :: DiffUArray Word8 Word8 >> ? ?} >> >> initState :: LoopState >> initState = LoopState 0 (array (0x00,0xFF) [(idx,0)|idx<-[0x00..0xFF]]) >> >> main :: IO () >> main = do >> ? ?execStateT looper initState >>= putStrLn . show . intVal >> >> looper :: StateT LoopState IO () >> looper = do >> ? ?st <- get >> ? ?let res = intVal st + 1 >> ? ? ? ?idx = fromIntegral res >> ? ?put $ st { intVal = res, diff = (diff st) // [(idx,idx)] } >> ? ?if res == 13000000 >> ? ? ? ?then return () >> ? ? ? ?else looper >> >> Of course our program does more than updating a counter ;-) >> Compiling and running this program yields the following result: >> >> [~]:[olaussot] >> ghc --make -O2 -o array ArrayPlay.hs >> [~]:[olaussot] >> ./array +RTS -sstderr >> ./array +RTS -sstderr >> 13000000 >> ? ? 313,219,740 bytes allocated in the heap >> ? 1,009,986,984 bytes copied during GC >> ? ? 200,014,828 bytes maximum residency (8 sample(s)) >> ? ? ? 4,946,648 bytes maximum slop >> ? ? ? ? ? ? 393 MB total memory in use (3 MB lost due to fragmentation) >> >> ?Generation 0: ? 590 collections, ? ? 0 parallel, ?3.06s, ?3.09s elapsed >> ?Generation 1: ? ? 8 collections, ? ? 0 parallel, ?3.56s, ?4.21s elapsed >> >> ?INIT ?time ? ?0.00s ?( ?0.00s elapsed) >> ?MUT ? time ? ?0.27s ?( ?0.27s elapsed) >> ?GC ? ?time ? ?6.62s ?( ?7.30s elapsed) >> ?EXIT ?time ? ?0.00s ?( ?0.00s elapsed) >> ?Total time ? ?6.89s ?( ?7.57s elapsed) >> >> ?%GC time ? ? ?96.1% ?(96.4% elapsed) >> >> ?Alloc rate ? ?1,155,958,754 bytes per MUT second >> >> ?Productivity ? 3.9% of total user, 3.6% of total elapsed >> >> Why does the program spend 96.1% of its total running time collecting garbage? >> Any tips to make this program perform better are appreciated. >> Please do tell if anything is unclear. >> >> -- >> Tobias Olausson >> tobsan@gmail.com >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > -- Tobias Olausson tobsan@gmail.com From daniel.is.fischer at web.de Tue Mar 3 20:38:56 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Mar 3 20:27:36 2009 Subject: [Haskell-cafe] Memory usage when passing arrays in state In-Reply-To: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> References: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> Message-ID: <200903040238.56198.daniel.is.fischer@web.de> Am Mittwoch, 4. M?rz 2009 01:44 schrieb Tobias Olausson: > Hello all. > I am currently implementing an emulation of a CPU, in which the CPU's > RAM is part of the internal state > that is passed around in the program using a state monad. However, the > program performs > unexpectingly bad, and some profiling information makes us believe > that the problem is the high > memory usage of the program. > > The program below is similar to our main program used when testing a > sorting algorithm in this CPU: > > module Main where > > import Control.Monad.State.Lazy Not good, use Control.Monad.State.Strict > import Data.Word > import Data.Array.Diff > import Control.Concurrent (threadDelay) > > data LoopState = LoopState > { intVal :: Integer > , diff :: DiffUArray Word8 Word8 Diff(U)Arrays tend to be slow, use them with care. > } > > initState :: LoopState > initState = LoopState 0 (array (0x00,0xFF) [(idx,0)|idx<-[0x00..0xFF]]) > > main :: IO () > main = do > execStateT looper initState >>= putStrLn . show . intVal > > looper :: StateT LoopState IO () > looper = do > st <- get > let res = intVal st + 1 > idx = fromIntegral res > put $ st { intVal = res, diff = (diff st) // [(idx,idx)] } > if res == 13000000 > then return () > else looper You're being too lazy, building a huge thunk that only gets evaluated at the end of the loop. You have to force evaluation earlier. > > Of course our program does more than updating a counter ;-) > Compiling and running this program yields the following result: > > [~]:[olaussot] >> ghc --make -O2 -o array ArrayPlay.hs > [~]:[olaussot] >> ./array +RTS -sstderr > ./array +RTS -sstderr > 13000000 > 313,219,740 bytes allocated in the heap > 1,009,986,984 bytes copied during GC > 200,014,828 bytes maximum residency (8 sample(s)) > 4,946,648 bytes maximum slop > 393 MB total memory in use (3 MB lost due to fragmentation) > > Generation 0: 590 collections, 0 parallel, 3.06s, 3.09s elapsed > Generation 1: 8 collections, 0 parallel, 3.56s, 4.21s elapsed > > INIT time 0.00s ( 0.00s elapsed) > MUT time 0.27s ( 0.27s elapsed) > GC time 6.62s ( 7.30s elapsed) > EXIT time 0.00s ( 0.00s elapsed) > Total time 6.89s ( 7.57s elapsed) > > %GC time 96.1% (96.4% elapsed) > > Alloc rate 1,155,958,754 bytes per MUT second > > Productivity 3.9% of total user, 3.6% of total elapsed > > Why does the program spend 96.1% of its total running time collecting > garbage? Any tips to make this program perform better are appreciated. > Please do tell if anything is unclear. Nothing gets evaluated until the end, so nothing can be discarded earlier. ---------------------------------------------------------------------- {-# LANGUAGE BangPatterns #-} module Main where import Control.Monad.State.Strict import Data.Word import Data.Array.Unboxed import Data.Array.ST import Data.Array.MArray update :: UArray Word8 Word8 -> Word8 -> Word8 -> UArray Word8 Word8 update arr i v = runSTUArray $ do sar <- unsafeThaw arr writeArray sar i v return sar data LoopState = LoopState { intVal :: !Integer , diff :: !(UArray Word8 Word8) } initState :: LoopState initState = LoopState 0 (array (0x00,0xFF) [(idx,0)|idx<-[0x00 .. 0xFF]]) main :: IO () main = do execStateT looper initState >>= putStrLn . show . intVal looper :: StateT LoopState IO () looper = do LoopState i df <- get let res = i + 1 idx = fromIntegral res !ndf = update df idx idx put (LoopState res ndf) if res == 13000000 then return () else looper ---------------------------------------------------------------------- Is much better behaved. I didn't investigate if every strictness annotation is necessary. > > -- > Tobias Olausson > tobsan@gmail.com Cheers, Daniel From wagner.andrew at gmail.com Tue Mar 3 20:44:15 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue Mar 3 20:32:55 2009 Subject: [Haskell-cafe] Difficulties in accessing inner elements of data types In-Reply-To: <33884.203.185.215.144.1236128421.squirrel@dockerz.net> References: <200903032057.57448.davidmiani@gmail.com> <33884.203.185.215.144.1236128421.squirrel@dockerz.net> Message-ID: Seems like Conal's semantic editor combinators could be of interest too, if I'm understanding correctly: http://conal.net/blog/posts/semantic-editor-combinators/ On Tue, Mar 3, 2009 at 8:00 PM, Tim Docker wrote: > > While writing an OrgFile is fairly easy, reading (and > > accessing inner parts) of an org file is very tedious, > > and modifying them is horrendous. > > Have you looked at > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor > > It's something I've used successfully when wanting to > manipulate the internals of complex types. > > Tim > > > _______________________________________________ > 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/20090303/2161a1f9/attachment.htm From ryani.spam at gmail.com Tue Mar 3 20:48:54 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Mar 3 20:37:33 2009 Subject: [Haskell-cafe] Memory usage when passing arrays in state In-Reply-To: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> References: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> Message-ID: <2f9b2d30903031748l96cce12n8d0a171cbd7eafa9@mail.gmail.com> I've found DiffArrays to be way too slow/memory-hogging for real usage. Since you are in IO already (StateT s IO), you'll probably be better off using a mutable array for a data structure. Some things are still best done in the imperative style. You can be a bit safer by using ST as the bottom monad, however, and returning the result as a pure array. This gives you a single copy per "runST". Alternatively, use IntMap instead of arrays if you want a pure data structure with reasonably efficient update/lookup. -- ryan On Tue, Mar 3, 2009 at 4:44 PM, Tobias Olausson wrote: > Hello all. > I am currently implementing an emulation of a CPU, in which the CPU's > RAM is part of the internal state > that is passed around in the program using a state monad. However, the > program performs > unexpectingly bad, and some profiling information makes us believe > that the problem is the high > memory usage of the program. > > The program below is similar to our main program used when testing a > sorting algorithm in this CPU: > > module Main where > > import Control.Monad.State.Lazy > import Data.Word > import Data.Array.Diff > import Control.Concurrent (threadDelay) > > data LoopState = LoopState > ? ?{ intVal :: Integer > ? ?, diff ? :: DiffUArray Word8 Word8 > ? ?} > > initState :: LoopState > initState = LoopState 0 (array (0x00,0xFF) [(idx,0)|idx<-[0x00..0xFF]]) > > main :: IO () > main = do > ? ?execStateT looper initState >>= putStrLn . show . intVal > > looper :: StateT LoopState IO () > looper = do > ? ?st <- get > ? ?let res = intVal st + 1 > ? ? ? ?idx = fromIntegral res > ? ?put $ st { intVal = res, diff = (diff st) // [(idx,idx)] } > ? ?if res == 13000000 > ? ? ? ?then return () > ? ? ? ?else looper > > Of course our program does more than updating a counter ;-) > Compiling and running this program yields the following result: > > [~]:[olaussot] >> ghc --make -O2 -o array ArrayPlay.hs > [~]:[olaussot] >> ./array +RTS -sstderr > ./array +RTS -sstderr > 13000000 > ? ? 313,219,740 bytes allocated in the heap > ? 1,009,986,984 bytes copied during GC > ? ? 200,014,828 bytes maximum residency (8 sample(s)) > ? ? ? 4,946,648 bytes maximum slop > ? ? ? ? ? ? 393 MB total memory in use (3 MB lost due to fragmentation) > > ?Generation 0: ? 590 collections, ? ? 0 parallel, ?3.06s, ?3.09s elapsed > ?Generation 1: ? ? 8 collections, ? ? 0 parallel, ?3.56s, ?4.21s elapsed > > ?INIT ?time ? ?0.00s ?( ?0.00s elapsed) > ?MUT ? time ? ?0.27s ?( ?0.27s elapsed) > ?GC ? ?time ? ?6.62s ?( ?7.30s elapsed) > ?EXIT ?time ? ?0.00s ?( ?0.00s elapsed) > ?Total time ? ?6.89s ?( ?7.57s elapsed) > > ?%GC time ? ? ?96.1% ?(96.4% elapsed) > > ?Alloc rate ? ?1,155,958,754 bytes per MUT second > > ?Productivity ? 3.9% of total user, 3.6% of total elapsed > > Why does the program spend 96.1% of its total running time collecting garbage? > Any tips to make this program perform better are appreciated. > Please do tell if anything is unclear. > > -- > Tobias Olausson > tobsan@gmail.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at web.de Tue Mar 3 20:55:29 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Mar 3 20:44:09 2009 Subject: [Haskell-cafe] Memory usage when passing arrays in state In-Reply-To: <65c9dbea0903031730n614b42aar162b7a7b564cd5a8@mail.gmail.com> References: <65c9dbea0903031644kd3c1a7h15ae50df2f2ae31f@mail.gmail.com> <65c9dbea0903031730n614b42aar162b7a7b564cd5a8@mail.gmail.com> Message-ID: <200903040255.29799.daniel.is.fischer@web.de> Am Mittwoch, 4. M?rz 2009 02:30 schrieb Tobias Olausson: > Thank you Daniel. > As I understood it DiffArrays are supposed to be faster than the regular They may be supposed to be faster, but they aren't. If you want anything resembling speed, use UArrays, STUArrays, or, if your array elements cannot be unboxed, plain Arrays and STArrays, or some other array-package from Hackage (I don't know which are good, though, the above are good enough for me). > Array due to the fact that it doesnt copy the entire Array, but just > updates the position that changes, and keeps some kind of "changelog" on > the array. But when looking at the statistics for my sample program, it > seems that it allocates a lot more than what should be needed, which would > indicate that maybe the array is copied anyway. > At this point, the DiffArray/DiffUArray are the only functional arrays, > right? No. They are probably the most dysfunctional arrays around. > I mean, I can add two and two together and see that it > equals...four, and if the only functional array is sort of broken, that > means so is my program. Are there any alternatives that are fast aswell? > > //Tobias From chak at cse.unsw.edu.au Tue Mar 3 21:58:54 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Tue Mar 3 21:47:39 2009 Subject: [Haskell-cafe] Status of Haskell under OsX In-Reply-To: <9E5D194D-FB2D-4502-8BC5-07545B812CF3@z.odi.ac> References: <49A7938C.4040802@gmail.com> <9E5D194D-FB2D-4502-8BC5-07545B812CF3@z.odi.ac> Message-ID: <15277C9C-AA24-4827-81DB-B886E6D75BB0@cse.unsw.edu.au> Ross Mellgren: > I use this configuration exclusively... it wasn't actually that hard > to set up once I found out that the .pc files are shipped in a > strange directory buried in the frameworks. > > I posted how I got it working back in December: http://sourceforge.net/mailarchive/message.php?msg_name=3E883695-30D3-4CBE-AD14-B08C24D343EF%40z.odi.ac That does work nicely. Thanks for the pointer. I added a paragraph on the Haskell wiki for easy reference: http://www.haskell.org/haskellwiki/Gtk2Hs#Using_the_GTK.2B_OS_X_Framework Manuel > On Mar 2, 2009, at 6:39 PM, Manuel M T Chakravarty wrote: > >> BTW, there is a nice native version of GTK for Mac OS X as a proper >> framework: >> >> http://www.gtk-osx.org/ >> >> Unfortunately, it seems rather difficult to build gtk2hs with the >> GTK+ framework as the framework doesn't support pkg-config and >> gtk2hs knows nothing about Mac frameworks. However, GHC has >> support for frameworks; so, it should be possible to get this to >> work. >> >> Manuel >> >> Arne Dehli Halvorsen: >>> Manuel M T Chakravarty wrote: >>>>> I'm planning to purchase a MacBookPro so I'm wondering how well >>>>> Haskell is supported under this platform. >>>> >>>> At least two of the regular contributors to GHC work on Macs. >>>> That should ensure that Mac OS X is well supported. Installation >>>> is trivial with the Mac OS X installer package: >>>> >>>> http://haskell.org/ghc/download_ghc_6_10_1.html#macosxintel >>> Hi, following on from this point: >>> >>> How does one get gtk2hs running on a mac? >>> >>> I have a MacBook Pro, and I've had ghc installed for some time now. >>> >>> (first in 6.8.2 (packaged), >>> then 6.10.1 (packaged), >>> then 6.8.2 via macports 1.6 >>> then 6.10.1 via macports 1.7) >>> >>> I tried to install gtk2hs via macports, but it didn't work. >>> (0.9.12? on 6.8.2, then on 6.10.1) >>> Is there a recipe one could follow? >>> Can I get the preconditions via macports, and then use cabal to >>> install >>> gtk2hs 0.10? >>> >>> Grateful for assistance, >>> Arne D H >>>> >>>> Manuel >> >> _______________________________________________ >> 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 mle+hs at mega-nerd.com Tue Mar 3 22:07:39 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue Mar 3 21:56:21 2009 Subject: [Haskell-cafe] environment variables for runghc? Message-ID: <20090304140739.c7e09109.mle+hs@mega-nerd.com> Hi all, Is there some environment variable I can set so that runghc can be told to always use -Wall? Cheers, Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "... a discussion of C++'s strengths and flaws always sounds like an argument about whether one should face north or east when one is sacrificing one's goat to the rain god." -- Thant Tessman From gwern0 at gmail.com Tue Mar 3 23:30:24 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Mar 3 23:19:03 2009 Subject: [Haskell-cafe] Data.Binary stack overflow with Data.Sequence String Message-ID: So recently I've been having issues with Data.Binary & Data.Sequence; I serialize a 'Seq String' You can see the file here: http://code.haskell.org/yi/Yi/IReader.hs The relevant function seems to be: -- | Read in database from 'dbLocation' and then parse it into an 'ArticleDB'. readDB :: YiM ArticleDB readDB = io $ (dbLocation >>= r) `catch` (\_ -> return empty) where r x = fmap (decode . BL.fromChunks . return) $ B.readFile x -- We read in with strict bytestrings to guarantee the file is closed, -- and then we convert it to the lazy bytestring data.binary expects. -- This is inefficient, but alas... My current serialized file is about 9.4M. I originally thought that the issue might be the recent upgrade in Yi to binary 0.5, but I unpulled patches back to past that, and the problem still manifested. Whenever yi tries to read the articles.db file, it stack overflows. It actually stack-overflowed on even smaller files, but I managed to bump the size upwards, it seems, by the strict-Bytestring trick. Unfortunately, my personal file has since passed whatever that limit was. I've read carefully the previous threads on Data.Binary and Data.Map stack-overflows, but none of them seem to help; hacking some $!s or seqs into readDB seems to make no difference, and Seq is supposed to be a strict datastructure already! Doing things in GHCi has been tedious, and hasn't enlightened me much: sometimes things overflow and sometimes they don't. It's all very frustrating and I'm seriously considering going back to using the original read/show code unless anyone knows how to fix this - that approach may be many times slower, but I know it will work. -- gwern From alexander.dunlap at gmail.com Wed Mar 4 00:06:41 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Tue Mar 3 23:55:20 2009 Subject: [Haskell-cafe] environment variables for runghc? In-Reply-To: <20090304140739.c7e09109.mle+hs@mega-nerd.com> References: <20090304140739.c7e09109.mle+hs@mega-nerd.com> Message-ID: <57526e770903032106m41ada33dwa2aaf90a50692c56@mail.gmail.com> I doubt there's an env variable, but you could do $ alias ghc='ghc -Wall' Alex On Tue, Mar 3, 2009 at 7:07 PM, Erik de Castro Lopo wrote: > Hi all, > > Is there some environment variable I can set so that runghc can > be told to always use -Wall? > > Cheers, > Erik > -- > ----------------------------------------------------------------- > Erik de Castro Lopo > ----------------------------------------------------------------- > "... a discussion of C++'s strengths and flaws always sounds > like an argument about whether one should face north or east > when one is sacrificing one's goat to the rain god." > -- Thant Tessman > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mle+hs at mega-nerd.com Wed Mar 4 01:50:40 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Mar 4 01:39:22 2009 Subject: [Haskell-cafe] environment variables for runghc? In-Reply-To: <57526e770903032106m41ada33dwa2aaf90a50692c56@mail.gmail.com> References: <20090304140739.c7e09109.mle+hs@mega-nerd.com> <57526e770903032106m41ada33dwa2aaf90a50692c56@mail.gmail.com> Message-ID: <20090304175040.4468b6ca.mle+hs@mega-nerd.com> Alexander Dunlap wrote: > I doubt there's an env variable, but you could do > > $ alias ghc='ghc -Wall' Sorry, doesn't work. I'm pretty sure runghc uses ghc directly and doesn't invoke a user shell to do so. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "If I were on life-support, I'd rather have it run by a Gameboy than a Windows box." -- Cliff Wells in comp.lang.python From haskell at list.mightyreason.com Wed Mar 4 05:08:19 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Wed Mar 4 04:57:13 2009 Subject: [Haskell-cafe] Re: Data.Binary stack overflow with Data.Sequence String In-Reply-To: References: Message-ID: <49AE5313.80700@list.mightyreason.com> I have collected some of the backing code to "decode". This is all pasted below so we can look at it. I will not improperly guess at the cause of the problem, and be totally wrong. I observe Get is a lazy monad: Prelude Data.Binary Data.Binary.Get Data.Monoid> "World" == runGet ((return $! undefined) >> return "World") mempty True Prelude Data.Binary Data.Binary.Get Data.Monoid> 'W' == head (runGet ((return $! undefined) >>= \t -> return $! ('W':t)) mempty) True Prelude Data.Binary Data.Binary.Get Data.Monoid> "orld" == tail (runGet ((return $! undefined) >>= \h -> return $! (h:"orld")) mempty) True This may have implication for building the "String" from "Char". The get for "Char" uses "return $! char" but this is no good unless the Char is being forced, as the (return $! undefined) above shows. The instance Get [a] inherits the laziness of replicateM which is sequence. The instance (Seq.Seq e) does not force the "x :: String" value. And even if it did it would only force the leading (:) cons cell and not the characters themselves. The instance is strict in what passes for the spine of the Seq, not the contents, and certainly not the deep contents. You might try using "newtype" when deserializing ArticleDB and make a much stricter version of the code. All the relevant code (yi & binary & ghc): > type Article = String > type ArticleDB = Seq Article > > -- | Read in database from 'dbLocation' and then parse it into an 'ArticleDB'. > readDB :: YiM ArticleDB > readDB = io $ (dbLocation >>= r) `catch` (\_ -> return empty) > where r x = fmap (decode . BL.fromChunks . return) $ B.readFile x > -- We read in with strict bytestrings to guarantee the file is closed, > -- and then we convert it to the lazy bytestring data.binary expects. > -- This is inefficient, but alas... > > decode :: Binary a => ByteString -> a > decode = runGet get > > instance (Binary e) => Binary (Seq.Seq e) where > put s = put (Seq.length s) >> Fold.mapM_ put s > get = do n <- get :: Get Int > rep Seq.empty n get > where rep xs 0 _ = return $! xs > rep xs n g = xs `seq` n `seq` do > x <- g > rep (xs Seq.|> x) (n-1) g > > instance Binary Int where > put i = put (fromIntegral i :: Int64) > get = liftM fromIntegral (get :: Get Int64) > > instance Binary Int64 where > put i = put (fromIntegral i :: Word64) > get = liftM fromIntegral (get :: Get Word64) > > instance Binary Word64 where > put = putWord64be > get = getWord64be > > instance Binary a => Binary [a] where > put l = put (length l) >> mapM_ put l > get = do n <- get :: Get Int > replicateM n get > > -- Char is serialised as UTF-8 > instance Binary Char where > put a | c <= 0x7f = put (fromIntegral c :: Word8) > | c <= 0x7ff = do put (0xc0 .|. y) > put (0x80 .|. z) > | c <= 0xffff = do put (0xe0 .|. x) > put (0x80 .|. y) > put (0x80 .|. z) > | c <= 0x10ffff = do put (0xf0 .|. w) > put (0x80 .|. x) > put (0x80 .|. y) > put (0x80 .|. z) > | otherwise = error "Not a valid Unicode code point" > where > c = ord a > z, y, x, w :: Word8 > z = fromIntegral (c .&. 0x3f) > y = fromIntegral (shiftR c 6 .&. 0x3f) > x = fromIntegral (shiftR c 12 .&. 0x3f) > w = fromIntegral (shiftR c 18 .&. 0x7) > > get = do > let getByte = liftM (fromIntegral :: Word8 -> Int) get > shiftL6 = flip shiftL 6 :: Int -> Int > w <- getByte > r <- case () of > _ | w < 0x80 -> return w > | w < 0xe0 -> do > x <- liftM (xor 0x80) getByte > return (x .|. shiftL6 (xor 0xc0 w)) > | w < 0xf0 -> do > x <- liftM (xor 0x80) getByte > y <- liftM (xor 0x80) getByte > return (y .|. shiftL6 (x .|. shiftL6 > (xor 0xe0 w))) > | otherwise -> do > x <- liftM (xor 0x80) getByte > y <- liftM (xor 0x80) getByte > z <- liftM (xor 0x80) getByte > return (z .|. shiftL6 (y .|. shiftL6 > (x .|. shiftL6 (xor 0xf0 w)))) > return $! chr r > > > replicateM :: (Monad m) => Int -> m a -> m [a] > replicateM n x = sequence (replicate n x) > > sequence :: Monad m => [m a] -> m [a] > {-# INLINE sequence #-} > sequence ms = foldr k (return []) ms > where > k m m' = do { x <- m; xs <- m'; return (x:xs) } -- Chris From jwlato at gmail.com Wed Mar 4 05:26:14 2009 From: jwlato at gmail.com (John Lato) Date: Wed Mar 4 05:14:53 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <9979e72e0903020403s7e90582br5b0fbca58acebe8f@mail.gmail.com> Message-ID: <9979e72e0903040226r30727061seb8d1b4327af3348@mail.gmail.com> On Tue, Mar 3, 2009 at 1:03 AM, Henning Thielemann wrote: > > On Mon, 2 Mar 2009, John Lato wrote: > > While I think that the Iteratee pattern has benefits, I suspect that it > can't be combined with regular lazy functions, e.g. of type [a] -> [a]. Say > I have a chain of functions: read a file, parse it into a tag soup, parse > that into an XML tree, transform that tree, format that into a string, write > that to a file, and all of these functions are written in a lazy way, which > is currently considered good style, I can't use them in conjunction with > iteratees. This means, almost all Haskell libraries have to be rewritten or > extended from lazy style to iteratee style. The question for me is then: Why > having laziness in Haskell at all? Or at least, why having laziness by > default, why not having laziness annotation instead of strictness > annotation. > I'm not sure that this is a problem, at least not for all cases. When reading seekable streams, it is possible to have IO on demand provided that all processing take place within the context of the Iteratee (see Oleg's Tiff reader, http://okmij.org/ftp/Haskell/Iteratee/Tiff.hs, and my wave reader, http://inmachina.net/~jwlato/haskell/iteratee/src/Data/Iteratee/Codecs/Wave.hs). Also, since the inner monad can be any monad, not just IO, you should be able to lift processing and computations into an iteratee in a fairly straightforward manner. File enumerators are only provided for IO, but it's fairly easy to create versions for other monads as necessary. I've got one for StateT s IO, for example. Now I do agree that this probably won't work in every case. I would suspect that parsers may have to be rewritten to use iteratees (although I don't know to what extent because I don't work with generic parsers). I'm not sure in what other cases this would also be true. The best way to figure it out would be to have more people using iteratees and reporting their findings. Cheers, John From stephen.tetley at gmail.com Wed Mar 4 06:25:11 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed Mar 4 06:13:52 2009 Subject: [Haskell-cafe] OpenVG: Linker errors with ghc --make, but not with ghci? In-Reply-To: References: Message-ID: <5fdc56d70903040325p18a6ec53g38c917dc683d75e5@mail.gmail.com> Hi Peter Yes this is definitely a problem with the OpenVG package. Although I wrote the package I don't know enough about the minutiae of Windows .dlls to sort this out directly (even though I did write most of the library on a Windows machine). I could try to and write a cabal+makefile build rather than a pure cabal one to follow the example of the OpenGL and GLUT libraries, though I don't know if that would work. With my current OpenGL and GLUT installation[1] on Windows I can only run GL programs from GHCi rather than compile them. Please let me know if you want me to try a cabal+makefile package, though the turnaround might not be quick. Best wishes Stephen [1] installed by following these instructions http://netsuperbrain.com/blog/posts/freeglut-windows-hopengl-hglut/ 2009/3/4 Peter Verswyvelen : > I followed the instructions on how to build OpenVG on Windows. It works fine > when I run the examples using "GHCi -lopenvg32", but when compiling it with > "GHC --make -lopenvg32" I get a bunch of linker errors, like > C:\Program > Files\Haskell\OpenVG-0.1\ghc-6.10.1/libHSOpenVG-0.1.a(Paths.o):fake:(.text+0x82): > undefined reference to `vgInterpolatePath' > C:\Program > Files\Haskell\OpenVG-0.1\ghc-6.10.1/libHSOpenVG-0.1.a(Paths.o):fake:(.text+0x40d): > undefined reference to `vgModifyPathCoords' > etc > However it does seem that the libopenvg32.a file contains all these > undefined references, and it is in the gcc-lib directory of GHC. > I'm a stuck. Any hints? > Thanks, > Peter > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jwlato at gmail.com Wed Mar 4 06:29:22 2009 From: jwlato at gmail.com (John Lato) Date: Wed Mar 4 06:18:00 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? Message-ID: <9979e72e0903040329p4c873a7bp30b011b5b109df5a@mail.gmail.com> > John A. De Goes schrieb: > >> Elsewhere, laziness can be a real boon, so I don't understand your >> question, "Why have laziness in Haskell at all?" > > As I have written, many libaries process their data lazily (or could be > changed to do so without altering their interface) but their interface > can forbid application to data that is fetched from the outside world. > Say you are used to 'map', 'filter', 'foldr' - you cannot use them on > data fetched by the iteratee/enumerator approach. > Thank you for replying to this; it's good to see what features people would like to make iteratees more useful. Where did you get the idea that you can't use 'map'? IterateeGM is a Monad and Functor, so fmap is available for the resultant value. If you want to map over the elements of the stream, use the 'mapStream' function ('map_stream' in Oleg's writings). I never thought about writing a general iteratee fold because that's all iteratees are anyway; it's simple enough to make a foldl. It should be possible to write foldr for seekable resources by enumerating the stream backwards. That certainly wouldn't work for network I/O, unfortunately. Note that this is essentially the approach taken by lazy bytestrings, for example. There are other elements I'd want to address before adding this, however. There are also complications dealing with nested streams. I have some ideas, but the way forward is far from clear. filter should be fairly simple to implement with peek and drop. I'll look into it. Cheers, John From apfelmus at quantentunnel.de Wed Mar 4 06:50:14 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed Mar 4 06:38:03 2009 Subject: [Haskell-cafe] Re: Zippers In-Reply-To: References: Message-ID: Cristiano Paris wrote: > > I'm trying to catch the connection between delimited continuations and > zippers so I wrote a (kinda) zipper interface to a simple tree > structure. Here's the code: > > ------- > module Main where > > import Data.Maybe > > data Tree a = Leaf a | Fork (Tree a) (Tree a) deriving Show > > tree = Fork (Fork (Leaf 1) (Leaf 2)) (Fork (Leaf 3) (Fork (Leaf 4) (Leaf 5))) > > data ZContext a = ZContext { moveUp :: Maybe (ZContext a), > moveLeft :: Maybe (ZContext a), > moveRight :: Maybe (ZContext a), > this :: Maybe a } > > initZ t = doInitZ Nothing t > where > doInitZ c (Leaf a) = ZContext c Nothing Nothing $ Just a > doInitZ c t@(Fork l r) = ZContext c (Just $ doInitZ s l) > (Just $ doInitZ s r) > Nothing > where s = Just $ doInitZ c t > ------- > > You access the tree in the following way (session from ghci): > > *Main> this $ fromJust . moveLeft $ fromJust . moveLeft $ initZ tree > > I read Haskell book's Chapter about Zippers on Wikibooks and I think I > understood the underlying concept even if the implementation still > seems to me a bit arbitrary (i.e. different implementation can be > provided even if the proposed one is neat thinking of > differentiation). > > Hence, I decided to go experimenting myself and came up with the above > solution. I know that the interface to a tree having values only on > leaves is pointless as the main advantage of using a Zipper is to get > O(1) performance on updating but I wanted to keep it as simple as > possible. > > So, can you provide some comments on that implementation? Thank you > all, as usual! The unusual thing about your implementation is probably that you're tying a knot by making both moveUp and moveLeft record fields. This reminds me of Weaving a web. Ralf Hinze and Johan Jeuring. 2001. http://www.informatik.uni-bonn.de/~ralf/publications/TheWeb.ps.gz The problem with knot-tying / sharing is of course that they are tricky to update. What about the crucial function update :: ZContext a -> Maybe a -> ZContext a that changes the data at a leaf? I think that with your current approach, you'd have to regenerate the whole context which pretty much defeats the purpose of a zipper. Regards, apfelmus -- http://apfelmus.nfshost.com From bugfact at gmail.com Wed Mar 4 09:16:33 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Mar 4 09:05:13 2009 Subject: [Haskell-cafe] OpenVG: Linker errors with ghc --make, but not with ghci? In-Reply-To: <5fdc56d70903040325p18a6ec53g38c917dc683d75e5@mail.gmail.com> References: <5fdc56d70903040325p18a6ec53g38c917dc683d75e5@mail.gmail.com> Message-ID: Thanks for the feedback. Yes this is definitely a complex thing. I succeeded in just the opposite: with a lot of hackery I got the FTGL binding on Hackage to compile and correctly run. However, when using it from GHCi it "compiles" correctly but fails to load the font and hence crashes. I'll try to look into the problem too, since I want to learn the FFI stuff. I'm also thinking to wrap QuesoGLC since it seems to have a nicer API then FTGL although I'm not sure it's worth the trouble On Wed, Mar 4, 2009 at 12:25 PM, Stephen Tetley wrote: > Hi Peter > > Yes this is definitely a problem with the OpenVG package. > > Although I wrote the package I don't know enough about the minutiae of > Windows .dlls to sort this out directly (even though I did write most > of the library on a Windows machine). I could try to and write a > cabal+makefile build rather than a pure cabal one to follow the > example of the OpenGL and GLUT libraries, though I don't know if that > would work. With my current OpenGL and GLUT installation[1] on Windows > I can only run GL programs from GHCi rather than compile them. > > Please let me know if you want me to try a cabal+makefile package, > though the turnaround might not be quick. > > Best wishes > > Stephen > > [1] installed by following these instructions > http://netsuperbrain.com/blog/posts/freeglut-windows-hopengl-hglut/ > > > > 2009/3/4 Peter Verswyvelen : >> I followed the instructions on how to build OpenVG on Windows. It works fine >> when I run the examples using "GHCi -lopenvg32", but when compiling it with >> "GHC --make -lopenvg32" I get a bunch of linker errors, like >> C:\Program >> Files\Haskell\OpenVG-0.1\ghc-6.10.1/libHSOpenVG-0.1.a(Paths.o):fake:(.text+0x82): >> undefined reference to `vgInterpolatePath' >> C:\Program >> Files\Haskell\OpenVG-0.1\ghc-6.10.1/libHSOpenVG-0.1.a(Paths.o):fake:(.text+0x40d): >> undefined reference to `vgModifyPathCoords' >> etc >> However it does seem that the libopenvg32.a file contains all these >> undefined references, and it is in the gcc-lib directory of GHC. >> I'm a stuck. Any hints? >> Thanks, >> Peter >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > From rj248842 at hotmail.com Wed Mar 4 10:02:01 2009 From: rj248842 at hotmail.com (R J) Date: Wed Mar 4 09:50:46 2009 Subject: [Haskell-cafe] (no subject) Message-ID: Could someone provide an elegant solution to Bird problem 4.2.13? Here are the problem and my inelegant solution: Problem ------- Since concatenation seems such a basic operation on lists, we can try to construct a data type that captures concatenation as a primitive. For example, data (CatList a) = CatNil | Wrap a | Cat (CatList a) (CatList a) The intention is that CatNil represents [], Wrap x represents [x], and Cat x y represents x ++ y. However, since "++" is associative, the expressions "Cat xs (Cat ys zs)" and "Cat (Cat xs ys) zs" should be regarded as equal. Define appropriate instances of "Eq" and "Ord" for "CatList". Inelegant Solution ------------------ The following solution works: instance (Eq a) => Eq (CatList a) where CatNil == CatNil = True CatNil == Wrap z = False CatNil == Cat z w = ( z == CatNil && w == CatNil ) Wrap x == CatNil = False Wrap x == Wrap z = x == z Wrap x == Cat z w = ( Wrap x == z && w == CatNil ) || ( Wrap x == w && z == CatNil ) Cat x y == CatNil = x == CatNil && y == CatNil Cat x y == Wrap z = ( x == Wrap z && y == CatNil ) || ( x == CatNil && y == Wrap z ) Cat x y == Cat z w = unwrap (Cat x y) == unwrap (Cat z w) unwrap :: CatList a -> [a] unwrap CatNil = [] unwrap (Wrap x) = [x] unwrap (Cat x y) = unwrap x ++ unwrap y instance (Eq a, Ord a) => Ord (CatList a) where x < y = unwrap x < unwrap y This solution correctly recognizes the equality of the following, including nested lists(represented, for example, by Wrap (Wrap 1), which corresponds to [[1]]): Wrap 1 == Cat (Wrap 1) CatNil Cat (Wrap 1) (Cat (Wrap 2) (Wrap 3)) == Cat (Wrap 1) (Cat (Wrap 2) (Wrap 3)) Wrap (Wrap 1) == Wrap (Cat (Wrap 1) CatNil) Although this solution works, it's a hack, because unwrap converts CatLists to lists. The question clearly seeks a pure solution that does not rely on Haskell's built-in lists. What's the pure solution that uses cases and recursion on CatList, not Haskell's built-in lists, to capture the equality of nested CatLists? _________________________________________________________________ Windows Live?: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090304/781128ff/attachment.htm From rj248842 at hotmail.com Wed Mar 4 10:07:29 2009 From: rj248842 at hotmail.com (R J) Date: Wed Mar 4 09:56:16 2009 Subject: [Haskell-cafe] Interesting problem from Bird (4.2.13) Message-ID: Could someone provide an elegant solution to Bird problem 4.2.13? Here are the problem and my inelegant solution: Problem ------- Since concatenation seems such a basic operation on lists, we can try to construct a data type that captures concatenation as a primitive. For example, data (CatList a) = CatNil | Wrap a | Cat (CatList a) (CatList a) The intention is that CatNil represents [], Wrap x represents [x], and Cat x y represents x ++ y. However, since "++" is associative, the expressions "Cat xs (Cat ys zs)" and "Cat (Cat xs ys) zs" should be regarded as equal. Define appropriate instances of "Eq" and "Ord" for "CatList". Inelegant Solution ------------------ The following solution works: instance (Eq a) => Eq (CatList a) where CatNil == CatNil = True CatNil == Wrap z = False CatNil == Cat z w = ( z == CatNil && w == CatNil ) Wrap x == CatNil = False Wrap x == Wrap z = x == z Wrap x == Cat z w = ( Wrap x == z && w == CatNil ) || ( Wrap x == w && z == CatNil ) Cat x y == CatNil = x == CatNil && y == CatNil Cat x y == Wrap z = ( x == Wrap z && y == CatNil ) || ( x == CatNil && y == Wrap z ) Cat x y == Cat z w = unwrap (Cat x y) == unwrap (Cat z w) unwrap :: CatList a -> [a] unwrap CatNil = [] unwrap (Wrap x) = [x] unwrap (Cat x y) = unwrap x ++ unwrap y instance (Eq a, Ord a) => Ord (CatList a) where x < y = unwrap x < unwrap y This solution correctly recognizes the equality of the following, including nested lists(represented, for example, by Wrap (Wrap 1), which corresponds to [[1]]): Wrap 1 == Cat (Wrap 1) CatNil Cat (Wrap 1) (Cat (Wrap 2) (Wrap 3)) == Cat (Wrap 1) (Cat (Wrap 2) (Wrap 3)) Wrap (Wrap 1) == Wrap (Cat (Wrap 1) CatNil) Although this solution works, it's a hack, because unwrap converts CatLists to lists. The question clearly seeks a pure solution that does not rely on Haskell's built-in lists. What's the pure solution that uses cases and recursion on CatList, not Haskell's built-in lists, to capture the equality of nested CatLists? _________________________________________________________________ Windows Live? Contacts: Organize your contact list. http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090304/82b88d5f/attachment.htm From daniel.is.fischer at web.de Wed Mar 4 11:31:17 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Mar 4 11:20:00 2009 Subject: [Haskell-cafe] Stacking State on State..... In-Reply-To: References: Message-ID: <200903041731.17527.daniel.is.fischer@web.de> Am Dienstag, 3. M?rz 2009 23:28 schrieb Phil: > I've had a look at your example - it's raised yet more questions in my > mind! > > On 02/03/2009 23:36, "Daniel Fischer" wrote: > > A stupid example: > > ---------------------------------------------------------------------- > > module UhOh where > > > > import Control.Monad > > import Control.Monad.State.Lazy > > --import Control.Monad.State.Strict > > > > > > uhOh :: State s () > > uhOh = State $ \_ -> undefined > > > > uhOhT :: Monad m => StateT s m () > > uhOhT = StateT $ \_ -> return undefined > > > > uhOhT2 :: Monad m => StateT s m () > > uhOhT2 = StateT $ \_ -> undefined > > > > oy :: State s () > > oy = State $ \_ -> ((),undefined) > > > > oyT :: Monad m => StateT s m () > > oyT = StateT $ \_ -> return ((),undefined) > > > > hum :: State Int Int > > hum = do > > k <- get > > w <- uhOh > > put (k+2) > > return w > > return (k+1) > > > > humT :: Monad m => StateT Int m Int > > humT = do > > k <- get > > w <- uhOhT > > put (k+2) > > return w > > return (k+1) > > > > > > humT2 :: Monad m => StateT Int m Int > > humT2 = do > > k <- get > > w <- uhOhT2 > > put (k+2) > > return w > > return (k+1) > > > > > > whoa n = runState (replicateM_ n hum >> hum) 1 > > > > whoaT n = runStateT (replicateM_ n humT >> humT) 1 > > > > whoaT2 n = runStateT (replicateM_ n humT2 >> humT2) 1 > > > > yum :: State Int Int > > yum = do > > k <- get > > w <- oy > > put (k+2) > > return w > > return (k+1) > > > > yumT :: Monad m => StateT Int m Int > > yumT = do > > k <- get > > w <- oyT > > put (k+2) > > return w > > return (k+1) > > > > hoha n = runState (replicateM_ n yum >> yum) 1 > > > > hohaT n = runStateT (replicateM_ n yumT >> yumT) 1 > > > > oops m = runState m 1 > > ---------------------------------------------------------------------- > > > > What happens with > > > > whoa 10 > > hoha 10 > > oops (whoaT 10) > > oops (whoaT2 10) > > oops (hohaT 10) > > > > respectively when the Lazy or Strict library is imported? > > Answer first, then test whether you were right. > > OK, I had a think about this - I'm not 100% clear but: > > UhOh - OK for lazy, Bad for Strict. "undefined" 'could' be of the form > (a,s) so the lazy accepts it, but the strict version tries to produce (a,s) > out of undefined and fails. Correct. > > Oy - Both are OK here. The pair form is retained and neither will go as > far as to analyse the contents of either element of the pair, as neither is > used. Correct. > > UhOhT - OK for lazy, Bad for Strict. Same as Oh UhOh, but as we have > transformer we return inside a Monad. Correct. > > UhOhT2 - Bad for both - transformers should return a Monad. Mostly correct, but, using Lazy: *UhOh> oops (whoaT2 10) ((22,23),*** Exception: Prelude.undefined *UhOh> evalState (runStateT humT2 4) 0 (5,6) *UhOh> let putI :: Int -> State Int (); putI = put *UhOh> let see = do { k <- get; w <- uhOhT2; put (k+2); lift (putI 4); return w; return (k+1) } *UhOh> oops $ runStateT see 3 ((4,5),4) So if the inner monad is lazy enough, it can happily pass over the undefined. Let's look at what happens if we bind uhOhT2 to f :: () -> StateT s m b (where m is some monad). uhOhT2 >>= f = StateT $ \so -> do ~(a,so') <- runStateT uhOhT2 so runStateT (f a) so' = StateT $ \so -> do ~(ao,so') <- undefined runStateT (f a) so' = StateT $ \so -> undefined >>= \x -> let (a,so') = x in runStateT (f a) so' Now if f doesn't inspect a and runStateT (f a) doesn't inspect so', the only one left to raise an objection is the (>>=) of the inner monad m (let bindings are lazy, so the let (a,so') = x won't fail on undefined, only if f needs to analyse a or runStateT (f a) needs to analyse so' will failure occur). If m is Maybe or [], the inner bind fails and so everything fails. But if m is a lazy State monad, we see that undefined >>= g = State $ \si -> let (b, si') = runState undefined si in runState (g b) si' and only if g needs to analyse b or runState (g b) needs to analyse si' we will fail. When g is \x -> let (a,so') = x in runStateT (f a) so', it only needs to analyse b if f needs to analyse a or runStateT (f a) needs to analyse so'. Since I've avoided that, the put repairs the outer state (and in 'see', the 'lift $ putI 4' also repairs the inner state) and no harm's done. > > OyT - Same as Oy, but returned inside a monad. > Sure. > > The thing which confuses me is why we care about these functions at all > hum, yum, etc. Although these inspect the State Monads above they stick > the values in to 'w' which is never used (I think), because the first > return statement just produces "M w" which is not returned because of the > return (k+1) afterwards?? Yes, the w is never really used, makes no difference at all. > > Because lazy and strict are only separated by the laziness on the bind > between contiguous hum and yum states, I would have thought that laziness > on w would have been the same on both. Yes. > > Hmmm. But I suppose each call to hum and yum is increment stating in it's > corresponding UhOh and Oy function. Thus causing these to be strictly > evaluated one level deeper.... In which case I do understand. I'm sorry, I don't understand the above :( In oy(T), we do something moderately bad, we inject an undefined into the state. But we fix it before anybody had a chance to see it in yum(T) by immediately following it by a put. It's a bit like map (const 1) $ map (const undefined) list , the intermediate result would be harmful, but it doesn't persist. In uhOh(T), we do something bad, we let the complete (value,state) pair be undefined. If nobody looks whether it's a real pair before we fix it by the put, again no harm is done. The strict state monad checks if it's a real pair (whatever, whatever else), finds that it isn't and bombs out. The lazy state monad says "whatever, I'll assume it's okay until I need to inspect it". It never needs to inspect it, so it's ignored. In uhOhT2, we do something even worse, we let the inner-monadic value be undefined. The strict state transformer monad says "give me a pair", undefined can't, bomb out. The lazy state transformer monad says "if the inner monad's bind asks you for a pair, hand it over, please" and passes the undefined to the inner monad's bind without inspecting it. > > We have: > > hum >> hum >> hum ..... > > And At each stage we are also doing UhOh >> UhOh >> UhOh inside the hums? > > Is this right, I'm not so sure? I'm in danger of going a bit cross-eyed > here! We're doing an uhOh sandwiched between a get and a put in each hum, so it's rather get >> uhOh >> put x >> get >> uhOh >> ... Now the point is, in the lazy monad we have (uhOh >> put x) === put x, but not in the strict monad. > > >> This means that each new (value,state) is just passed around as a thunk > >> and not even evaluated to the point where a pair is constructed - it's > >> just a blob, and could be anything as far as haskell is concerned. > > > > Not quite anything, it must have the correct type, but whether it's > > _|_, (_|_,_|_), (a,_|_), (_|_,s) or (a,s) (where a and s denote non-_|_ > > elements of the respective types), the (>>=) doesn't care. Whether any > > evaluation occurs is up to (>>=)'s arguments. > > By correct type you mean that it must *feasibly* be a pair... But the lazy > pattern matching doesn't verify that it *is* a pair. Thus if we returned > something that could never be a pair, it will fail to compile, Yes, it may have type forall a. a, or it may have type forall a b. (a,b), or it may have a more restricted pair type. If the bound function k has type a -> State s b , the type of the thing must be unifyable with (a,s). If it's not, the code won't compile. If it is, the lazy pattern matching will not even verify that the thing exists (cf. uhOhT2). > but if it is > of the form X or (X,X) it won't check any further than that, but if it was > say [X] that wouldn't work even for lazy - haskell doesn't trust us that > much!? > > >> It follows that each new state cannot evaluated even if we make > >> newStockSum strict as (by adding a bang) because the state tuple > >> newStockSum is wrapped in is completely unevaluated - so even if > >> newStockSum is evaluated INSIDE this blob, haskell will still keep the > >> whole chain. > > > > Well, even with the bang, newStockSum will only be evaluated if somebody > > looks at what mc delivers. In the Strict case, (>>=) does, so newStockSum > > is evaluated at each step. > > When you say 'looks' at it do you mean it is the final print state on the > result that ultimately causes the newStockSum to be evaluated in the lazy > version? In this case, yes. In principle, you could have something that forces the evaluation before, e.g. if you replace replicateM_ with a stricter version, replicateM'_ :: (Monad m) => Int -> m a -> m () replicateM'_ k a = sequence'_ (replicate k a) sequence'_ :: (Monad m) => [m a] -> m () sequence'_ (x:xs) = do !a <- x sequence'_ xs sequence'_ [] = return () , the sequence'_ inspects the result () of mc. With the bang on newStockSum, this also forces the evaluation of that, even with Control.Monad.State.Lazy. In the few test I ran, the combination State.Lazy and replicateM'_ was about 6% slower and allocated ~8% more than State.Strict and replicateM_. If you leave off the bang on newStockSum, replicateM'_ doesn't help State.Lazy (perhaps a tiny little bit). > Thus we are saying we evaluate it only because we know it is > needed. That's the point of lazy evaluation. And by using strictness annotations in the right places, we help the compiler because we may know that something will be needed although the compiler can't ascertain it alone. > However in the strict case, the fact that newStockSum is used to evaluate > the NEXT newStockSum in the subsequent state (called via the bind) is > enough to force evaluation, even if the result of the subsequent state is > not used? With the bang, yes. > > > In the Lazy case, (>>=) doesn't, replicateM_ doesn't, > > so newStockSum won't be evaluated inside the blob, if it were, it would > > force the evaluation of the previous pair and almost everything else, > > then there would have been no problem. What the bang does in the lazy > > case is to keep the thunk for the evaluation of the states a little > > smaller and simpler, so the evaluation is a bit faster and uses less > > memory, but not much (further strictness elsewhere helps, too, as you've > > investigated). > > So in the lazy state the bang will evaluate things that are local to THIS > state calculation, but it won't force evaluation of previous states. Thus > expression remaining could be simplified as far as possible without > requiring the previous MonteCarlo state or the previous BoxMuller state. In the lazy state, the bang will cause evaluation of newStockSum when somebody says "hand me a pair, not a blob". Then mc says "Okay, a pair. Now what do I put in the pair? Let me see. Ah, the first component is (), no sweat. And the second component is newStockSum - oh, that's strict, so I have to evaluate it before I can put it into the pair." And thus everything else is forced and happiness ensues :) Cheers, Daniel From RafaelGCPP.Linux at gmail.com Wed Mar 4 11:36:53 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Wed Mar 4 11:25:30 2009 Subject: [Haskell-cafe] Interesting problem from Bird (4.2.13) In-Reply-To: References: Message-ID: <351ff25e0903040836p7af50ea8jfeb7af46e74dcea@mail.gmail.com> Mine is somewhat more elegant... data (CatList a) = CatNil | Wrap a | Cat (CatList a) (CatList a) deriving Show instance (Eq a) => Eq (CatList a) where CatNil == CatNil = True Wrap x == Wrap y = x==y a@(Cat x y) == b = case (adjust a) of CatNil -> b==CatNil Wrap x -> (adjust b)==Wrap x Cat x y -> case (adjust b) of Cat z w -> (x==z) && (y==w) otherwise -> False b == a@(Cat x y) = a==b _ == _ = False adjust :: CatList a -> CatList a adjust (Cat CatNil x) = x adjust (Cat x CatNil) = x adjust (Cat (Cat x y) z) = adjust (Cat x (Cat y z)) adjust (Cat x y) = Cat (adjust x) (adjust y) adjust x = x You don't have to evaluate everything. Just do a recursion fixing the associative rule. 2009/3/4 R J > Could someone provide an elegant solution to Bird problem 4.2.13? > > Here are the problem and my inelegant solution: > > Problem > ------- > > Since concatenation seems such a basic operation on lists, we can try to > construct a data type that captures > concatenation as a primitive. > > For example, > > data (CatList a) = CatNil > | Wrap a > | Cat (CatList a) (CatList a) > > The intention is that CatNil represents [], Wrap x represents [x], and Cat > x y represents > x ++ y. > > However, since "++" is associative, the expressions "Cat xs (Cat ys zs)" > and "Cat (Cat xs ys) zs" should be regarded as equal. > > Define appropriate instances of "Eq" and "Ord" for "CatList". > > Inelegant Solution > ------------------ > > The following solution works: > > instance (Eq a) => Eq (CatList a) where > CatNil == CatNil = True > CatNil == Wrap z = False > CatNil == Cat z w = ( z == CatNil && w == CatNil ) > > Wrap x == CatNil = False > Wrap x == Wrap z = x == z > Wrap x == Cat z w = ( Wrap x == z && w == CatNil ) || > ( Wrap x == w && z == CatNil ) > > Cat x y == CatNil = x == CatNil && y == CatNil > Cat x y == Wrap z = ( x == Wrap z && y == CatNil ) || > ( x == CatNil && y == Wrap z ) > Cat x y == Cat z w = unwrap (Cat x y) == unwrap (Cat z w) > > unwrap :: CatList a -> [a] > unwrap CatNil = [] > unwrap (Wrap x) = [x] > unwrap (Cat x y) = unwrap x ++ unwrap y > > instance (Eq a, Ord a) => Ord (CatList a) where > x < y = unwrap x < unwrap y > > This solution correctly recognizes the equality of the following, including > nested lists(represented, for example, by Wrap (Wrap 1), which corresponds > to [[1]]): > > Wrap 1 == Cat (Wrap 1) CatNil > Cat (Wrap 1) (Cat (Wrap 2) (Wrap 3)) == Cat (Wrap 1) (Cat (Wrap 2) (Wrap > 3)) > Wrap (Wrap 1) == Wrap (Cat (Wrap 1) CatNil) > > Although this solution works, it's a hack, because unwrap converts CatLists > to lists. The question clearly seeks a pure solution that does not rely > on Haskell's built-in lists. > > What's the pure solution that uses cases and recursion on > CatList, not Haskell's built-in lists, to capture the equality of nested > CatLists? > > > ------------------------------ > Windows Live? Contacts: Organize your contact list. Check it out. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090304/a57117a4/attachment-0001.htm From devriese at cs.tcd.ie Wed Mar 4 11:37:31 2009 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Wed Mar 4 11:27:21 2009 Subject: [Haskell-cafe] *almost* composition in writer monad Message-ID: <390165D2-C035-429D-A695-4C96690DB480@cs.tcd.ie> Hi, Does this function remind anybody of anything? It seems like I'm missing an obvious abstraction: composeWriter :: [a -> (a, b)] -> a -> (a, [b]) composeWriter [] a = (a, []) composeWriter (f:fs) a = let (a', b) = f a (final_a, bs) = composeWriter fs a' in (final_a, b:bs) It's almost but not quite composition for functions in the Writer monad; the difference is that every function has exactly one b result, rather than a list of them. Edsko From gleb.alexeev at gmail.com Wed Mar 4 11:56:01 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Wed Mar 4 11:44:46 2009 Subject: [Haskell-cafe] Re: Interesting problem from Bird (4.2.13) In-Reply-To: References: Message-ID: Here's my attempt though it's not really different from using built-in lists: viewCL CatNil = Nothing viewCL (Wrap a) = Just (a, CatNil) viewCL (Cat a b) = case viewCL a of Nothing -> viewCL b Just (x, xs) -> Just (x, Cat xs b) instance Eq a => Eq (CatList a) where a == b = case (viewCL a, viewCL b) of (Just (x, xs), Just (y, ys)) -> x==y && xs == ys (Nothing, Nothing) -> True _ -> False From miguelimo38 at yandex.ru Wed Mar 4 12:29:48 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Mar 4 12:18:35 2009 Subject: [Haskell-cafe] *almost* composition in writer monad In-Reply-To: <390165D2-C035-429D-A695-4C96690DB480@cs.tcd.ie> References: <390165D2-C035-429D-A695-4C96690DB480@cs.tcd.ie> Message-ID: <87E587B9-19EC-4920-9A1F-3549CD4332CB@yandex.ru> Isn't that "sequence" in State monad? On 4 Mar 2009, at 19:37, Edsko de Vries wrote: > Hi, > > Does this function remind anybody of anything? It seems like I'm > missing an obvious abstraction: > > composeWriter :: [a -> (a, b)] -> a -> (a, [b]) > composeWriter [] a > = (a, []) > composeWriter (f:fs) a > = let (a', b) = f a > (final_a, bs) = composeWriter fs a' > in (final_a, b:bs) > > It's almost but not quite composition for functions in the Writer > monad; the difference is that every function has exactly one b > result, rather than a list of them. > > Edsko > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Wed Mar 4 13:00:10 2009 From: dons at galois.com (Don Stewart) Date: Wed Mar 4 12:49:38 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <49ABFBAB.1050106@libero.it> References: <49ABFBAB.1050106@libero.it> Message-ID: <20090304180010.GD5886@whirlpool.galois.com> manlio_perillo: > Hi. > > After some work I have managed to implement two simple programs that > parse the Netflix Prize data set. > > For details about the Netflix Prize, there was a post by Kenneth Hoste > some time ago. > > I have cabalized the program, and made available here: > http://haskell.mperillo.ath.cx/netflix-0.0.1.tar.gz > > The process-data-1 program parse the training data set, grouping ratings > by movies. > The process-data-2 program, instead, groups ratings by users. > > > The structure of the two programs is similar: I create singletons IntMap > and then use foldl + union to merge them together. > > > The data structure used is: > > type Rating = Word32 :*: Word8 -- id, rating > type MovieRatings = IntMap (UArr Rating) > > UArr is from uvector package. > > > The training data set contains about 100 million ratings, so, in theory, > the amount of memory required to store pairs of (id, rating) is about > 480 MB. > > > The process-data-1 program parse the entire dataset using about 1.4 GB > of memory (3x increment). > > This is strange. > The memory required is proportional to the number of ratings. > It may be IntMap the culprit, or the garbage collector than does not > release the memory to the operating system (or, worse, does not > deallocate all used temporary memory). > > > The process-data-2 has much more problems. > When I try to parse *only* 500 movie ratings, the memory usage is > 471 MB; 780 MB after all data has been fully evaluated (array > concatenations). > > > I'm using ghc 6.8.2 on Debian Etch. > I would like to do some tests with recent GHC versions, but it may be a > problem. > Seems like a useful benchmark of a number of things. Any chance you'll upload it to hackage? From devriese at cs.tcd.ie Wed Mar 4 13:02:38 2009 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Wed Mar 4 12:52:35 2009 Subject: [Haskell-cafe] *almost* composition in writer monad In-Reply-To: <87E587B9-19EC-4920-9A1F-3549CD4332CB@yandex.ru> References: <390165D2-C035-429D-A695-4C96690DB480@cs.tcd.ie> <87E587B9-19EC-4920-9A1F-3549CD4332CB@yandex.ru> Message-ID: Doh, yes, of course. I had a feeling I was missing something obvious :) Thanks :) On 4 Mar 2009, at 17:29, Miguel Mitrofanov wrote: > Isn't that "sequence" in State monad? > > On 4 Mar 2009, at 19:37, Edsko de Vries wrote: > >> Hi, >> >> Does this function remind anybody of anything? It seems like I'm >> missing an obvious abstraction: >> >> composeWriter :: [a -> (a, b)] -> a -> (a, [b]) >> composeWriter [] a >> = (a, []) >> composeWriter (f:fs) a >> = let (a', b) = f a >> (final_a, bs) = composeWriter fs a' >> in (final_a, b:bs) >> >> It's almost but not quite composition for functions in the Writer >> monad; the difference is that every function has exactly one b >> result, rather than a list of them. >> >> Edsko >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Wed Mar 4 13:08:47 2009 From: dons at galois.com (Don Stewart) Date: Wed Mar 4 12:58:12 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <9979e72e0903040226r30727061seb8d1b4327af3348@mail.gmail.com> References: <9979e72e0902281451k20ec1bd5i38ffdb81e021222e@mail.gmail.com> <20090228225416.GG23790@whirlpool.galois.com> <9979e72e0903011304v32d78d7jbeddfccfe069ae28@mail.gmail.com> <9979e72e0903020403s7e90582br5b0fbca58acebe8f@mail.gmail.com> <9979e72e0903040226r30727061seb8d1b4327af3348@mail.gmail.com> Message-ID: <20090304180847.GF5886@whirlpool.galois.com> jwlato: > On Tue, Mar 3, 2009 at 1:03 AM, Henning Thielemann > wrote: > > > > On Mon, 2 Mar 2009, John Lato wrote: > > > > While I think that the Iteratee pattern has benefits, I suspect that it > > can't be combined with regular lazy functions, e.g. of type [a] -> [a]. Say > > I have a chain of functions: read a file, parse it into a tag soup, parse > > that into an XML tree, transform that tree, format that into a string, write > > that to a file, and all of these functions are written in a lazy way, which > > is currently considered good style, I can't use them in conjunction with > > iteratees. This means, almost all Haskell libraries have to be rewritten or > > extended from lazy style to iteratee style. The question for me is then: Why > > having laziness in Haskell at all? Or at least, why having laziness by > > default, why not having laziness annotation instead of strictness > > annotation. > > > > I'm not sure that this is a problem, at least not for all cases. When > reading seekable streams, it is possible to have IO on demand provided > that all processing take place within the context of the Iteratee (see > Oleg's Tiff reader, http://okmij.org/ftp/Haskell/Iteratee/Tiff.hs, and > my wave reader, > http://inmachina.net/~jwlato/haskell/iteratee/src/Data/Iteratee/Codecs/Wave.hs). BTW, I've started (with his blessing) packaging up Oleg's Haskell code: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/liboleg-0.1.0.2 So you can use, e.g., the left-fold based TIFF parser: http://hackage.haskell.org/packages/archive/liboleg/0.1.0.2/doc/html/Codec-Image-Tiff.html I'm walking backwards over his released modules, adding a few each day. Enjoy. -- Don From ryani.spam at gmail.com Wed Mar 4 13:55:18 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Mar 4 13:43:56 2009 Subject: [Haskell-cafe] Interesting problem from Bird (4.2.13) In-Reply-To: References: Message-ID: <2f9b2d30903041055o7ceee788q10449c8027b5e4d4@mail.gmail.com> 2009/3/4 R J : > What's the pure solution that uses cases and recursion on > CatList, not Haskell's built-in lists, to capture the equality of nested > CatLists? As Rafael pointed out, the simplest thing to do is to convert to a canonical form; you can prove that each CatList has a single canonical form and that two equal CatLists always have the same canonical form. Something from Rafael's solution was bugging me, though. > adjust :: CatList a -> CatList a > adjust (Cat CatNil x) = x > adjust (Cat x CatNil) = x -- *1 > adjust (Cat (Cat x y) z) = adjust (Cat x (Cat y z)) > adjust (Cat x y) = Cat (adjust x) (adjust y) -- *2 > adjust x = x *2 is the more odd one. I was sure he had missed a case where the result of the left "adjust" was incorrect. But he didn't; the interesting thing is that the left adjust is redundant. The only case left is "Wrap" which does nothing. *1 is a bit odd because it breaks the nice symmetry of the pattern-matching. Also, the CatNil cases both fail to adjust the results. Here's my solution: > canonical (Cat CatNil xs) = canonical xs > canonical (Cat (Cat x y) z) = canonical (Cat x (Cat y z)) > canonical (Cat x xs) = Cat x (canonical xs) -- x is "Wrap e" for some e > canonical (Wrap e) = Cat (Wrap e) CatNil > canonical CatNil = CatNil However, this is basically just converting to a list! In canonical form, a CatList always looks like this: Cat (Wrap e1) $ Cat (Wrap e2) $ Cat (Wrap e3) $ ... $ CatNil > canon_eq CatNil CatNil = True > canon_eq (Cat (Wrap x) xs) (Cat (Wrap y) ys) = x == y && canon_eq xs ys > canon_eq _ _ = False > instance Eq a => Eq (CatList a) where xs == ys = canonical xs `canon_eq` canonical ys Gleb's "viewCL" solution is also interesting, but it is also equivalent to using lists, due to lazy evaluation. In fact, an efficient "toList" on CatLists is just "unfoldr viewCL". From frodo at theshire.org Wed Mar 4 15:53:44 2009 From: frodo at theshire.org (Cristiano Paris) Date: Wed Mar 4 15:42:20 2009 Subject: [Haskell-cafe] Re: Zippers In-Reply-To: References: Message-ID: On Wed, Mar 4, 2009 at 12:50 PM, Heinrich Apfelmus wrote: > ... > The unusual thing about your implementation is probably that you're > tying a knot by making both ?moveUp ?and ?moveLeft ?record fields. This > reminds me of > > ?Weaving a web. Ralf Hinze and Johan Jeuring. 2001. > ?http://www.informatik.uni-bonn.de/~ralf/publications/TheWeb.ps.gz > > > The problem with knot-tying / sharing is of course that they are tricky > to update. What about the crucial function > > ?update :: ZContext a -> Maybe a -> ZContext a > > that changes the data at a leaf? I think that with your current > approach, you'd have to regenerate the whole context which pretty much > defeats the purpose of a zipper. Hi Heinrich and thanks for your reply. I haven't read the paper (which I'm going to read now) but I don't fully understand your point. I'd (and indeed I did) write 'update' as: update z x = z { this = this z >> Just x } exploiting the '>>' operator's logic. How would this differ from the corresponding 'update' in the original Huet's FP? Maybe I don't get how my update would impact performances. In both cases the update functions leave context unchanged, don't they? If my update function have to replicate the context since functional values are immutable, doesn't Huet's do the same? Thank you for any further comments. Cristiano From martijn at van.steenbergen.nl Wed Mar 4 16:07:29 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Mar 4 15:56:06 2009 Subject: [Haskell-cafe] environment variables for runghc? In-Reply-To: <20090304175040.4468b6ca.mle+hs@mega-nerd.com> References: <20090304140739.c7e09109.mle+hs@mega-nerd.com> <57526e770903032106m41ada33dwa2aaf90a50692c56@mail.gmail.com> <20090304175040.4468b6ca.mle+hs@mega-nerd.com> Message-ID: <49AEED91.4050309@van.steenbergen.nl> So try: $ alias runghc='runghc -Wall' Assuming you're on Unix. HTH, Martijn. Erik de Castro Lopo wrote: > Alexander Dunlap wrote: > >> I doubt there's an env variable, but you could do >> >> $ alias ghc='ghc -Wall' > > Sorry, doesn't work. I'm pretty sure runghc uses ghc directly > and doesn't invoke a user shell to do so. > > Erik From frodo at theshire.org Wed Mar 4 16:07:53 2009 From: frodo at theshire.org (Cristiano Paris) Date: Wed Mar 4 15:56:29 2009 Subject: [Haskell-cafe] Re: Zippers In-Reply-To: References: Message-ID: On Wed, Mar 4, 2009 at 9:53 PM, Cristiano Paris wrote: > ... > Thank you for any further comments. I forgot to mention one drawback I found in my implementation: it can't be (de)serialized to a String, which is clearly possible with Huet's. I think this accounts for the "Zipper as a delimited continuation reified to data" statement :D Cristiano From barsoap at web.de Wed Mar 4 17:38:01 2009 From: barsoap at web.de (Achim Schneider) Date: Wed Mar 4 17:26:48 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions References: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> Message-ID: <20090304233801.3048333f@solaris> Peter Verswyvelen wrote: > Maybe this raises a new question: does understanding category theory > makes you a better *programmer*? > Possibly yes, possibly no. In my experience, you have to have a look at how CT is applied to other fields to appreciate its clarity. Doing so, you may succeed in promoting some of your understanding of code to a more general level. I see abstract nonsense as way less fuzzy than lambda-based abstraction, and a lot more flexible (mentally speaking) than type theory, or logic, in general. The fact that it encompasses both makes it even more attractive (although you can express both of them in terms of the other as it stands) There's not much to understand about CT, anyway: It's actually nearly as trivial as set theory. One part of the benefit starts when you begin to categorise different kind of categories, in the same way that understanding monads is easiest if you just consider their difference to applicative functors. It's a system inviting you to tackle a problem with scrutiny, neither tempting you to generalise way beyond computability, nor burdening you with formal proof requirements or shackling you to some other ball and chain. Sadly, almost all texts about CT are absolutely useless: They tend to focus either on pure mathematical abstraction, lacking applicability, or tell you the story for a particular application of CT to a specific topic, loosing themselves in detail without providing the bigger picture. That's why I liked that Rosetta stone paper so much: I still don't understand anything more about physics, but I see how working inside a category with specific features and limitations is the exact right thing to do for those guys, and why you wouldn't want to do a PL that works in the same category. Throwing lambda calculus at a problem that doesn't happen to be a DSL or some other language of some sort is a bad idea. I seem to understand that for some time now, being especially fond of automata[1] to model autonomous, interacting agents, but CT made me grok it. The future will show how far it will pull my thinking out of the Turing tarpit. [1] Which aren't, at all, objects. Finite automata don't go bottom in any case, at least not if you don't happen to shoot them and their health drops below zero. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From lrpalmer at gmail.com Wed Mar 4 17:55:02 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Mar 4 17:43:39 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: <20090304233801.3048333f@solaris> References: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> <20090304233801.3048333f@solaris> Message-ID: <7ca3f0160903041455r3b54de58wb518833d3d8541c3@mail.gmail.com> On Wed, Mar 4, 2009 at 3:38 PM, Achim Schneider wrote: > There's not much to understand about CT, anyway: It's actually nearly > as trivial as set theory. You mean that theory which predicts the existence of infinitely many infinities; in fact for any cardinal, there are at least that many cardinals? That theory in which aleph_1 and 2^aleph_0 are definitely comparable, but we provably cannot compare them? The theory which has omega_0 < omega_1 < omega_2 < ... omega_omega < ..., where obviously omega_a is much larger than a... except for when it catches its tail and omega_alpha = alpha for some crazy-ass alpha. I don't think set theory is trivial in the least. I think it is complicated, convoluted, often anti-intuitive and nonconstructive. Category theory is much more trivial, and that's what makes it powerful. (Although training yourself to think categorically is quite difficult, I'm finding) > One part of the benefit starts when you begin > to categorise different kind of categories, in the same way that > understanding monads is easiest if you just consider their difference > to applicative functors. It's a system inviting you to tackle a problem > with scrutiny, neither tempting you to generalise way beyond > computability, nor burdening you with formal proof requirements or > shackling you to some other ball and chain. > > Sadly, almost all texts about CT are absolutely useless: They > tend to focus either on pure mathematical abstraction, lacking > applicability, or tell you the story for a particular application of CT > to a specific topic, loosing themselves in detail without providing the > bigger picture. That's why I liked that Rosetta stone paper so much: I > still don't understand anything more about physics, but I see how > working inside a category with specific features and limitations is the > exact right thing to do for those guys, and why you wouldn't want to do > a PL that works in the same category. > > > Throwing lambda calculus at a problem that doesn't happen to be a DSL > or some other language of some sort is a bad idea. I seem to understand > that for some time now, being especially fond of automata[1] to model > autonomous, interacting agents, but CT made me grok it. The future will > show how far it will pull my thinking out of the Turing tarpit. > > > [1] Which aren't, at all, objects. Finite automata don't go bottom in > any case, at least not if you don't happen to shoot them and their > health drops below zero. > > -- > (c) this sig last receiving data processing entity. Inspect headers > for copyright history. All rights reserved. Copying, hiring, renting, > performance and/or quoting of this signature prohibited. > > > _______________________________________________ > 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/20090304/f372561e/attachment.htm From mle+hs at mega-nerd.com Wed Mar 4 18:13:54 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Mar 4 18:02:34 2009 Subject: [Haskell-cafe] environment variables for runghc? In-Reply-To: <49AEED91.4050309@van.steenbergen.nl> References: <20090304140739.c7e09109.mle+hs@mega-nerd.com> <57526e770903032106m41ada33dwa2aaf90a50692c56@mail.gmail.com> <20090304175040.4468b6ca.mle+hs@mega-nerd.com> <49AEED91.4050309@van.steenbergen.nl> Message-ID: <20090305101354.17e3b3bc.mle+hs@mega-nerd.com> Martijn van Steenbergen wrote: > So try: > > $ alias runghc='runghc -Wall' Of course! I should have tried that, but I looked at the man page for runghc and -Wall wasn't mentioned. > Assuming you're on Unix. Of course :-). Thanks ver much Martijn. Cheers, Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- `If you want a vision of the future, it is a wireless broadband network feeding requests for foreign money-laundering assistance into a human temporal lobe, forever. With banner ads.' -- John M. Ford From haskell at list.mightyreason.com Wed Mar 4 18:22:45 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Wed Mar 4 18:11:29 2009 Subject: [Haskell-cafe] Optimization by cafe Message-ID: I have a performance glitch in regex-tdfa related to GHC-6.10.1 (on a PPC G4 with -O2). I have okay code that runs in 0.2 seconds. I simplify this code to run faster and it takes 4.0 seconds (it allocates something in the loop, I think) I turn on -prof for the simpler code and it runs in 0.25 seconds. I can't profile my way out of it, due to above paradox. Has anyone else seen this sort of paradox? The simpler code's loop is just a bunch of pattern matching and lookups, multi: > matchTest :: Regex -> S.ByteString -> Bool > matchTest !r !input = ... > > multi (Simple' {dt_win=w,dt_trans=CharMap t, dt_other=o}) !off = > if IMap.null w > then if off > endOff > then False > else case IMap.findWithDefault o (fromEnum (input `S.unsafeIndex` off)) t of > Transition {trans_many=DFA {d_dt=dt'}} -> > multi dt' (succ off) > else True All the above regex search does is look for a match. It is a tester, returning Bool. The "w" is checked for winning, if it wins it returns True. If not winning, the offset is checked against the end (cached in endOff). If the end has been reach it returns False. Otherwise it looks up the Word8 at offset "off" in "input" , looks up this Word8 as an Int in the t::IntMap Transition , defaulting to Transition "o" The next DT is followed with the (succ off), note that !off is strict. I cannot think of how to reduce the code any further. It should not be doing any allocation. The Regex is being compiled once, cached, and run 10^6 times against a short piece of text. I know it can run fast because I have huge module running in ST.Strict that does all kinds of extra computation and runs in 0.2 seconds. It should be possible to cut this down and win. So I also applied my delete key to most of the code in the complicated ST.Strict module, keeping the runST. The end result was not unlike the above code, and ran in 4.0 seconds instead of 0.2 seconds. I have looked hard at the core output. I am at a loss. So I have turned to haskell-cafe for insight and moral support. -- Chris From RafaelGCPP.Linux at gmail.com Wed Mar 4 18:38:43 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Wed Mar 4 18:27:18 2009 Subject: [Haskell-cafe] Interesting problem from Bird (4.2.13) In-Reply-To: <2f9b2d30903041055o7ceee788q10449c8027b5e4d4@mail.gmail.com> References: <2f9b2d30903041055o7ceee788q10449c8027b5e4d4@mail.gmail.com> Message-ID: <351ff25e0903041538ha88c4d2icfa7dc155bb1606e@mail.gmail.com> Good point Ryan, I did it in my lunch time and, being in a hurry, overlooked the fact that left adjust in (*2) is redundant and that (*1) can be completely removed by using (adjust x). I actually think I added (*2) for "safety"!! :-D R J, you should take a look on Chris Okasaki's book. This is pretty much what he does all the time to make sure invariants in his data structures are met. Best Regards, Rafael On Wed, Mar 4, 2009 at 15:55, Ryan Ingram wrote: > 2009/3/4 R J : > > What's the pure solution that uses cases and recursion on > > CatList, not Haskell's built-in lists, to capture the equality of nested > > CatLists? > > As Rafael pointed out, the simplest thing to do is to convert to a > canonical form; you can prove that each CatList has a single canonical > form and that two equal CatLists always have the same canonical form. > > Something from Rafael's solution was bugging me, though. > > adjust :: CatList a -> CatList a > > adjust (Cat CatNil x) = x > > adjust (Cat x CatNil) = x -- *1 > > adjust (Cat (Cat x y) z) = adjust (Cat x (Cat y z)) > > adjust (Cat x y) = Cat (adjust x) (adjust y) -- *2 > > adjust x = x > > *2 is the more odd one. I was sure he had missed a case where the > result of the left "adjust" was incorrect. But he didn't; the > interesting thing is that the left adjust is redundant. The only case > left is "Wrap" which does nothing. > > *1 is a bit odd because it breaks the nice symmetry of the > pattern-matching. > > Also, the CatNil cases both fail to adjust the results. > > Here's my solution: > > > canonical (Cat CatNil xs) = canonical xs > > canonical (Cat (Cat x y) z) = canonical (Cat x (Cat y z)) > > canonical (Cat x xs) = Cat x (canonical xs) -- x is "Wrap e" for some e > > canonical (Wrap e) = Cat (Wrap e) CatNil > > canonical CatNil = CatNil > > However, this is basically just converting to a list! In canonical > form, a CatList always looks like this: > > Cat (Wrap e1) $ Cat (Wrap e2) $ Cat (Wrap e3) $ ... $ CatNil > > > canon_eq CatNil CatNil = True > > canon_eq (Cat (Wrap x) xs) (Cat (Wrap y) ys) = x == y && canon_eq xs ys > > canon_eq _ _ = False > > > instance Eq a => Eq (CatList a) where xs == ys = canonical xs `canon_eq` > canonical ys > > Gleb's "viewCL" solution is also interesting, but it is also > equivalent to using lists, due to lazy evaluation. In fact, an > efficient "toList" on CatLists is just "unfoldr viewCL". > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090304/a32ef4d3/attachment.htm From ok at cs.otago.ac.nz Wed Mar 4 19:47:42 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Mar 4 19:36:21 2009 Subject: [Haskell-cafe] (no subject) In-Reply-To: References: Message-ID: On 5 Mar 2009, at 4:02 am, R J wrote: > Could someone provide an elegant solution to Bird problem 4.2.13? This is the classic Lisp "SAMEFRINGE" problem in disguise. You say that the method of converting CatLists to lists and then comparing those is a "hack", but I take leave to doubt that. It's easy to get right, and it works. == and < are, in general, O(n) operations on lists, so the O(n) cost of converting trees to lists isn't unreasonable. In fact given ((((((Wrap 1) ++ ..) ++ ..) ....) it can take O(n) time to reach the very first element. Best of all, the fact that Haskell is lazy means that converting trees to lists and comparing the lists are interleaved; if comparison stops early the rest of the trees won't be converted. One way to proceed in a strict language is to work with a (pure) state involving - the current focus of "list" 1 - the current focus of "list" 2 - the rest of "list" 1 (as a list of parts) - the rest of "list" 2 (as a list of parts). I thought I had demonstrated this when one last check showed a serious bug in my code. In any case, this relies on lists to implement the stacks we use for "the rest of the tree". Your "unwrap" approach is much easier to get right. From fft1976 at gmail.com Wed Mar 4 19:58:15 2009 From: fft1976 at gmail.com (FFT) Date: Wed Mar 4 19:46:50 2009 Subject: [Haskell-cafe] binary serialization Message-ID: Is there a way to do binary serialization of Haskell values (in GHC, at least)? If you propose a method, what are its type safety and portability properties? From xj2106 at columbia.edu Wed Mar 4 20:00:43 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Wed Mar 4 19:49:45 2009 Subject: [Haskell-cafe] Optimizing array operation? Message-ID: <87r61cdbr8.fsf@columbia.edu> Dear list, I decided to extract some common code I use in my data analysis code and end up with some interesting pattern. > -- | Confined array operation. The type Arr here is actually used as > -- a C-like array with index runs from 0 to n-1. > type Arr = Array Int > > -- | Element fetching function, no bounds checking. Works with array > -- with index [0..n-1] > (!>) :: Arr e -> Int -> e > (!>) = unsafeAt > {-# INLINE (!>) #-} > > -- | Length of the array. > arrLength :: Arr e -> Int > arrLength = numElements > {-# INLINE arrLength #-} > > -- | Sequentially loop over all elements in an array. > loopArrM :: (Monad m) => > (e -> m a) -- ^ function to apply to elements > -> Arr e -- ^ the array > -> m () > loopArrM = loopArrMp (\ _ -> True) > {-# INLINE loopArrM #-} > > -- | Same as loopArrM but only to those with index satisfies predicate. > loopArrMp :: (Monad m) => > (Int -> Bool) -- ^ predicate > -> (e -> m a) -- ^ function to apply to elements > -> Arr e -- ^ the array > -> m () > loopArrMp p f arr = loopArrMG 0 end p f arr > where > end = arrLength arr > {-# INLINE loopArrMp #-} > > -- | Same as loopArrM but only to indices within a range. > loopArrMr :: (Monad m) => > Int -- ^ start index > -> Int -- ^ end index > -> (e -> m a) -- ^ function to apply to elements > -> Arr e -- ^ the array > -> m () > loopArrMr start end = loopArrMG start end (\ _ -> True) > {-# INLINE loopArrMr #-} > > -- | Generic loopArrM for indices with in a range [start, end-1] and > -- satisfy predicate. > loopArrMG :: (Monad m) => > Int -- ^ start index > -> Int -- ^ end index > -> (Int -> Bool) -- ^ predicate > -> (e -> m a) -- ^ function to apply to elements > -> Arr e -- ^ the array > -> m () > loopArrMG start end p f arr = go start > where > go !j | j == end = return () > | p j = f (arr !> j) >> go (j + 1) > | otherwise = go (j + 1) > {-# INLINE loopArrMG #-} It is quite frequently to loop over Arr with various conditions, so I wrote loopArrMG to do it. I know a list comprehension would just do the trick, but the extra time and heap allocation is not what I want. My question here is that whether there is a better data structure available to accomplish such task? If not, is there a better way to write the above code? Thanks, Xiao-Yong -- c/* __o/* <\ * (__ */\ < From fft1976 at gmail.com Wed Mar 4 20:03:38 2009 From: fft1976 at gmail.com (FFT) Date: Wed Mar 4 19:52:15 2009 Subject: [Haskell-cafe] MPI Message-ID: Are MPI bindings still the best way of using Haskell on Beowulf clusters? It's my feeling that the bindings stagnated, or are they just very mature? From dons at galois.com Wed Mar 4 20:04:07 2009 From: dons at galois.com (Don Stewart) Date: Wed Mar 4 19:53:30 2009 Subject: [Haskell-cafe] binary serialization In-Reply-To: References: Message-ID: <20090305010407.GJ6336@whirlpool.galois.com> fft1976: > Is there a way to do binary serialization of Haskell values (in GHC, > at least)? If you propose a method, what are its type safety and > portability properties? There are many ways. See Data.Binary (fast, portable). Most are type safe, or additional safety can be added. From matt at mattelder.org Wed Mar 4 20:29:39 2009 From: matt at mattelder.org (Matthew Elder) Date: Wed Mar 4 20:18:15 2009 Subject: [Haskell-cafe] ANN: Happstack 0.2 Released Message-ID: <987d172d0903041729m3d5d475dha3d8a08f18523377@mail.gmail.com> Happstack 0.2 has been released; it is available on Hackage. A lot of community effort has gone into it! For details, please see this post: http://blog.happstack.com/2009/03/04/happstack-02-released Regards, Matthew Elder -- Need somewhere to put your code? http://patch-tag.com Want to build a webapp? http://happstack.com From ryani.spam at gmail.com Wed Mar 4 21:00:15 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Mar 4 20:48:51 2009 Subject: [Haskell-cafe] Re: Zippers In-Reply-To: References: Message-ID: <2f9b2d30903041800l71753c19p187d17d739275a8b@mail.gmail.com> On Wed, Mar 4, 2009 at 12:53 PM, Cristiano Paris wrote: > I'd (and indeed I did) write 'update' as: > > update z x = z { this = this z >> Just x } > > exploiting the '>>' operator's logic. How would this differ from the > corresponding 'update' in the original Huet's FP? Maybe I don't get > how my update would impact performances. In both cases the update > functions leave context unchanged, don't they? If my update function > have to replicate the context since functional values are immutable, > doesn't Huet's do the same? > > Thank you for any further comments. The problem is that your zipper structure is too open, you don't have any specification of the "zipper laws". For example, I'd expect that for any zipper z, one of the following holds: a) moveUp z = Nothing b) moveUp z >>= moveLeft = Just z c) moveUp z >>= moveRight = Just z Here is the problem with your "update": tree = Fork (Leaf 1) (Leaf 2) ztree = initZ tree test = fromJust $ do z1 <- moveLeft ztree let z2 = update z1 3 z3 <- moveUp z2 z4 <- moveLeft z3 this z4 I'd expect "test" to equal 3, but I believe with your code that it still equals 1. As apfelmus said, update needs to completely re-construct the zipper structure with the tied knot, which defeats the purpose of using a zipper in the first place. -- ryan From gwern0 at gmail.com Wed Mar 4 21:33:15 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Mar 4 21:21:51 2009 Subject: [Haskell-cafe] Data.Binary stack overflow with Data.Sequence String In-Reply-To: <3a9962070903032050o4221663y77128df44b5cf965@mail.gmail.com> References: <3a9962070903032050o4221663y77128df44b5cf965@mail.gmail.com> Message-ID: On Tue, Mar 3, 2009 at 11:50 PM, Spencer Janssen wrote: > On Tue, Mar 3, 2009 at 10:30 PM, Gwern Branwen wrote: >> So recently I've been having issues with Data.Binary & Data.Sequence; >> I serialize a 'Seq String' >> >> You can see the file here: http://code.haskell.org/yi/Yi/IReader.hs >> >> The relevant function seems to be: >> >> -- | Read in database from 'dbLocation' and then parse it into an 'ArticleDB'. >> readDB :: YiM ArticleDB >> readDB = io $ (dbLocation >>= r) `catch` (\_ -> return empty) >> ? ? ? ? ?where r x = fmap (decode . BL.fromChunks . return) $ B.readFile x >> ? ? ? ? ? ? ? ?-- We read in with strict bytestrings to guarantee the >> file is closed, >> ? ? ? ? ? ? ? ?-- and then we convert it to the lazy bytestring >> data.binary expects. >> ? ? ? ? ? ? ? ?-- This is inefficient, but alas... >> >> My current serialized file is about 9.4M. I originally thought that >> the issue might be the recent upgrade in Yi to binary 0.5, but I >> unpulled patches back to past that, and the problem still manifested. >> >> Whenever yi tries to read the articles.db file, it stack overflows. It >> actually stack-overflowed on even smaller files, but I managed to bump >> the size upwards, it seems, by the strict-Bytestring trick. >> Unfortunately, my personal file has since passed whatever that limit >> was. >> >> I've read carefully the previous threads on Data.Binary and Data.Map >> stack-overflows, but none of them seem to help; hacking some $!s or >> seqs into readDB seems to make no difference, and Seq is supposed to >> be a strict datastructure already! Doing things in GHCi has been >> tedious, and hasn't enlightened me much: sometimes things overflow and >> sometimes they don't. It's all very frustrating and I'm seriously >> considering going back to using the original read/show code unless >> anyone knows how to fix this - that approach may be many times slower, >> but I know it will work. >> >> -- >> gwern > > Have you tried the darcs version of binary? ?It has a new instance > which looks more efficient than the old. > > > Cheers, > Spencer Janssen I have. It still stack-overflows on my 9.8 meg file. (The magic number seems to be somewhere between 9 and 10 megabytes.) -- gwern From magicloud.magiclouds at gmail.com Wed Mar 4 21:40:07 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed Mar 4 21:28:43 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? Message-ID: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> Hi, I am using gtk2hs to make some sidebar thing for xmonad. Well, after I tried a few ways, I still cannot make it dock like xmobar. It just covered other windows at the edge of the screen. Could someone give me a sample or something I could learn from? Thanks. -- ??????? ??????? From allbery at ece.cmu.edu Wed Mar 4 22:59:53 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Mar 4 22:48:49 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> Message-ID: <9D7EC421-A962-47C9-B009-BC4401357247@ece.cmu.edu> On 2009 Mar 4, at 21:40, Magicloud Magiclouds wrote: > I am using gtk2hs to make some sidebar thing for xmonad. Well, after > I tried a few ways, I still cannot make it dock like xmobar. It just > covered other windows at the edge of the screen. > Could someone give me a sample or something I could learn from? > Thanks. You need to go to freedesktop.org and read up on the Extended Window Manager Hints. In this particular case the extension you need is the _NET_WM_STRUT property. (xmobar is open source, you could look through its source) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090304/2e3c3c42/PGP.bin From newsham at lava.net Thu Mar 5 00:55:20 2009 From: newsham at lava.net (Tim Newsham) Date: Thu Mar 5 00:44:14 2009 Subject: [Haskell-cafe] binary serialization In-Reply-To: <20090305010407.GJ6336@whirlpool.galois.com> References: <20090305010407.GJ6336@whirlpool.galois.com> Message-ID: > fft1976: >> Is there a way to do binary serialization of Haskell values (in GHC, >> at least)? If you propose a method, what are its type safety and >> portability properties? > > There are many ways. See Data.Binary (fast, portable). Most are type > safe, or additional safety can be added. I would add to that: Data.Derive can be used to automatically generate Data.Binary.Binary instances for your custom data types. Tim Newsham http://www.thenewsh.com/~newsham/ From magicloud.magiclouds at gmail.com Thu Mar 5 01:06:47 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Mar 5 00:55:24 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: <9D7EC421-A962-47C9-B009-BC4401357247@ece.cmu.edu> References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> <9D7EC421-A962-47C9-B009-BC4401357247@ece.cmu.edu> Message-ID: <3bd412d40903042206xf635b00ocb2ab0f222e40159@mail.gmail.com> Since I am using gtk, I set Gdk::Window::TYPE_HINT_DOCK as its document says. But it does not work. And as I looked into xmobar's source, there seems no special code for xmonad. And my xmonad.hs is very simple, too. So I wonder how to make it work.... On Thu, Mar 5, 2009 at 11:59 AM, Brandon S. Allbery KF8NH wrote: > On 2009 Mar 4, at 21:40, Magicloud Magiclouds wrote: >> >> ?I am using gtk2hs to make some sidebar thing for xmonad. Well, after >> I tried a few ways, I still cannot make it dock like xmobar. It just >> covered other windows at the edge of the screen. >> ?Could someone give me a sample or something I could learn from? Thanks. > > > You need to go to freedesktop.org and read up on the Extended Window Manager > Hints. ?In this particular case the extension you need is the _NET_WM_STRUT > property. > > (xmobar is open source, you could look through its source) > > -- > 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 magicloud.magiclouds at gmail.com Thu Mar 5 01:45:51 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Mar 5 01:34:27 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: <3bd412d40903042206xf635b00ocb2ab0f222e40159@mail.gmail.com> References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> <9D7EC421-A962-47C9-B009-BC4401357247@ece.cmu.edu> <3bd412d40903042206xf635b00ocb2ab0f222e40159@mail.gmail.com> Message-ID: <3bd412d40903042245rc971e77gd668e5f292743550@mail.gmail.com> I am confused. Code like this works in other WM, except xmonad. #include int main(int argc, char **argv) { GtkWidget *panel; gtk_init(&argc, &argv); panel = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_type_hint(GTK_WINDOW(panel), GDK_WINDOW_TYPE_HINT_DOCK); gtk_widget_show(panel); gtk_main(); return 0; } And here is my xmonad.hs, which you can see, no "special dock configuration" for xmobar.... import XMonad import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Util.Run(spawnPipe) import XMonad.Util.EZConfig(additionalKeys) import qualified System.IO.UTF8 main = do xmproc <- spawnPipe "xmobar ~/.xmonad/xmobar.config" xmonad $ defaultConfig { terminal = "~/bin/mTerm", borderWidth = 3, normalBorderColor = "#0000ff", focusedBorderColor = "#00ff00", layoutHook = avoidStruts $ layoutHook defaultConfig, logHook = dynamicLogWithPP $ xmobarPP { ppOutput = System.IO.UTF8.hPutStrLn xmproc, ppTitle = xmobarColor "green" "" }, modMask = mod4Mask } `additionalKeys` [ ((mod4Mask, xK_z), spawn "slock") , ((0, xK_Print), spawn "scrot") ] On Thu, Mar 5, 2009 at 2:06 PM, Magicloud Magiclouds wrote: > Since I am using gtk, I set Gdk::Window::TYPE_HINT_DOCK as its > document says. But it does not work. > And as I looked into xmobar's source, there seems no special code for > xmonad. And my xmonad.hs is very simple, too. > So I wonder how to make it work.... > > On Thu, Mar 5, 2009 at 11:59 AM, Brandon S. Allbery KF8NH > wrote: >> On 2009 Mar 4, at 21:40, Magicloud Magiclouds wrote: >>> >>> ?I am using gtk2hs to make some sidebar thing for xmonad. Well, after >>> I tried a few ways, I still cannot make it dock like xmobar. It just >>> covered other windows at the edge of the screen. >>> ?Could someone give me a sample or something I could learn from? Thanks. >> >> >> You need to go to freedesktop.org and read up on the Extended Window Manager >> Hints. ?In this particular case the extension you need is the _NET_WM_STRUT >> property. >> >> (xmobar is open source, you could look through its source) >> >> -- >> 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 frodo at theshire.org Thu Mar 5 04:05:01 2009 From: frodo at theshire.org (Cristiano Paris) Date: Thu Mar 5 03:53:35 2009 Subject: [Haskell-cafe] Re: Zippers In-Reply-To: <2f9b2d30903041800l71753c19p187d17d739275a8b@mail.gmail.com> References: <2f9b2d30903041800l71753c19p187d17d739275a8b@mail.gmail.com> Message-ID: On 3/5/09, Ryan Ingram wrote: > ... > Here is the problem with your "update": > > tree = Fork (Leaf 1) (Leaf 2) > ztree = initZ tree > > test = fromJust $ do > z1 <- moveLeft ztree > let z2 = update z1 3 > z3 <- moveUp z2 > z4 <- moveLeft z3 > this z4 > > I'd expect "test" to equal 3, but I believe with your code that it > still equals 1. As apfelmus said, update needs to completely > re-construct the zipper structure with the tied knot, which defeats > the purpose of using a zipper in the first place. I got it. I dont't know what your expression "tied knot" is referring to but I got the point. Thanks. Cristiano From manlio_perillo at libero.it Thu Mar 5 05:17:45 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Mar 5 05:06:32 2009 Subject: [Haskell-cafe] help optimizing memory usage for a program In-Reply-To: <20090304180010.GD5886@whirlpool.galois.com> References: <49ABFBAB.1050106@libero.it> <20090304180010.GD5886@whirlpool.galois.com> Message-ID: <49AFA6C9.6020702@libero.it> Don Stewart ha scritto: > manlio_perillo: >> Hi. >> >> After some work I have managed to implement two simple programs that >> parse the Netflix Prize data set. >> >> For details about the Netflix Prize, there was a post by Kenneth Hoste >> some time ago. >> >> I have cabalized the program, and made available here: >> http://haskell.mperillo.ath.cx/netflix-0.0.1.tar.gz >> > [...] > > Seems like a useful benchmark of a number of things. Any chance you'll > upload it to hackage? > Not the package as it is now. And I first need to write a program that generates a reasonable data set. But, yes, I will upload it to hackage, if it can be useful. What name should I use? How should I categorize it? Regards Manlio Perillo From apfelmus at quantentunnel.de Thu Mar 5 05:21:11 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Mar 5 05:08:56 2009 Subject: [Haskell-cafe] Re: Zippers In-Reply-To: References: <2f9b2d30903041800l71753c19p187d17d739275a8b@mail.gmail.com> Message-ID: Cristiano Paris wrote: > Ryan Ingram wrote: >> ... >> Here is the problem with your "update": >> >> tree = Fork (Leaf 1) (Leaf 2) >> ztree = initZ tree >> >> test = fromJust $ do >> z1 <- moveLeft ztree >> let z2 = update z1 3 >> z3 <- moveUp z2 >> z4 <- moveLeft z3 >> this z4 >> >> I'd expect "test" to equal 3, but I believe with your code that it >> still equals 1. As apfelmus said, update needs to completely >> re-construct the zipper structure with the tied knot, which defeats >> the purpose of using a zipper in the first place. > > I got it. I dont't know what your expression "tied knot" is referring > to but I got the point. In doInitZ , you're basically using the s itself to define the moveLeft and moveRight fields of s . You could as well write it as initZ t = doInitZ Nothing t where doInitZ c (Leaf a) = ZContext c Nothing Nothing $ Just a doInitZ c t@(Fork l r) = s where s = ZContext c (Just $ doInitZ (Just s) l) (Just $ doInitZ (Just s) r) Nothing Such self-reference is usually called "tying the knot", see also http://www.haskell.org/haskellwiki/Tying_the_Knot Regards, apfelmus -- http://apfelmus.nfshost.com From manlio_perillo at libero.it Thu Mar 5 05:24:34 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Mar 5 05:13:15 2009 Subject: [Haskell-cafe] monadic MapReduce In-Reply-To: <20090302235744.GA22350@amuttreja-dt> References: <49AAD334.9090202@libero.it> <20090301185817.GE15163@raven> <49ABF6F1.60903@libero.it> <20090302235744.GA22350@amuttreja-dt> Message-ID: <49AFA862.7000400@libero.it> Anish Muttreja ha scritto: > [...] > > How about this. Is there a reason why I can't > replace the variables b and c in the type signature of mapReduce with with (IO b') > and (IO c'). b and c can be any types. > > mapReduce :: Strategy (IO b') -- evaluation strategy for mapping > -> (a -> IO b') -- map function > -> Strategy (IO c') -- evaluation strategy for reduction > -> ([IO b'] -> (IO c')) -- reduce function > -> [a] -- list to map over > -> (IO c') > > Just remember to wrap all values back in the IO monad. > The other day I found, with google, a definizion of mapReduce, that make use of forkIO to execute piece of IO actions on separate threads. I can't find it anymore... > Anish > Manlio From frodo at theshire.org Thu Mar 5 06:27:44 2009 From: frodo at theshire.org (Cristiano Paris) Date: Thu Mar 5 06:16:18 2009 Subject: [Haskell-cafe] Re: Zippers In-Reply-To: References: <2f9b2d30903041800l71753c19p187d17d739275a8b@mail.gmail.com> Message-ID: On Thu, Mar 5, 2009 at 11:21 AM, Heinrich Apfelmus wrote: > ... > Such self-reference is usually called "tying the knot", see also > > ?http://www.haskell.org/haskellwiki/Tying_the_Knot I didn't know. Would you call this "Tying the knot" as well? http://yi-editor.blogspot.com/2008/12/prototypes-encoding-oo-style.html Thank you. Cristiano From manlio_perillo at libero.it Thu Mar 5 06:30:13 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Mar 5 06:18:55 2009 Subject: [Haskell-cafe] possible memory leak in uvector 0.1.0.3 In-Reply-To: <1581481873.20090303175347@gmail.com> References: <49AC840C.7060604@libero.it> <1236079848.22402.82.camel@localhost> <49AD200D.5060102@libero.it> <7DD8072CCCD84A96B408871A394A42D8@cr3lt> <49AD4035.6010009@libero.it> <1581481873.20090303175347@gmail.com> Message-ID: <49AFB7C5.6080606@libero.it> Bulat Ziganshin ha scritto: > Hello Manlio, > > Tuesday, March 3, 2009, 5:35:33 PM, you wrote: > >> There are 100,000,000 ratings, so I create 100,000,000 arrays containing >> only one element. > > every array needs ~30 bytes - it's a minimal memory block ghc can > alloc for variable-sized objects. multiple this by 3 to account for > copying GC behavior > Ok, this explains memory usage; thanks. IMHO, this informations should go in the wiki; they may be insignificant for normal applications, but when one starts to deal with huge amount of data, 10 bytes per item make an important difference. Manlio Perillo From alexey.skladnoy at gmail.com Thu Mar 5 06:42:54 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Thu Mar 5 06:31:08 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: <3bd412d40903042245rc971e77gd668e5f292743550@mail.gmail.com> References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> <3bd412d40903042206xf635b00ocb2ab0f222e40159@mail.gmail.com> <3bd412d40903042245rc971e77gd668e5f292743550@mail.gmail.com> Message-ID: <200903051442.54603.alexey.skladnoy@gmail.com> On Thursday 05 March 2009 09:45:51 Magicloud Magiclouds wrote: > I am confused. Code like this works in other WM, except xmonad. You code does not set _NET_WM_STRUT property. And because of that xmonad doesn't treat it specifically. You can inspect you window properties using `xprop' utility. From ndmitchell at gmail.com Thu Mar 5 06:51:35 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Mar 5 06:40:10 2009 Subject: [Haskell-cafe] Data.Binary stack overflow with Data.Sequence String In-Reply-To: References: <3a9962070903032050o4221663y77128df44b5cf965@mail.gmail.com> Message-ID: <404396ef0903050351q3ad4bf5emc26148ae8a30d936@mail.gmail.com> Hi Gwern, I get String/Data.Binary issues too. My suggestion would be to change your strings to ByteString's, serisalise, and then do the reverse conversion when reading. Interestingly, a String and a ByteString have identical Data.Binary reps, but in my experiments converting, including the cost of BS.unpack, makes the reading substantially cheaper. Thanks Neil On Thu, Mar 5, 2009 at 2:33 AM, Gwern Branwen wrote: > On Tue, Mar 3, 2009 at 11:50 PM, Spencer Janssen > wrote: >> On Tue, Mar 3, 2009 at 10:30 PM, Gwern Branwen wrote: >>> So recently I've been having issues with Data.Binary & Data.Sequence; >>> I serialize a 'Seq String' >>> >>> You can see the file here: http://code.haskell.org/yi/Yi/IReader.hs >>> >>> The relevant function seems to be: >>> >>> -- | Read in database from 'dbLocation' and then parse it into an 'ArticleDB'. >>> readDB :: YiM ArticleDB >>> readDB = io $ (dbLocation >>= r) `catch` (\_ -> return empty) >>> ? ? ? ? ?where r x = fmap (decode . BL.fromChunks . return) $ B.readFile x >>> ? ? ? ? ? ? ? ?-- We read in with strict bytestrings to guarantee the >>> file is closed, >>> ? ? ? ? ? ? ? ?-- and then we convert it to the lazy bytestring >>> data.binary expects. >>> ? ? ? ? ? ? ? ?-- This is inefficient, but alas... >>> >>> My current serialized file is about 9.4M. I originally thought that >>> the issue might be the recent upgrade in Yi to binary 0.5, but I >>> unpulled patches back to past that, and the problem still manifested. >>> >>> Whenever yi tries to read the articles.db file, it stack overflows. It >>> actually stack-overflowed on even smaller files, but I managed to bump >>> the size upwards, it seems, by the strict-Bytestring trick. >>> Unfortunately, my personal file has since passed whatever that limit >>> was. >>> >>> I've read carefully the previous threads on Data.Binary and Data.Map >>> stack-overflows, but none of them seem to help; hacking some $!s or >>> seqs into readDB seems to make no difference, and Seq is supposed to >>> be a strict datastructure already! Doing things in GHCi has been >>> tedious, and hasn't enlightened me much: sometimes things overflow and >>> sometimes they don't. It's all very frustrating and I'm seriously >>> considering going back to using the original read/show code unless >>> anyone knows how to fix this - that approach may be many times slower, >>> but I know it will work. >>> >>> -- >>> gwern >> >> Have you tried the darcs version of binary? ?It has a new instance >> which looks more efficient than the old. >> >> >> Cheers, >> Spencer Janssen > > I have. It still stack-overflows on my 9.8 meg file. (The magic number > seems to be somewhere between 9 and 10 megabytes.) > > -- > gwern > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Thu Mar 5 07:09:46 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Mar 5 06:58:21 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: <7ca3f0160903041455r3b54de58wb518833d3d8541c3@mail.gmail.com> References: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> <20090304233801.3048333f@solaris> <7ca3f0160903041455r3b54de58wb518833d3d8541c3@mail.gmail.com> Message-ID: Ha. There's even a wiki page on the paradoxes of set theory http://en.wikipedia.org/wiki/Paradoxes_of_set_theory If I recall correctly, a math professor once told me that it is not yet proven if the cardinality of the power set of the natural numbers is larger or smaller or equal than the cardinality of the real numbers... But that is many many years ago so don't shoot me if I'm wrong :) 2009/3/4 Luke Palmer > On Wed, Mar 4, 2009 at 3:38 PM, Achim Schneider wrote: > >> There's not much to understand about CT, anyway: It's actually nearly >> as trivial as set theory. > > > You mean that theory which predicts the existence of infinitely many > infinities; in fact for any cardinal, there are at least that many > cardinals? That theory in which aleph_1 and 2^aleph_0 are definitely > comparable, but we provably cannot compare them? The theory which has > omega_0 < omega_1 < omega_2 < ... omega_omega < ..., where obviously omega_a > is much larger than a... except for when it catches its tail and omega_alpha > = alpha for some crazy-ass alpha. > > I don't think set theory is trivial in the least. I think it is > complicated, convoluted, often anti-intuitive and nonconstructive. > > Category theory is much more trivial, and that's what makes it powerful. > (Although training yourself to think categorically is quite difficult, I'm > finding) > > > >> One part of the benefit starts when you begin >> to categorise different kind of categories, in the same way that >> understanding monads is easiest if you just consider their difference >> to applicative functors. It's a system inviting you to tackle a problem >> with scrutiny, neither tempting you to generalise way beyond >> computability, nor burdening you with formal proof requirements or >> shackling you to some other ball and chain. >> >> Sadly, almost all texts about CT are absolutely useless: They >> tend to focus either on pure mathematical abstraction, lacking >> applicability, or tell you the story for a particular application of CT >> to a specific topic, loosing themselves in detail without providing the >> bigger picture. That's why I liked that Rosetta stone paper so much: I >> still don't understand anything more about physics, but I see how >> working inside a category with specific features and limitations is the >> exact right thing to do for those guys, and why you wouldn't want to do >> a PL that works in the same category. >> >> >> Throwing lambda calculus at a problem that doesn't happen to be a DSL >> or some other language of some sort is a bad idea. I seem to understand >> that for some time now, being especially fond of automata[1] to model >> autonomous, interacting agents, but CT made me grok it. The future will >> show how far it will pull my thinking out of the Turing tarpit. >> >> >> [1] Which aren't, at all, objects. Finite automata don't go bottom in >> any case, at least not if you don't happen to shoot them and their >> health drops below zero. >> >> -- >> (c) this sig last receiving data processing entity. Inspect headers >> for copyright history. All rights reserved. Copying, hiring, renting, >> performance and/or quoting 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/967aacd5/attachment.htm From daniel.is.fischer at web.de Thu Mar 5 07:29:15 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Mar 5 07:17:53 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: References: <7ca3f0160903041455r3b54de58wb518833d3d8541c3@mail.gmail.com> Message-ID: <200903051329.16143.daniel.is.fischer@web.de> Am Donnerstag, 5. M?rz 2009 13:09 schrieb Peter Verswyvelen: > Ha. There's even a wiki page on the paradoxes of set theory > http://en.wikipedia.org/wiki/Paradoxes_of_set_theory > > If I recall correctly, a math professor once told me that it is not yet > proven if the cardinality of the power set of the natural numbers is larger > or smaller or equal than the cardinality of the real numbers... But that > is many many years ago so don't shoot me if I'm wrong :) > In standard NBG set theory, it is easy to prove that card(P(N)) == card(R). From weilawei at gmail.com Thu Mar 5 07:40:00 2009 From: weilawei at gmail.com (Rob Crowther) Date: Thu Mar 5 07:28:34 2009 Subject: [Haskell-cafe] Finding the Convex Hull (Problem 12 of Real World Haskell) Message-ID: I wrote a "solution" to this problem, but it appears to return incorrect results. There's a pastebin of the code at http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2121 and a picture of the inputs, outputs, and expected results graphed at http://img510.imageshack.us/img510/9971/resultsg.jpg I'm wondering if this is a flaw in my code, my understanding of the problem, or both. Any ideas on how to track this one down would be very much appreciated. Thank you! -- ?(^o^)? -rob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/64212dcd/attachment.htm From marlowsd at gmail.com Thu Mar 5 08:08:09 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Mar 5 07:56:52 2009 Subject: [Haskell-cafe] Re: [Haskell] Lazy IO breaks purity In-Reply-To: References: <20090305021220.7FC65AB11@Adric.metnet.fnmoc.navy.mil> Message-ID: <49AFCEB9.7090008@gmail.com> Lennart Augustsson wrote: > I don't see any breaking of referential transparence in your code. > Every time you do an IO operation the result is basically > non-deterministic since you are talking to the outside world. > You're assuming the IO has some kind of semantics that Haskell makes > no promises about. > > I'm not saying that this isn't a problem, because it is. > But it doesn't break referential transparency, it just makes the > semantics of IO even more complicated. > > (I don't have a formal proof that unsafeInterleaveIO cannot break RT, > but I've not seen an example where it does yet.) So the argument is something like: we can think of the result of a call to unsafeInterleaveIO as having been chosen at the time we called unsafeInterleaveIO, rather than when its result is actually evaluated. This is on dodgy ground, IMO: either you admit that the IO monad contains an Oracle, or you admit it can time-travel. I don't believe in either of those things :-) Cheers, Simon > -- Lennart > > On Thu, Mar 5, 2009 at 2:12 AM, wrote: >> >> We demonstrate how lazy IO breaks referential transparency. A pure >> function of the type Int->Int->Int gives different integers depending >> on the order of evaluation of its arguments. Our Haskell98 code uses >> nothing but the standard input. We conclude that extolling the purity >> of Haskell and advertising lazy IO is inconsistent. >> >> Henning Thielemann wrote on Haskell-Cafe: >>> Say I have a chain of functions: read a file, ... write that to a file, >>> all of these functions are written in a lazy way, which is currently >>> considered good style >> Lazy IO should not be considered good style. One of the common >> definitions of purity is that pure expressions should evaluate to the >> same results regardless of evaluation order, or that equals can be >> substituted for equals. If an expression of the type Int evaluates to >> 1, we should be able to replace every occurrence of the expression with >> 1 without changing the results and other observables. >> >> The expression (read s) where s is the result of the (hGetContents h1) >> action has the pure type, e.g., Int. Yet its evaluation does more than >> just producing an integer: it may also close a file associated with >> the handle h1. Closing the file has an observable effect: the file >> descriptor, which is a scarce resource, is freed. Some OS lock the >> open file, or prevent operations such as renaming and deletion on the >> open file. A file system whose file is open cannot be >> unmounted. Suppose I use an Haskell application such as an editor to >> process data from a removable drive. I mount the drive, tell the >> application the file name. The (still running) application finished >> with the file and displayed the result. And yet I can't unplug the >> removable drive, because it turns out that the final result was >> produced without needing to read all the data from the file, and the >> file remains unclosed. >> >> Some people say: the programmer should have used seq. That is the >> admission of guilt! An expression (read s)::Int that evaluates to 1 is >> equal to 1. So, one should be able substitute (read s) with 1. If the >> result of evaluating 1 turns out not needed for the final outcome, >> then not evaluating (read s) should not affect the outcome. And yet it >> does. One uses seq to force evaluation of an expression even if the >> result may be unused. Thus the expression of a pure type >> has *side-effect*. >> >> The advice about using seq reminds me of advice given to C programmers >> that they should not free a malloc'ed pointer twice, dereference a >> zero pointer and write past the boundary of an array. If lazy IO is >> considered good style given the proper use of seq, then C should be >> considered safe given the proper use of pointers and arrays. >> >> Side affects like closing a file are observable in the external >> world. A program may observe these effects, in an IO monad. One can >> argue there are no guarantees at all about what happens in the IO >> monad. Can side-effects of lazy IO be observable in _pure_ Haskell >> code, in functions with pure type? Yes, they can. The examples are >> depressingly easy to write, once one realizes that reading does have >> side effects, POSIX provides for file descriptor aliasing, and sharing >> becomes observable with side effects. Here is a simple Haskell98 code. >> >> >>> {- Haskell98! -} >>> >>> module Main where >>> >>> import System.IO >>> import System.Posix.IO (fdToHandle, stdInput) >>> >>> -- f1 and f2 are both pure functions, with the pure type. >>> -- Both compute the result of the subtraction e1 - e2. >>> -- The only difference between them is the sequence of >>> -- evaluating their arguments, e1 `seq` e2 vs. e2 `seq` e1 >>> -- For really pure functions, that difference should not be observable >>> >>> f1, f2:: Int -> Int -> Int >>> >>> f1 e1 e2 = e1 `seq` e2 `seq` e1 - e2 >>> f2 e1 e2 = e2 `seq` e1 `seq` e1 - e2 >>> >>> read_int s = read . head . words $ s >>> >>> main = do >>> let h1 = stdin >>> h2 <- fdToHandle stdInput >>> s1 <- hGetContents h1 >>> s2 <- hGetContents h2 >>> print $ f1 (read_int s1) (read_int s2) >>> -- print $ f2 (read_int s1) (read_int s2) >> >> One can compile it with GHC (I used 6.8.2, with and without -O2) and >> run like this >> ~> /tmp/a.out >> 1 >> 2 >> -1 >> That is, we run the program and type 1 and 2 as the inputs. The >> program prints out the result, -1. If we comment out the line >> "print $ f1 (read_int s1) (read_int s2)" and uncomment out the last >> line the transcript looks like this >> ~> /tmp/a.out >> 1 >> 2 >> 1 >> >> Running the code with Hugs exhibits the same behavior. Thus a pure >> function (-) of the pure type gives different results depending on the >> order of evaluating its arguments. >> >> Is 1 = -1? >> >> >> >> >> >> >> _______________________________________________ >> Haskell mailing list >> Haskell@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell >> > _______________________________________________ > Haskell mailing list > Haskell@haskell.org > http://www.haskell.org/mailman/listinfo/haskell From mailing_list at istitutocolli.org Thu Mar 5 08:21:29 2009 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Thu Mar 5 08:10:05 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: <9D7EC421-A962-47C9-B009-BC4401357247@ece.cmu.edu> References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> <9D7EC421-A962-47C9-B009-BC4401357247@ece.cmu.edu> Message-ID: <20090305132129.GA23016@eeepc.nowhere.net> On Wed, Mar 04, 2009 at 10:59:53PM -0500, Brandon S. Allbery KF8NH wrote: > On 2009 Mar 4, at 21:40, Magicloud Magiclouds wrote: >> Could someone give me a sample or something I could learn from? Thanks. > > (xmobar is open source, you could look through its source) xmobar is not open source. xmobar is FREE software! here's the relevant bits (from Xmobar.hs) setProperties :: Rectangle -> Config -> Display -> Window -> [Rectangle] -> IO () setProperties r c d w srs = do a1 <- internAtom d "_NET_WM_STRUT_PARTIAL" False c1 <- internAtom d "CARDINAL" False a2 <- internAtom d "_NET_WM_WINDOW_TYPE" False c2 <- internAtom d "ATOM" False v <- internAtom d "_NET_WM_WINDOW_TYPE_DOCK" False changeProperty32 d w a1 c1 propModeReplace $ map fi $ getStrutValues r (position c) (getRootWindowHeight srs) changeProperty32 d w a2 c2 propModeReplace [fromIntegral v] hope this helps. Best, Andrea From wagner.andrew at gmail.com Thu Mar 5 08:38:32 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Thu Mar 5 08:27:05 2009 Subject: [Haskell-cafe] Finding the Convex Hull (Problem 12 of Real World Haskell) In-Reply-To: References: Message-ID: Whenever I'm looking for a bug in Haskell code, I find it helpful to start by seeing if I can simplify the code any first. In this case, there are a couple of things I notice: - validPointsOf is just a filter. It would be easier to write "valid :: MyDirection -> Bool" and then "validPointsOf = filter (valid . snd)" - Similarly, there's no need to write your own minimum-finder and call it lowestY. Instead, write (or derive!) an Ord instance, and then use the standard prelude function "minimum" - a small simplification of sortByCoTan: sortByCoTan pivot = sortBy (comparing (coTan pivot)) Hope this helps! 2009/3/5 Rob Crowther > I wrote a "solution" to this problem, but it appears to return incorrect > results. There's a pastebin of the code at > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2121 and a picture of the > inputs, outputs, and expected results graphed at > http://img510.imageshack.us/img510/9971/resultsg.jpg > > I'm wondering if this is a flaw in my code, my understanding of the > problem, or both. Any ideas on how to track this one down would be very much > appreciated. > > Thank you! > > -- > ?(^o^)? -rob > > _______________________________________________ > 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/20090305/3ae22521/attachment.htm From haberg at math.su.se Thu Mar 5 08:58:08 2009 From: haberg at math.su.se (Hans Aberg) Date: Thu Mar 5 08:47:00 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: <200903051329.16143.daniel.is.fischer@web.de> References: <7ca3f0160903041455r3b54de58wb518833d3d8541c3@mail.gmail.com> <200903051329.16143.daniel.is.fischer@web.de> Message-ID: On 5 Mar 2009, at 13:29, Daniel Fischer wrote: > In standard NBG set theory, it is easy to prove that card(P(N)) == > card(R). No, it is an axiom: Cohen showed in 1963 (mentioned in Mendelson, "Introduction to Mathematical Logic") that the continuum hypothesis (CH) is independent of NBG+(AC)+(Axiom of Restriction), where AC is the axiom of choice. Thus you can assume CH or its negation (which is intuitively somewhat strange). AC is independent of NGB, so you can assume it or its negation (also intuitively strange), though GHC (generalized CH, for any cardinality) + NBG implies AC (result by Sierpinski 1947 and Specker 1954). GHC says that for any set x, there are no cardinalities between card x and card 2^x (the power-set cardinality). Since card ? < card R by Cantors diagonal method, and card R <= card 2^? since R can be constructed out of binary sequences (and since the interval [0, 1] and R can be shown having the same cardinalities), GHC implies card R = card 2^?. (Here, ? is a lower case omega, denoting the first infinite ordinal.) Hans Aberg From daniel.is.fischer at web.de Thu Mar 5 09:00:00 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Mar 5 08:48:38 2009 Subject: [Haskell-cafe] Finding the Convex Hull (Problem 12 of Real World Haskell) In-Reply-To: References: Message-ID: <200903051500.00200.daniel.is.fischer@web.de> Am Donnerstag, 5. M?rz 2009 13:40 schrieb Rob Crowther: > I wrote a "solution" to this problem, but it appears to return incorrect > results. There's a pastebin of the code at > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2121 and a picture of the > inputs, outputs, and expected results graphed at > http://img510.imageshack.us/img510/9971/resultsg.jpg > > I'm wondering if this is a flaw in my code, my understanding of the > problem, or both. Definitely flawed code, probably based on incorrect understanding of the algorithm. > Any ideas on how to track this one down would be very > much appreciated. To track it down, it would be helpful to look at the intermediate results and see where they differ in what way from your expectations. *ConvexHull> let pointlist :: [Point2D]; pointlist = [(0,0), (2,0), (4,0), (6,0), (5,-2), (5,2), (0,4), (6,4), (5,6)] *ConvexHull> lowestY pointlist (5.0,-2.0) *ConvexHull> sortByCoTan it pointlist [(0.0,0.0),(2.0,0.0),(0.0,4.0),(4.0,0.0),(5.0,2.0),(5.0,6.0),(6.0,4.0),(5.0,-2.0),(6.0,0.0)] *ConvexHull> let sortedpoints = it *ConvexHull> listOfTurns sortedpoints [MyRight,MyLeft,MyRight,MyRight,MyLeft,MyLeft,MyRight] *ConvexHull> zip sortedpoints (MyStraight:MyStraight:it) [((0.0,0.0),MyStraight),((2.0,0.0),MyStraight),((0.0,4.0),MyRight),((4.0,0.0),MyLeft),((5.0,2.0),MyRight),((5.0,6.0),MyRight),((6.0,4.0),MyLeft),((5.0,-2.0),MyLeft),((6.0,0.0),MyRight)] *ConvexHull> validPointsOf it > > Thank you! *ConvexHull> let ly = lowestY pointlist *ConvexHull> coTan ly ly NaN First, you'd want to separate the point with lowest y-coordinate from the rest, like lowestY :: [Point2D] -> (Point2D,[Point2D]) lowestY (x:xs) = foldr update (x,[]) xs where update a (b,cs) = -- left as an exercise Then it might be a good idea to make sortByCoTan insensitive to other points with the same lowest y-coordinate, and of course, sort only the points other than the starting point. Also, the way the points are sorted, you'll walk clockwise around the boundary, so you'd never turn left, only proceed straight or turn right. But the turn at each point does not depend on its neighbours in the list sorted by cotangent, but on which points have so far been chosen, so you have to compute the turn based on that. The selection of points is considerably more complicated than just looking at the turn, consider e.g. [(0,0), (-2,2), (-2,3),(-1,3),(0,4),(1,4),(2,6),(3,9)]. When you have three points a, b and c, and you go from a via b to c, the turn at b is right, iff crossProduct a b c < 0 left, iff crossProduct a b c > 0. HTH, Daniel From daniel.is.fischer at web.de Thu Mar 5 09:12:11 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Mar 5 09:00:48 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: References: <200903051329.16143.daniel.is.fischer@web.de> Message-ID: <200903051512.11611.daniel.is.fischer@web.de> Am Donnerstag, 5. M?rz 2009 14:58 schrieb Hans Aberg: > On 5 Mar 2009, at 13:29, Daniel Fischer wrote: > > In standard NBG set theory, it is easy to prove that card(P(N)) == > > card(R). > > No, it is an axiom: Cohen showed in 1963 (mentioned in Mendelson, > "Introduction to Mathematical Logic") that the continuum hypothesis > (CH) is independent of NBG+(AC)+(Axiom of Restriction), where AC is > the axiom of choice. Yes, but the continuum hypothesis is 2^Aleph_0 == Aleph_1, which is quite something different from 2^Aleph_0 == card(R). You can show the latter easily with the Cantor-Bernstein theorem, independent of CH or AC. > Thus you can assume CH or its negation (which is > intuitively somewhat strange). AC is independent of NGB, so you can > assume it or its negation (also intuitively strange), though GHC > (generalized CH, for any cardinality) + NBG implies AC (result by > Sierpinski 1947 and Specker 1954). GHC says that for any set x, there > are no cardinalities between card x and card 2^x (the power-set > cardinality). Since card ? < card R by Cantors diagonal method, and > card R <= card 2^? since R can be constructed out of binary sequences > (and since the interval [0, 1] and R can be shown having the same > cardinalities), GHC implies card R = card 2^?. (Here, ? is a lower > case omega, denoting the first infinite ordinal.) > > Hans Aberg From colinpauladams at googlemail.com Thu Mar 5 09:17:52 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Thu Mar 5 09:06:27 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: References: <7ca3f0160903041455r3b54de58wb518833d3d8541c3@mail.gmail.com> <200903051329.16143.daniel.is.fischer@web.de> Message-ID: <1afdeaec0903050617j4ccc6adboc7b75b7655ff4607@mail.gmail.com> 2009/3/5 Hans Aberg : > GHC says that for any set x, there are no cardinalities between card x and No it doesn't. It says there is a syntax error in my code. From daniel.is.fischer at web.de Thu Mar 5 09:23:34 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Mar 5 09:12:09 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: <200903051512.11611.daniel.is.fischer@web.de> References: <200903051512.11611.daniel.is.fischer@web.de> Message-ID: <200903051523.34280.daniel.is.fischer@web.de> Am Donnerstag, 5. M?rz 2009 15:12 schrieb Daniel Fischer: > Yes, but the continuum hypothesis is 2^Aleph_0 == Aleph_1, which is quite > something different from 2^Aleph_0 == card(R). > > You can show the latter easily with the Cantor-Bernstein theorem, > independent of CH or AC. Just to flesh this up a bit: let f : P(N) -> R be given by f(M) = sum [2*3^(-k) | k <- M ] f is easily seen to be injective. define g : (0,1) -> P(N) by let x = sum [a_k*2^(-k) | k in N (\{0}), a_k in {0,1}, infinitely many a_k = 1] and then g(x) = {k | a_k = 1} again clearly g is an injection. Now the Cantor-Bernstein theorem asserts there is a bijection between the two sets. From haberg at math.su.se Thu Mar 5 09:48:58 2009 From: haberg at math.su.se (Hans Aberg) Date: Thu Mar 5 09:37:41 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: <200903051512.11611.daniel.is.fischer@web.de> References: <200903051329.16143.daniel.is.fischer@web.de> <200903051512.11611.daniel.is.fischer@web.de> Message-ID: <9F0054A9-AF53-4EDF-97E2-E6A6544BFAEB@math.su.se> On 5 Mar 2009, at 15:12, Daniel Fischer wrote: >> No, it is an axiom: Cohen showed in 1963 (mentioned in Mendelson, >> "Introduction to Mathematical Logic") that the continuum hypothesis >> (CH) is independent of NBG+(AC)+(Axiom of Restriction), where AC is >> the axiom of choice. > > Yes, but the continuum hypothesis is 2^Aleph_0 == Aleph_1, which is > quite > something different from 2^Aleph_0 == card(R). Yes, right, card R = 2^Aleph_0, as you said, and Aleph_1 is defined as the smallest cardinal greater than Aleph_0. Hans Aberg From manlio_perillo at libero.it Thu Mar 5 09:54:07 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Mar 5 09:42:46 2009 Subject: [Haskell-cafe] missing support to Data.Binary for uvector package Message-ID: <49AFE78F.9010707@libero.it> Hi. I'm still having problems with the uvector package. I have an IntMap (UArr xxx) data type, and I want to serialize it to disk, in binary format. I'm using the uvector package from http://patch-tag.com/repo/pumpkin-uvector/home The problem is with missing instance declarations, for Hyperstrict data type and Data.Array.Vector.UArr.UPrim. For the former, the instance is simple, but for the latter I have no idea about what to do. The full error message (GHC 6.8.2): No instance for (uvector-0.2:Data.Array.Vector.UArr.UPrim (Word32 uvector-0.2:Data.Array.Vector.Prim.Hyperstrict.:*: Word8)) arising from a use of `encode' at bin/process-data-1.hs:72:18-36 Possible fix: add an instance declaration for (uvector-0.2:Data.Array.Vector.UArr.UPrim (Word32 uvector-0.2:Data.Array.Vector.Prim.Hyperstrict.:*: Word8)) Thanks Manlio Perillo From lennart at augustsson.net Thu Mar 5 09:58:03 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Mar 5 09:46:38 2009 Subject: [Haskell-cafe] Re: [Haskell] Lazy IO breaks purity In-Reply-To: <49AFCEB9.7090008@gmail.com> References: <20090305021220.7FC65AB11@Adric.metnet.fnmoc.navy.mil> <49AFCEB9.7090008@gmail.com> Message-ID: You're assuming that IO operations have semantics. >From the Haskell program's point of view, and when reasoning about Haskell programs (not their interaction with the world) you should assume that every IO operation returns a random result. The way Oleg's program behaves does not break RT under the random result assumption. What could break RT is if you could do this f :: Int -> Int <- someIOoperation let x = f 0; y = f 0 and end up with x and y not being equal. It's (of course) easy to construct someIOoperation that has this behaviour (using FFI), but I don't think you can construct it just using the normal IO operations and unsafeInterleaveIO. But as I said, I think this is a problem anyway, because IO without semantics is rather useless. -- Lennart On Thu, Mar 5, 2009 at 1:08 PM, Simon Marlow wrote: > Lennart Augustsson wrote: >> >> I don't see any breaking of referential transparence in your code. >> Every time you do an IO operation the result is basically >> non-deterministic since you are talking to the outside world. >> You're assuming the IO has some kind of semantics that Haskell makes >> no promises about. >> >> I'm not saying that this isn't a problem, because it is. >> But it doesn't break referential transparency, it just makes the >> semantics of IO even more complicated. >> >> (I don't have a formal proof that unsafeInterleaveIO cannot break RT, >> but I've not seen an example where it does yet.) > > So the argument is something like: we can think of the result of a call to > unsafeInterleaveIO as having been chosen at the time we called > unsafeInterleaveIO, rather than when its result is actually evaluated. This > is on dodgy ground, IMO: either you admit that the IO monad contains an > Oracle, or you admit it can time-travel. ? I don't believe in either of > those things :-) > > Cheers, > ? ? ? ?Simon > >> ?-- Lennart >> >> On Thu, Mar 5, 2009 at 2:12 AM, ? wrote: >>> >>> We demonstrate how lazy IO breaks referential transparency. ?A pure >>> function of the type Int->Int->Int gives different integers depending >>> on the order of evaluation of its arguments. Our Haskell98 code uses >>> nothing but the standard input. ?We conclude that extolling the purity >>> of Haskell and advertising lazy IO is inconsistent. >>> >>> Henning Thielemann wrote on Haskell-Cafe: >>>> >>>> Say I have a chain of functions: read a file, ... write that to a file, >>>> all of these functions are written in a lazy way, which is currently >>>> considered good style >>> >>> Lazy IO should not be considered good style. One of the common >>> definitions of purity is that pure expressions should evaluate to the >>> same results regardless of evaluation order, or that equals can be >>> substituted for equals. If an expression of the type Int evaluates to >>> 1, we should be able to replace every occurrence of the expression with >>> 1 without changing the results and other observables. >>> >>> The expression (read s) where s is the result of the (hGetContents h1) >>> action has the pure type, e.g., Int. Yet its evaluation does more than >>> just producing an integer: it may also close a file associated with >>> the handle h1. Closing the file has an observable effect: the file >>> descriptor, which is a scarce resource, is freed. Some OS lock the >>> open file, or prevent operations such as renaming and deletion on the >>> open file. A file system whose file is open cannot be >>> unmounted. Suppose I use an Haskell application such as an editor to >>> process data from a removable drive. I mount the drive, tell the >>> application the file name. The (still running) application finished >>> with the file and displayed the result. And yet I can't unplug the >>> removable drive, because it turns out that the final result was >>> produced without needing to read all the data from the file, and the >>> file remains unclosed. >>> >>> Some people say: the programmer should have used seq. That is the >>> admission of guilt! An expression (read s)::Int that evaluates to 1 is >>> equal to 1. So, one should be able substitute (read s) with 1. If the >>> result of evaluating 1 turns out not needed for the final outcome, >>> then not evaluating (read s) should not affect the outcome. And yet it >>> does. One uses seq to force evaluation of an expression even if the >>> result may be unused. Thus the expression of a pure type >>> has *side-effect*. >>> >>> The advice about using seq reminds me of advice given to C programmers >>> that they should not free a malloc'ed pointer twice, dereference a >>> zero pointer and write past the boundary of an array. If lazy IO is >>> considered good style given the proper use of seq, then C should be >>> considered safe given the proper use of pointers and arrays. >>> >>> Side affects like closing a file are observable in the external >>> world. A program may observe these effects, in an IO monad. One can >>> argue there are no guarantees at all about what happens in the IO >>> monad. Can side-effects of lazy IO be observable in _pure_ Haskell >>> code, in functions with pure type? Yes, they can. The examples are >>> depressingly easy to write, once one realizes that reading does have >>> side effects, POSIX provides for file descriptor aliasing, and sharing >>> becomes observable with side effects. Here is a simple Haskell98 code. >>> >>> >>>> {- Haskell98! -} >>>> >>>> module Main where >>>> >>>> import System.IO >>>> import System.Posix.IO (fdToHandle, stdInput) >>>> >>>> -- f1 and f2 are both pure functions, with the pure type. >>>> -- Both compute the result of the subtraction e1 - e2. >>>> -- The only difference between them is the sequence of >>>> -- evaluating their arguments, e1 `seq` e2 vs. e2 `seq` e1 >>>> -- For really pure functions, that difference should not be observable >>>> >>>> f1, f2:: Int -> Int -> Int >>>> >>>> f1 e1 e2 = e1 `seq` e2 `seq` e1 - e2 >>>> f2 e1 e2 = e2 `seq` e1 `seq` e1 - e2 >>>> >>>> read_int s = read . head . words $ s >>>> >>>> main = do >>>> ? ? ? let h1 = stdin >>>> ? ? ? h2 <- fdToHandle stdInput >>>> ? ? ? s1 <- hGetContents h1 >>>> ? ? ? s2 <- hGetContents h2 >>>> ? ? ? print $ f1 (read_int s1) (read_int s2) >>>> ? ? ? -- print $ f2 (read_int s1) (read_int s2) >>> >>> One can compile it with GHC (I used 6.8.2, with and without -O2) and >>> run like this >>> ?~> /tmp/a.out >>> ?1 >>> ?2 >>> ?-1 >>> That is, we run the program and type 1 and 2 as the inputs. The >>> program prints out the result, -1. If we comment out the line >>> "print $ f1 (read_int s1) (read_int s2)" and uncomment out the last >>> line the transcript looks like this >>> ?~> /tmp/a.out >>> ?1 >>> ?2 >>> ?1 >>> >>> Running the code with Hugs exhibits the same behavior. Thus a pure >>> function (-) of the pure type gives different results depending on the >>> order of evaluating its arguments. >>> >>> ? ? ? Is 1 = -1? >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Haskell mailing list >>> Haskell@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell >>> >> _______________________________________________ >> Haskell mailing list >> Haskell@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From haberg at math.su.se Thu Mar 5 10:55:30 2009 From: haberg at math.su.se (Hans Aberg) Date: Thu Mar 5 10:44:08 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: <200903051523.34280.daniel.is.fischer@web.de> References: <200903051512.11611.daniel.is.fischer@web.de> <200903051523.34280.daniel.is.fischer@web.de> Message-ID: On 5 Mar 2009, at 15:23, Daniel Fischer wrote: > Just to flesh this up a bit: > > let f : P(N) -> R be given by f(M) = sum [2*3^(-k) | k <- M ] > f is easily seen to be injective. > > define g : (0,1) -> P(N) by > let x = sum [a_k*2^(-k) | k in N (\{0}), a_k in {0,1}, infinitely > many a_k = > 1] > and then g(x) = {k | a_k = 1} > > again clearly g is an injection. > Now the Cantor-Bernstein theorem asserts there is a bijection > between the two > sets. I think one just defines an equivalence relation of elements mapped to each other by a finite number of iterations of f o g and g o f. The equivalence classes are then at most countable. So one can set up a bijection on each equivalence class: easy for at most countable sets. Then paste it together. The axiom of choice probably implicit here. Hans Aberg From jonathanccast at fastmail.fm Thu Mar 5 11:05:38 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Mar 5 10:54:14 2009 Subject: [Haskell-cafe] Re: [Haskell] Lazy IO breaks purity In-Reply-To: <49AFCEB9.7090008@gmail.com> References: <20090305021220.7FC65AB11@Adric.metnet.fnmoc.navy.mil> <49AFCEB9.7090008@gmail.com> Message-ID: <1236269138.6328.0.camel@jonathans-macbook> On Thu, 2009-03-05 at 13:08 +0000, Simon Marlow wrote: > Lennart Augustsson wrote: > > I don't see any breaking of referential transparence in your code. > > Every time you do an IO operation the result is basically > > non-deterministic since you are talking to the outside world. > > You're assuming the IO has some kind of semantics that Haskell makes > > no promises about. > > > > I'm not saying that this isn't a problem, because it is. > > But it doesn't break referential transparency, it just makes the > > semantics of IO even more complicated. > > > > (I don't have a formal proof that unsafeInterleaveIO cannot break RT, > > but I've not seen an example where it does yet.) > > So the argument is something like: we can think of the result of a call to > unsafeInterleaveIO as having been chosen at the time we called > unsafeInterleaveIO, rather than when its result is actually evaluated. > This is on dodgy ground, IMO: either you admit that the IO monad contains > an Oracle, or you admit it can time-travel. I don't believe in either of > those things :-) That's the charm of denotational semantics --- you're outside the laws of physics. jcc From daniel.is.fischer at web.de Thu Mar 5 11:06:12 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Mar 5 10:54:48 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: References: <200903051523.34280.daniel.is.fischer@web.de> Message-ID: <200903051706.12862.daniel.is.fischer@web.de> Am Donnerstag, 5. M?rz 2009 16:55 schrieb Hans Aberg: > On 5 Mar 2009, at 15:23, Daniel Fischer wrote: > > Just to flesh this up a bit: > > > > let f : P(N) -> R be given by f(M) = sum [2*3^(-k) | k <- M ] > > f is easily seen to be injective. > > > > define g : (0,1) -> P(N) by > > let x = sum [a_k*2^(-k) | k in N (\{0}), a_k in {0,1}, infinitely > > many a_k = > > 1] > > and then g(x) = {k | a_k = 1} > > > > again clearly g is an injection. > > Now the Cantor-Bernstein theorem asserts there is a bijection > > between the two > > sets. > > I think one just defines an equivalence relation of elements mapped to > each other by a finite number of iterations of f o g and g o f. The > equivalence classes are then at most countable. So one can set up a > bijection on each equivalence class: easy for at most countable sets. > Then paste it together. The axiom of choice probably implicit here. Cantor-Bernstein doesn't require choice (may be different for intuitionists). http://en.wikipedia.org/wiki/Cantor-Bernstein_theorem > > Hans Aberg Cheers, Daniel From svein.ove at aas.no Thu Mar 5 11:13:10 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Thu Mar 5 11:01:45 2009 Subject: [Haskell-cafe] Re: [Haskell] Lazy IO breaks purity In-Reply-To: <221b53ab0903050812k43d7ac05hac6ae68f2abce6e6@mail.gmail.com> References: <20090305021220.7FC65AB11@Adric.metnet.fnmoc.navy.mil> <49AFCEB9.7090008@gmail.com> <221b53ab0903050812k43d7ac05hac6ae68f2abce6e6@mail.gmail.com> Message-ID: <221b53ab0903050813p66d4baecmfd4b97ef31f7745c@mail.gmail.com> On Thu, Mar 5, 2009 at 2:08 PM, Simon Marlow wrote: > > So the argument is something like: we can think of the result of a call to > unsafeInterleaveIO as having been chosen at the time we called > unsafeInterleaveIO, rather than when its result is actually evaluated. This > is on dodgy ground, IMO: either you admit that the IO monad contains an > Oracle, or you admit it can time-travel. ? I don't believe in either of > those things :-) > As it turns out, time-travel as a vehicle for computation has a long tradition in the more advanced systems; see http://www.frc.ri.cmu.edu/~hpm/project.archive/general.articles/1991/TempComp.html for an example. From haberg at math.su.se Thu Mar 5 12:05:36 2009 From: haberg at math.su.se (Hans Aberg) Date: Thu Mar 5 11:54:15 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions In-Reply-To: <200903051706.12862.daniel.is.fischer@web.de> References: <200903051523.34280.daniel.is.fischer@web.de> <200903051706.12862.daniel.is.fischer@web.de> Message-ID: On 5 Mar 2009, at 17:06, Daniel Fischer wrote: > Cantor-Bernstein doesn't require choice (may be different for > intuitionists). > http://en.wikipedia.org/wiki/Cantor-Bernstein_theorem Yes, that is right, Mendelson says that. - I find it hard to figure out when it is used, as it is so intuitive. Mendelson says AC is in fact equivalent proving all x, y: card x <= card y or card y <= card x Hans Aberg From pumpkingod at gmail.com Thu Mar 5 12:39:53 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Thu Mar 5 12:28:26 2009 Subject: [Haskell-cafe] missing support to Data.Binary for uvector package In-Reply-To: <49AFE78F.9010707@libero.it> References: <49AFE78F.9010707@libero.it> Message-ID: Hi Manlio, I'm not sure the whole list wants to hear about bugs in my modifications to an alpha library! :-) But basically, I haven't added a Binary instance for productions like that yet. This isn't trivial, but shouldn't be hard. Otherwise, using the unsafe serialization functions I provide in that same module might give you better luck (at the cost of some safety). But uvector, no matter how awesome the fusion work Don and others did on it, is definitely not "finished" yet. Be prepared to hack a lot (and maybe crash a fair amount) if you want to use it. Hope this helps, Dan On Thu, Mar 5, 2009 at 9:54 AM, Manlio Perillo wrote: > Hi. > > I'm still having problems with the uvector package. > > > I have an IntMap (UArr xxx) data type, and I want to serialize it to disk, > in binary format. > > I'm using the uvector package from > http://patch-tag.com/repo/pumpkin-uvector/home > > > The problem is with missing instance declarations, for Hyperstrict data type > and Data.Array.Vector.UArr.UPrim. > > > For the former, the instance is simple, but for the latter I have no idea > about what to do. > > The full error message (GHC 6.8.2): > > ? ?No instance for (uvector-0.2:Data.Array.Vector.UArr.UPrim > ? ? ? ? ? ? ? ? ? ? ? (Word32 > uvector-0.2:Data.Array.Vector.Prim.Hyperstrict.:*: Word8)) > ? ? ?arising from a use of `encode' at bin/process-data-1.hs:72:18-36 > ? ?Possible fix: > ? ? ?add an instance declaration for > ? ? ?(uvector-0.2:Data.Array.Vector.UArr.UPrim > ? ? ? ? (Word32 uvector-0.2:Data.Array.Vector.Prim.Hyperstrict.:*: Word8)) > > > Thanks ?Manlio Perillo > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dev at mobileink.com Thu Mar 5 12:45:38 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Thu Mar 5 12:34:11 2009 Subject: [Haskell-cafe] Re: [Haskell] Lazy IO breaks purity In-Reply-To: <49AFCEB9.7090008@gmail.com> References: <20090305021220.7FC65AB11@Adric.metnet.fnmoc.navy.mil> <49AFCEB9.7090008@gmail.com> Message-ID: <75cc17ac0903050945t60a0e159of111c3fbead090be@mail.gmail.com> On Thu, Mar 5, 2009 at 7:08 AM, Simon Marlow wrote: > > So the argument is something like: we can think of the result of a call to > unsafeInterleaveIO as having been chosen at the time we called > unsafeInterleaveIO, rather than when its result is actually evaluated. This > is on dodgy ground, IMO: either you admit that the IO monad contains an > Oracle, or you admit it can time-travel. I don't believe in either of > those things :-) > > Surely there's a quantum mechanical metaphor waiting to happen here. getCat :: IO Cat If "getCat" appears in a program text, does it denote or not? Or both? If it does, is the cat alive or dead? (Apologies to Schrodinger). -gregg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/c3fac11a/attachment.htm From allbery at ece.cmu.edu Thu Mar 5 12:50:20 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Mar 5 12:39:12 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: <20090305132129.GA23016@eeepc.nowhere.net> References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> <9D7EC421-A962-47C9-B009-BC4401357247@ece.cmu.edu> <20090305132129.GA23016@eeepc.nowhere.net> Message-ID: On 2009 Mar 5, at 8:21, Andrea Rossato wrote: > On Wed, Mar 04, 2009 at 10:59:53PM -0500, Brandon S. Allbery KF8NH > wrote: >> On 2009 Mar 4, at 21:40, Magicloud Magiclouds wrote: >>> Could someone give me a sample or something I could learn from? >>> Thanks. >> >> (xmobar is open source, you could look through its source) > > xmobar is not open source. xmobar is FREE software! I don't do fundamentalist religion... -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/01444edb/PGP.bin From fft1976 at gmail.com Thu Mar 5 13:43:45 2009 From: fft1976 at gmail.com (FFT) Date: Thu Mar 5 13:32:21 2009 Subject: [Haskell-cafe] Re: MPI In-Reply-To: References: Message-ID: On Wed, Mar 4, 2009 at 5:03 PM, FFT wrote: > Are MPI bindings still the best way of using Haskell on Beowulf > clusters? It's my feeling that the bindings stagnated, or are they > just very mature? What's the story with distributed memory multiprocessing? Are Haskell programmers uninterested in it, or are things other than MPI used with it? From anishmuttreja at gmail.com Thu Mar 5 13:48:27 2009 From: anishmuttreja at gmail.com (Anish Muttreja) Date: Thu Mar 5 13:36:22 2009 Subject: [Haskell-cafe] monadic MapReduce In-Reply-To: References: <49AAD334.9090202@libero.it> <20090301185817.GE15163@raven> <49ABF6F1.60903@libero.it> <20090302235744.GA22350@amuttreja-dt> Message-ID: <20090305184826.GA23065@amuttreja-dt> On Tue, Mar 03, 2009 at 07:27:35AM -1000, Tim Newsham wrote: >> How about this. Is there a reason why I can't >> replace the variables b and c in the type signature of mapReduce with with (IO b') >> and (IO c'). b and c can be any types. >> >> mapReduce :: Strategy (IO b') -- evaluation strategy for mapping >> -> (a -> IO b') -- map function >> -> Strategy (IO c') -- evaluation strategy for reduction >> -> ([IO b'] -> (IO c')) -- reduce function >> -> [a] -- list to map over >> -> (IO c') >> >> Just remember to wrap all values back in the IO monad. > > Remember, the idea of map-reduce is to provide a very restrictive > programming interface so that you have a lot of flexibility in > your execution strategy. If you start loosening the interface > you will still be able to execute the program, but you may > not be able to perform all the great optimizations you want to > perform. For example, if you are using IO actions that are > stateful, what are the semantics? Can one map action affect > other map actions? Does this imply an ordering of the map functions? > Does this imply they all run on the same machine or at least have > state communicated between the machines on which they run? Yes, IO actions in mapReduce will introduce all these questions. I thought Manlio's example was a case where the IO actions consist only of reading an entire file into a string and no ordering or dependence between map actions is implied. I have a similar application where this, unsafe as it is, might be useful. I need to read in a large number of CSV files, with numeric columns, and group columns with high correlation together. I have yet to try my own suggestion though. I have tried the first approach I suggested, read in the contents into strings and work with the normal map-reduce. That does keep the handles open till map-reduce is done. > The austere interface precludes any of these issues, and therein > lies the beauty. > >> Anish > > Btw. I prefer the sawzall formulation over the map-reduce formulation. > A sawzall program just specifies how to map some data to a monoid > and the system is free to mappend the monoid values in whatever order > it wants (by applying associativity). Thanks for the tip, I wasn't aware of this. At least in the map-reduce formulation in this thread, the fold is completely specified by the user and not optimized further. So the sawazall formulation seems promising, because sometimes the fold action is more expensive than the map action. And while we are talking about different formulations, the code here http://article.gmane.org/gmane.comp.lang.haskell.cafe/41944 splits the list of operands into chunks and does the fold action in parallel on each chunk. This actually works well for me, though I find the semantics a little hard to remember. Anish > Tim Newsham > http://www.thenewsh.com/~newsham/ From jfredett at gmail.com Thu Mar 5 13:48:29 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Thu Mar 5 13:37:06 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue Message-ID: <49B01E7D.6000207@gmail.com> I've been working on a little project, and one of the things I need to do is dynamically compile and import a Haskell Source file containing filtering definitions. I've written a small monad called Filter which is simply: type Filter a = Reader (Config, Email) a To encompass all the email filtering. The method I need to import, filterMain, has type: filterMain :: Deliverable a => Filter a where Deliverable is a type class which abstracts over delivery to a path in the file system. The notion is that I can write a type like: data DEmail = {email :: Email, path :: FilePath} newtype Maildir = MD DEmail instance Deliverable Maildir where {- ... omitted -} However, Filter a should not be restricted to Deliverable types- it also encompasses the results of regular expression matching, etc, which are not -- in general -- Deliverable instances. My question is this, when importing the file containing the definitions of filterMain, I have the following code to grab filterMain and return it as a function. getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter a) getFilterMain fMainLoc = do loadModules [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] fMain <- (interpret "(filterMain)" (as :: Deliverable a => Filter a)) return (fMain) However, when I try to compile this, I get the type error: Hackmain.hs:70:43: Ambiguous type variable `a' in the constraint: `Deliverable a' arising from a use of `getFilterMainStuff' at Hackmain.hs:70:43-60 Probable fix: add a type signature that fixes these type variable(s) My understanding is that a type like "Foo a => Bar a" (where Foo is a class and Bar is a datatype) would simply restrict the values of a to only those implementing Foo. But evidently I'm wrong. Is there a good (read, easy... :) ) fix to this? Any help would be greatly appreciated. /Joe PS. All the actual code is on patch-tag, here http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to look at that directly, the relevant files are in Src, namely, Hackmain.hs, Filter.hs, and Deliverable.hs -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/d67072c5/jfredett.vcf From anishmuttreja at gmail.com Thu Mar 5 13:56:42 2009 From: anishmuttreja at gmail.com (Anish Muttreja) Date: Thu Mar 5 13:44:33 2009 Subject: [Haskell-cafe] Test if a file is empty or stat in haskell Message-ID: <20090305185642.GB23065@amuttreja-dt> I am looking for a way to test if a file is empty. Something like isFileEmpty along the lines of System.Directory.doesFileExist? A function that wraps stat would also serve the purpose. I get the feeling that someone must have felt the need for this before me, but Google search not yield anything, hence the question. Thanks! Anish From daniel.is.fischer at web.de Thu Mar 5 14:04:04 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Mar 5 13:52:39 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: <49B01E7D.6000207@gmail.com> References: <49B01E7D.6000207@gmail.com> Message-ID: <200903052004.04379.daniel.is.fischer@web.de> Am Donnerstag, 5. M?rz 2009 19:48 schrieb Joseph Fredette: > > getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter > a) > getFilterMain fMainLoc = > do > loadModules [fMainLoc]; setTopLevelModules [(takeWhile > (/='.') fMainLoc)] > fMain <- (interpret "(filterMain)" (as :: Deliverable a => > Filter a)) Without looking at more code, the type variable a here is a fresh type variable, not the one from getFilterMain's signature. > return > (fMain) Maybe bringing the type variable a into scope in the function body by {-# LANGUAGE ScopedTypeVariables #-} getFilterMain :: forall a. Deliverable a => FilePath -> Interpreter (Filter, a) would suffice. > > > However, when I try to compile this, I get the type error: > > Hackmain.hs:70:43: > Ambiguous type variable `a' in the constraint: > `Deliverable a' > arising from a use of `getFilterMainStuff' at > Hackmain.hs:70:43-60 > Probable fix: add a type signature that fixes these type > variable(s) > > My understanding is that a type like "Foo a => Bar a" (where Foo is a > class and Bar is a datatype) would simply restrict > the values of a to only those implementing Foo. But evidently I'm wrong. > Is there a good (read, easy... :) ) fix to this? > > Any help would be greatly appreciated. > > /Joe > > PS. All the actual code is on patch-tag, here > http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to look at > that directly, the relevant files are in Src, namely, Hackmain.hs, > Filter.hs, and Deliverable.hs From daniel.is.fischer at web.de Thu Mar 5 14:15:03 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Mar 5 14:03:37 2009 Subject: [Haskell-cafe] Test if a file is empty or stat in haskell In-Reply-To: <20090305185642.GB23065@amuttreja-dt> References: <20090305185642.GB23065@amuttreja-dt> Message-ID: <200903052015.03294.daniel.is.fischer@web.de> Am Donnerstag, 5. M?rz 2009 19:56 schrieb Anish Muttreja: > I am looking for a way to test if a file is empty. > Something like isFileEmpty along the lines of > System.Directory.doesFileExist? If you're on a *nixy OS, System.Posix.Files getFileStatus, fileSize ... dunno if Windows has similar functionality. > > A function that wraps stat would also serve the purpose. > I get the feeling that someone must have felt the need for this before > me, but Google search not yield anything, hence the question. > > Thanks! > Anish From hjgtuyl at chello.nl Thu Mar 5 14:20:23 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Thu Mar 5 14:09:04 2009 Subject: [Haskell-cafe] Test if a file is empty or stat in haskell In-Reply-To: <20090305185642.GB23065@amuttreja-dt> References: <20090305185642.GB23065@amuttreja-dt> Message-ID: On Thu, 05 Mar 2009 19:56:42 +0100, Anish Muttreja wrote: > I am looking for a way to test if a file is empty. > Something like isFileEmpty along the lines of > System.Directory.doesFileExist? > > A function that wraps stat would also serve the purpose. > I get the feeling that someone must have felt the need for this before > me, but Google search not yield anything, hence the question. > > Thanks! > Anish Searching for "size" with Hoogle lead me to System.IO.hFileSize: hFileSize :: Handle -> IO Integer For a handle hdl which attached to a physical file, hFileSize hdl returns the size of that file in 8-bit bytes. -- Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From anishmuttreja at gmail.com Thu Mar 5 14:24:46 2009 From: anishmuttreja at gmail.com (Anish Muttreja) Date: Thu Mar 5 14:12:37 2009 Subject: [Haskell-cafe] Test if a file is empty or stat in haskell In-Reply-To: <200903052015.03294.daniel.is.fischer@web.de> References: <20090305185642.GB23065@amuttreja-dt> <200903052015.03294.daniel.is.fischer@web.de> Message-ID: <20090305192446.GA23662@amuttreja-dt> On Thu, Mar 05, 2009 at 08:15:03PM +0100, Daniel Fischer wrote: > Am Donnerstag, 5. M?rz 2009 19:56 schrieb Anish Muttreja: > > I am looking for a way to test if a file is empty. > > Something like isFileEmpty along the lines of > > System.Directory.doesFileExist? > > If you're on a *nixy OS, > System.Posix.Files > > getFileStatus, fileSize ... Great, thanks. > dunno if Windows has similar functionality. I am on Linux. BTW, Hoogle does not seem to know about System.Posix.Files, though it did point me to System.IO.FileSize which would also have served the purpose. http://www.haskell.org/hoogle/?hoogle=fileSize Thanks, Anish > > > > > A function that wraps stat would also serve the purpose. > > I get the feeling that someone must have felt the need for this before > > me, but Google search not yield anything, hence the question. > > > > Thanks! > > Anish > From dons at galois.com Thu Mar 5 14:35:43 2009 From: dons at galois.com (Don Stewart) Date: Thu Mar 5 14:25:09 2009 Subject: [Haskell-cafe] Data.Binary stack overflow with Data.Sequence String In-Reply-To: <404396ef0903050351q3ad4bf5emc26148ae8a30d936@mail.gmail.com> References: <3a9962070903032050o4221663y77128df44b5cf965@mail.gmail.com> <404396ef0903050351q3ad4bf5emc26148ae8a30d936@mail.gmail.com> Message-ID: <20090305193543.GF11109@whirlpool.galois.com> Avoid unpack! ndmitchell: > Hi Gwern, > > I get String/Data.Binary issues too. My suggestion would be to change > your strings to ByteString's, serisalise, and then do the reverse > conversion when reading. Interestingly, a String and a ByteString have > identical Data.Binary reps, but in my experiments converting, > including the cost of BS.unpack, makes the reading substantially > cheaper. > > Thanks > > Neil > > On Thu, Mar 5, 2009 at 2:33 AM, Gwern Branwen wrote: > > On Tue, Mar 3, 2009 at 11:50 PM, Spencer Janssen > > wrote: > >> On Tue, Mar 3, 2009 at 10:30 PM, Gwern Branwen wrote: > >>> So recently I've been having issues with Data.Binary & Data.Sequence; > >>> I serialize a 'Seq String' > >>> > >>> You can see the file here: http://code.haskell.org/yi/Yi/IReader.hs > >>> > >>> The relevant function seems to be: > >>> > >>> -- | Read in database from 'dbLocation' and then parse it into an 'ArticleDB'. > >>> readDB :: YiM ArticleDB > >>> readDB = io $ (dbLocation >>= r) `catch` (\_ -> return empty) > >>> ? ? ? ? ?where r x = fmap (decode . BL.fromChunks . return) $ B.readFile x > >>> ? ? ? ? ? ? ? ?-- We read in with strict bytestrings to guarantee the > >>> file is closed, > >>> ? ? ? ? ? ? ? ?-- and then we convert it to the lazy bytestring > >>> data.binary expects. > >>> ? ? ? ? ? ? ? ?-- This is inefficient, but alas... > >>> > >>> My current serialized file is about 9.4M. I originally thought that > >>> the issue might be the recent upgrade in Yi to binary 0.5, but I > >>> unpulled patches back to past that, and the problem still manifested. > >>> > >>> Whenever yi tries to read the articles.db file, it stack overflows. It > >>> actually stack-overflowed on even smaller files, but I managed to bump > >>> the size upwards, it seems, by the strict-Bytestring trick. > >>> Unfortunately, my personal file has since passed whatever that limit > >>> was. > >>> > >>> I've read carefully the previous threads on Data.Binary and Data.Map > >>> stack-overflows, but none of them seem to help; hacking some $!s or > >>> seqs into readDB seems to make no difference, and Seq is supposed to > >>> be a strict datastructure already! Doing things in GHCi has been > >>> tedious, and hasn't enlightened me much: sometimes things overflow and > >>> sometimes they don't. It's all very frustrating and I'm seriously > >>> considering going back to using the original read/show code unless > >>> anyone knows how to fix this - that approach may be many times slower, > >>> but I know it will work. > >>> > >>> -- > >>> gwern > >> > >> Have you tried the darcs version of binary? ?It has a new instance > >> which looks more efficient than the old. > >> > >> > >> Cheers, > >> Spencer Janssen > > > > I have. It still stack-overflows on my 9.8 meg file. (The magic number > > seems to be somewhere between 9 and 10 megabytes.) > > > > -- > > gwern > > _______________________________________________ > > 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 Thu Mar 5 14:37:56 2009 From: dons at galois.com (Don Stewart) Date: Thu Mar 5 14:27:17 2009 Subject: [Haskell-cafe] missing support to Data.Binary for uvector package In-Reply-To: <49AFE78F.9010707@libero.it> References: <49AFE78F.9010707@libero.it> Message-ID: <20090305193756.GG11109@whirlpool.galois.com> manlio_perillo: > Hi. > > I'm still having problems with the uvector package. > > > I have an IntMap (UArr xxx) data type, and I want to serialize it to > disk, in binary format. > > I'm using the uvector package from > http://patch-tag.com/repo/pumpkin-uvector/home > > > The problem is with missing instance declarations, for Hyperstrict data > type and Data.Array.Vector.UArr.UPrim. > > > For the former, the instance is simple, but for the latter I have no > idea about what to do. > > The full error message (GHC 6.8.2): > > No instance for (uvector-0.2:Data.Array.Vector.UArr.UPrim > (Word32 > uvector-0.2:Data.Array.Vector.Prim.Hyperstrict.:*: Word8)) > arising from a use of `encode' at bin/process-data-1.hs:72:18-36 > Possible fix: > add an instance declaration for > (uvector-0.2:Data.Array.Vector.UArr.UPrim > (Word32 uvector-0.2:Data.Array.Vector.Prim.Hyperstrict.:*: Word8)) > > uvector is alpha/experimental. You should expect to write instances/patches if you chose to use it! -- Don From mailing_list at istitutocolli.org Thu Mar 5 14:46:16 2009 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Thu Mar 5 14:34:51 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> <9D7EC421-A962-47C9-B009-BC4401357247@ece.cmu.edu> <20090305132129.GA23016@eeepc.nowhere.net> Message-ID: <20090305194616.GF23016@eeepc.nowhere.net> On Thu, Mar 05, 2009 at 12:50:20PM -0500, Brandon S. Allbery KF8NH wrote: > On 2009 Mar 5, at 8:21, Andrea Rossato wrote: >> xmobar is not open source. xmobar is FREE software! > > I don't do fundamentalist religion... qualifying as fundamentalism the avoidance of cheap marketing strategies is just a ... cheap marketing strategy. cheers, andrea From ndmitchell at gmail.com Thu Mar 5 14:55:46 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Mar 5 14:44:19 2009 Subject: [Haskell-cafe] Data.Binary stack overflow with Data.Sequence String In-Reply-To: <20090305193543.GF11109@whirlpool.galois.com> References: <3a9962070903032050o4221663y77128df44b5cf965@mail.gmail.com> <404396ef0903050351q3ad4bf5emc26148ae8a30d936@mail.gmail.com> <20090305193543.GF11109@whirlpool.galois.com> Message-ID: <404396ef0903051155t19cf1a75m8b98e8709c1cae9e@mail.gmail.com> Avoid massive reductions in runtime while maintaining the same API? I did move to using ByteString's internally for those bits later on, but reading String's from Data.Binary with a ByteString+unpack went much more quickly than reading String's On Thu, Mar 5, 2009 at 7:35 PM, Don Stewart wrote: > Avoid unpack! > > ndmitchell: >> Hi Gwern, >> >> I get String/Data.Binary issues too. My suggestion would be to change >> your strings to ByteString's, serisalise, and then do the reverse >> conversion when reading. Interestingly, a String and a ByteString have >> identical Data.Binary reps, but in my experiments converting, >> including the cost of BS.unpack, makes the reading substantially >> cheaper. >> >> Thanks >> >> Neil >> >> On Thu, Mar 5, 2009 at 2:33 AM, Gwern Branwen wrote: >> > On Tue, Mar 3, 2009 at 11:50 PM, Spencer Janssen >> > wrote: >> >> On Tue, Mar 3, 2009 at 10:30 PM, Gwern Branwen wrote: >> >>> So recently I've been having issues with Data.Binary & Data.Sequence; >> >>> I serialize a 'Seq String' >> >>> >> >>> You can see the file here: http://code.haskell.org/yi/Yi/IReader.hs >> >>> >> >>> The relevant function seems to be: >> >>> >> >>> -- | Read in database from 'dbLocation' and then parse it into an 'ArticleDB'. >> >>> readDB :: YiM ArticleDB >> >>> readDB = io $ (dbLocation >>= r) `catch` (\_ -> return empty) >> >>> ? ? ? ? ?where r x = fmap (decode . BL.fromChunks . return) $ B.readFile x >> >>> ? ? ? ? ? ? ? ?-- We read in with strict bytestrings to guarantee the >> >>> file is closed, >> >>> ? ? ? ? ? ? ? ?-- and then we convert it to the lazy bytestring >> >>> data.binary expects. >> >>> ? ? ? ? ? ? ? ?-- This is inefficient, but alas... >> >>> >> >>> My current serialized file is about 9.4M. I originally thought that >> >>> the issue might be the recent upgrade in Yi to binary 0.5, but I >> >>> unpulled patches back to past that, and the problem still manifested. >> >>> >> >>> Whenever yi tries to read the articles.db file, it stack overflows. It >> >>> actually stack-overflowed on even smaller files, but I managed to bump >> >>> the size upwards, it seems, by the strict-Bytestring trick. >> >>> Unfortunately, my personal file has since passed whatever that limit >> >>> was. >> >>> >> >>> I've read carefully the previous threads on Data.Binary and Data.Map >> >>> stack-overflows, but none of them seem to help; hacking some $!s or >> >>> seqs into readDB seems to make no difference, and Seq is supposed to >> >>> be a strict datastructure already! Doing things in GHCi has been >> >>> tedious, and hasn't enlightened me much: sometimes things overflow and >> >>> sometimes they don't. It's all very frustrating and I'm seriously >> >>> considering going back to using the original read/show code unless >> >>> anyone knows how to fix this - that approach may be many times slower, >> >>> but I know it will work. >> >>> >> >>> -- >> >>> gwern >> >> >> >> Have you tried the darcs version of binary? ?It has a new instance >> >> which looks more efficient than the old. >> >> >> >> >> >> Cheers, >> >> Spencer Janssen >> > >> > I have. It still stack-overflows on my 9.8 meg file. (The magic number >> > seems to be somewhere between 9 and 10 megabytes.) >> > >> > -- >> > gwern >> > _______________________________________________ >> > 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 ndmitchell at gmail.com Thu Mar 5 14:57:38 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Mar 5 14:46:12 2009 Subject: [Haskell-cafe] Test if a file is empty or stat in haskell In-Reply-To: <20090305192446.GA23662@amuttreja-dt> References: <20090305185642.GB23065@amuttreja-dt> <200903052015.03294.daniel.is.fischer@web.de> <20090305192446.GA23662@amuttreja-dt> Message-ID: <404396ef0903051157q419f28dbl2639c449fe8e63ec@mail.gmail.com> Hi > I am on Linux. BTW, Hoogle does not seem to ?know about > System.Posix.Files, though it did point me to System.IO.FileSize > which would also have served the purpose. To build the Hoogle libraries I need to build the packages. I run Windows not Linux, so its a bit difficult to index System.Posix - but I am trying to shortly. Thanks Neil From jfredett at gmail.com Thu Mar 5 15:02:38 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Thu Mar 5 14:51:13 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: <200903052004.04379.daniel.is.fischer@web.de> References: <49B01E7D.6000207@gmail.com> <200903052004.04379.daniel.is.fischer@web.de> Message-ID: <49B02FDE.7050707@gmail.com> This doesn't seem to do it, same type error... Maybe I need to use some kind of witness type -- to inform the compiler of the type of a @ runtime? Daniel Fischer wrote: > Am Donnerstag, 5. M?rz 2009 19:48 schrieb Joseph Fredette: > >> getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter >> a) >> getFilterMain fMainLoc = >> do >> loadModules [fMainLoc]; setTopLevelModules [(takeWhile >> (/='.') fMainLoc)] >> fMain <- (interpret "(filterMain)" (as :: Deliverable a => >> Filter a)) >> > > Without looking at more code, the type variable a here is a fresh type > variable, not the one from getFilterMain's signature. > > >> return >> (fMain) >> > > > Maybe bringing the type variable a into scope in the function body by > > {-# LANGUAGE ScopedTypeVariables #-} > > getFilterMain :: forall a. Deliverable a => FilePath -> Interpreter (Filter, > a) > > would suffice. > > > >> However, when I try to compile this, I get the type error: >> >> Hackmain.hs:70:43: >> Ambiguous type variable `a' in the constraint: >> `Deliverable a' >> arising from a use of `getFilterMainStuff' at >> Hackmain.hs:70:43-60 >> Probable fix: add a type signature that fixes these type >> variable(s) >> >> My understanding is that a type like "Foo a => Bar a" (where Foo is a >> class and Bar is a datatype) would simply restrict >> the values of a to only those implementing Foo. But evidently I'm wrong. >> Is there a good (read, easy... :) ) fix to this? >> >> Any help would be greatly appreciated. >> >> /Joe >> >> PS. All the actual code is on patch-tag, here >> http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to look at >> that directly, the relevant files are in Src, namely, Hackmain.hs, >> Filter.hs, and Deliverable.hs >> > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/e5a99f9c/jfredett.vcf From thomas.dubuisson at gmail.com Thu Mar 5 15:43:22 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Mar 5 15:31:57 2009 Subject: [Haskell-cafe] Test if a file is empty or stat in haskell In-Reply-To: <20090305192446.GA23662@amuttreja-dt> References: <20090305185642.GB23065@amuttreja-dt> <200903052015.03294.daniel.is.fischer@web.de> <20090305192446.GA23662@amuttreja-dt> Message-ID: <4c44d90b0903051243h15a24a8ek3512a1d696147afb@mail.gmail.com> >> getFileStatus, fileSize ... > > Great, thanks. > BTW, Hoogle does not seem to ?know about > System.Posix.Files, though it did point me to System.IO.FileSize > which would also have served the purpose. Yep, this was discussed in a Hoogle and Network.Socket thread I started last week. There is a wiki for summarizing thoughts [1]. Some time this weekend or next week I intend to submit a Hoogle ticket proposing what I see as an agreeable outcome. At that point I hope Neil will accept and maybe even find time to write code. The final step would involve me buying Neil a beer - I've lots of beer-debt to the Haskell community. [1] http://haskell.org/haskellwiki/Hoogle/Packages From ryani.spam at gmail.com Thu Mar 5 16:25:29 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Mar 5 16:14:02 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: <49B01E7D.6000207@gmail.com> References: <49B01E7D.6000207@gmail.com> Message-ID: <2f9b2d30903051325j1ba98cc3i755540e33671eaa5@mail.gmail.com> So, by using the Haskell interpreter, you're using the not-very-well-supported dynamically-typed subset of Haskell. You can tell this from the type signature of "interpret": > interpret :: Typeable a => String -> a -> Interpreter a > as :: Typeable a => a > as = undefined (from http://hackage.haskell.org/packages/archive/hint/0.2.1/doc/html/src/Language-Haskell-Interpreter-GHC.html) In particular, the "as" argument to interpret is specifying what type you want the interpreted result to be typechecked against; the interpretation fails if it doesn't match that type. But you need the result type to be an instance of Typeable; (forall a. Deliverable a => Filter a) most certainly is not. Off the top of my head, you have a couple of directions you can take this. (1) Make Typeable a superclass of Deliverable, saying that all deliverable things must be dynamically typeable. Then derive Typeable on Filter, and have the result be of type "Filter a" using ScopedTypeVariables as suggested before. (You can also pass "infer" to the interpreter and let the compiler try to figure out the result type instead of passing (as :: SomeType).) (2) Make a newtype wrapper around Filter and give it an instance of Typeable, and add a constraint to filterMain that the result type in the filter is also typeable. Then unwrap the newtype after the interpreter completes. Good luck; I've never tried to use the Haskell interpreter before, so I'm curious how well it works and what problems you have with it! -- ryan 2009/3/5 Joseph Fredette : > I've been working on a little project, and one of the things I need to do is > dynamically compile and import a Haskell Source file containing filtering > definitions. I've written a small monad called Filter which is simply: > > ? type Filter a = Reader (Config, Email) a > > To encompass all the email filtering. The method I need to import, > filterMain, has type: > > ? filterMain :: Deliverable a => Filter a > > where Deliverable is a type class which abstracts over delivery to a path in > the file system. The notion is that I can write a type like: > > ? data DEmail = {email :: Email, path :: FilePath} > ? newtype Maildir = MD DEmail > > ? instance Deliverable Maildir where > ? ? ?{- ... omitted -} > > However, Filter a should not be restricted to Deliverable types- it also > encompasses the results of regular expression matching, etc, which are not > -- in general -- Deliverable instances. > > My question is this, when importing the file containing the definitions of > ?filterMain, I have the following code to grab filterMain and return it as a > function. > > ? getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter a) > ? ? ? ? ? ? ? ? ? ? ? getFilterMain fMainLoc = do > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? loadModules > [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] > ? ? ? ? ? ? ? ? ? ? fMain ?<- (interpret "(filterMain)" (as :: Deliverable a > => Filter a)) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return (fMain) > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?However, when I try to compile > this, I get the type error: > > ? Hackmain.hs:70:43: > ? ? ? Ambiguous type variable `a' in the constraint: > ? ? ? ? `Deliverable a' > ? ? ? ? ? arising from a use of `getFilterMainStuff' at Hackmain.hs:70:43-60 > ? ? ? Probable fix: add a type signature that fixes these type variable(s) > > My understanding is that a type like "Foo a => Bar a" (where Foo is a class > and Bar is a datatype) would simply restrict > the values of a to only those implementing Foo. But evidently I'm wrong. Is > there a good (read, easy... :) ) fix to this? > > Any help would be greatly appreciated. > > /Joe > > PS. All the actual code is on patch-tag, here > http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to look at that > directly, the relevant files are in Src, namely, Hackmain.hs, Filter.hs, and > Deliverable.hs > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From barsoap at web.de Thu Mar 5 17:04:13 2009 From: barsoap at web.de (Achim Schneider) Date: Thu Mar 5 16:52:56 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions References: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> <20090304233801.3048333f@solaris> <7ca3f0160903041455r3b54de58wb518833d3d8541c3@mail.gmail.com> Message-ID: <20090305230413.137d411c@solaris> Luke Palmer wrote: > I don't think set theory is trivial in the least. I think it is > complicated, convoluted, often anti-intuitive and nonconstructive. > Waaaaaaagh! I mean trivial in the mathematical sense, as in how far away from the axioms you are. The other kind of "triviality" of set theory just proves the point I made about CT vs. lambda calculus. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From barsoap at web.de Thu Mar 5 17:13:23 2009 From: barsoap at web.de (Achim Schneider) Date: Thu Mar 5 17:02:13 2009 Subject: [Haskell-cafe] Re: Theory about uncurried functions References: <067A3E80-C2F9-4EC3-AB6F-80EFA661345A@math.su.se> <20090304233801.3048333f@solaris> <7ca3f0160903041455r3b54de58wb518833d3d8541c3@mail.gmail.com> <20090305230413.137d411c@solaris> Message-ID: <20090305231323.6827c157@solaris> To wrap up: While formalising, there is always a tradeoff between complexity of the theory you're using and the complexity of it being applied to some specific topic. Category theory hits a very, very sweet spot there. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From jfredett at gmail.com Thu Mar 5 17:47:50 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Thu Mar 5 17:36:22 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: <2f9b2d30903051325j1ba98cc3i755540e33671eaa5@mail.gmail.com> References: <49B01E7D.6000207@gmail.com> <2f9b2d30903051325j1ba98cc3i755540e33671eaa5@mail.gmail.com> Message-ID: <49B05696.7010808@gmail.com> So, I tried both of those things, both each alone and together. No dice. Same error, so I reverted back to the original. :( However, I was, after some random type signature insertions, able to convert the problem into a different one, via: getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter a) getFilterMain MainLoc = do loadModules [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] fMain <- (interpret "(filterMain)" infer) return (fMain :: Deliverable a => Filter a) Inferred type is less polymorphic than expected Quantified type variable `a' is mentioned in the environment: fMain :: Filter a (bound at Hackmain.hs:77:1) In the first argument of `return', namely `(fMain :: (Deliverable a) => Filter a)' In the expression: return (fMain :: (Deliverable a) => Filter a) In the expression: do loadModules [fMainLoc] setTopLevelModules [(takeWhile (/= '.') fMainLoc)] fMain <- (interpret "(filterMain)" infer) return (fMain :: (Deliverable a) => Filter a) I'm thinking that this might be more easily solved -- I do think I understand the issue. somehow, I need to tell the compiler that the 'a' used in the return statement (return (fMain :: ...)) is the same as the 'a' in the type sig for the whole function. While I ponder this, and hopefully receive some more help -- thanks again Dan, Ryan -- Are there any other options besides Hint that might -- at least in the short term -- make this easier? I'd really like to finish this up. I'm _so_ close to getting it done. Thanks, /Joe Ryan Ingram wrote: > So, by using the Haskell interpreter, you're using the > not-very-well-supported dynamically-typed subset of Haskell. You can > tell this from the type signature of "interpret": > > >> interpret :: Typeable a => String -> a -> Interpreter a >> > > >> as :: Typeable a => a >> as = undefined >> > > (from http://hackage.haskell.org/packages/archive/hint/0.2.1/doc/html/src/Language-Haskell-Interpreter-GHC.html) > > In particular, the "as" argument to interpret is specifying what type > you want the interpreted result to be typechecked against; the > interpretation fails if it doesn't match that type. But you need the > result type to be an instance of Typeable; (forall a. Deliverable a => > Filter a) most certainly is not. > > > Off the top of my head, you have a couple of directions you can take this. > > (1) Make Typeable a superclass of Deliverable, saying that all > deliverable things must be dynamically typeable. Then derive Typeable > on Filter, and have the result be of type "Filter a" using > ScopedTypeVariables as suggested before. (You can also pass "infer" to > the interpreter and let the compiler try to figure out the result type > instead of passing (as :: SomeType).) > > (2) Make a newtype wrapper around Filter and give it an instance of > Typeable, and add a constraint to filterMain that the result type in > the filter is also typeable. Then unwrap the newtype after the > interpreter completes. > > Good luck; I've never tried to use the Haskell interpreter before, so > I'm curious how well it works and what problems you have with it! > > > -- ryan > > 2009/3/5 Joseph Fredette : > >> I've been working on a little project, and one of the things I need to do is >> dynamically compile and import a Haskell Source file containing filtering >> definitions. I've written a small monad called Filter which is simply: >> >> type Filter a = Reader (Config, Email) a >> >> To encompass all the email filtering. The method I need to import, >> filterMain, has type: >> >> filterMain :: Deliverable a => Filter a >> >> where Deliverable is a type class which abstracts over delivery to a path in >> the file system. The notion is that I can write a type like: >> >> data DEmail = {email :: Email, path :: FilePath} >> newtype Maildir = MD DEmail >> >> instance Deliverable Maildir where >> {- ... omitted -} >> >> However, Filter a should not be restricted to Deliverable types- it also >> encompasses the results of regular expression matching, etc, which are not >> -- in general -- Deliverable instances. >> >> My question is this, when importing the file containing the definitions of >> filterMain, I have the following code to grab filterMain and return it as a >> function. >> >> getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter a) >> getFilterMain fMainLoc = do >> loadModules >> [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] >> fMain <- (interpret "(filterMain)" (as :: Deliverable a >> => Filter a)) return (fMain) >> >> However, when I try to compile >> this, I get the type error: >> >> Hackmain.hs:70:43: >> Ambiguous type variable `a' in the constraint: >> `Deliverable a' >> arising from a use of `getFilterMainStuff' at Hackmain.hs:70:43-60 >> Probable fix: add a type signature that fixes these type variable(s) >> >> My understanding is that a type like "Foo a => Bar a" (where Foo is a class >> and Bar is a datatype) would simply restrict >> the values of a to only those implementing Foo. But evidently I'm wrong. Is >> there a good (read, easy... :) ) fix to this? >> >> Any help would be greatly appreciated. >> >> /Joe >> >> PS. All the actual code is on patch-tag, here >> http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to look at that >> directly, the relevant files are in Src, namely, Hackmain.hs, Filter.hs, and >> Deliverable.hs >> >> _______________________________________________ >> 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: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/abdda8e0/jfredett-0001.vcf From eelco at lempsink.nl Thu Mar 5 17:49:39 2009 From: eelco at lempsink.nl (Eelco Lempsink) Date: Thu Mar 5 17:38:18 2009 Subject: [Haskell-cafe] Haskell Logo Voting will start soon! Message-ID: Hi there! It's been quiet for a while around the 'new logo' competition, but here is how it is going to work: The list with options can be found here (for now): http://community.haskell.org/~eelco/poll.html Notice that some (very) similar logos are grouped as one option (thanks to Ian Lynagh) All submissions compete, so that still makes more than a 100 options! The voting system we'll use is the Condorcet Internet Voting System (http://www.cs.cornell.edu/andru/civs.html ). The poll won't be public, but every subscriber to Haskell-Cafe will get a (private) voting ballot by email. The poll will (probably) start March 16 and run for about a week (don't worry, there will be a strict deadline communicated). When the poll is over, the results will be viewable by everybody. The CIVS allows easy grouping and ordering, so the task of ordering 100 options should be doable within 5-10 minutes. If you're in a hurry you can do it a lot faster, just pick your favorite and put it first. If you want to learn more about condorcet voting, the CIVS site and Wikipedia are your friends. I'll supervise the poll and make sure it's started, stopped and all Haskell-Cafe subscribers get a ballot (Simon Marlow provided the email addresses). Since I'm going on a (probably internet deprived) holiday for a week _and_ to make sure I haven't overlooked anything, I'm announcing it now but won't start the poll till March 16. Of course, I'd love to hear about anything that I missed and/or that might influence the voting process in a significant way. (There are probably some people subscribed with multiple addresses, but I'll be using the subscriber list from yesterday, so signing up now with lots of addresses won't get you more ballots ;) -- Regards, Eelco Lempsink -------------- 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/20090305/18b8a209/PGP.bin From lemming at henning-thielemann.de Thu Mar 5 17:52:10 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Mar 5 17:40:44 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: <9979e72e0903040329p4c873a7bp30b011b5b109df5a@mail.gmail.com> References: <9979e72e0903040329p4c873a7bp30b011b5b109df5a@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, John Lato wrote: >> John A. De Goes schrieb: >> >>> Elsewhere, laziness can be a real boon, so I don't understand your >>> question, "Why have laziness in Haskell at all?" >> >> As I have written, many libaries process their data lazily (or could be >> changed to do so without altering their interface) but their interface >> can forbid application to data that is fetched from the outside world. >> Say you are used to 'map', 'filter', 'foldr' - you cannot use them on >> data fetched by the iteratee/enumerator approach. >> > > Thank you for replying to this; it's good to see what features people > would like to make iteratees more useful. > > Where did you get the idea that you can't use 'map'? What I meant was, that you cannot just use the functions you are used from Data.List. You need functions adapted to Iteratee. This also implies that all libraries written in terms of Data.List functions cannot be used as they are. Maybe it's a good time to review those libraries, whether they need lists at all, or whether they would also work with functionality that can be provided by Iteratees. The question, whether libraries should be bound to lists and Strings did already arise with ByteStrings. So Iteratees may be just one more reason to generalize the libraries. From barsoap at web.de Thu Mar 5 18:03:51 2009 From: barsoap at web.de (Achim Schneider) Date: Thu Mar 5 17:52:33 2009 Subject: [Haskell-cafe] Re: Haskell Logo Voting will start soon! References: Message-ID: <20090306000351.61146bca@solaris> Eelco Lempsink wrote: > The poll won't be public, but every subscriber to Haskell-Cafe > will get a (private) voting ballot by email. > What about us gmane users? -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From dons at galois.com Thu Mar 5 18:26:26 2009 From: dons at galois.com (Don Stewart) Date: Thu Mar 5 18:15:49 2009 Subject: [Haskell-cafe] Haskell Logo Voting will start soon! In-Reply-To: References: Message-ID: <20090305232626.GC11725@whirlpool.galois.com> eelco: > Hi there! > > It's been quiet for a while around the 'new logo' competition, but here > is how it is going to work: > > The list with options can be found here (for now): > http://community.haskell.org/~eelco/poll.html Notice that some (very) > similar logos are grouped as one option (thanks to Ian Lynagh) All > submissions compete, so that still makes more than a 100 options! > > The voting system we'll use is the Condorcet Internet Voting System > (http://www.cs.cornell.edu/andru/civs.html). The poll won't be public, > but every subscriber to Haskell-Cafe will get a (private) voting ballot > by email. The poll will (probably) start March 16 and run for about a > week (don't worry, there will be a strict deadline communicated). When > the poll is over, the results will be viewable by everybody. > > The CIVS allows easy grouping and ordering, so the task of ordering 100 > options should be doable within 5-10 minutes. If you're in a hurry you > can do it a lot faster, just pick your favorite and put it first. If you > want to learn more about condorcet voting, the CIVS site and Wikipedia > are your friends. > > I'll supervise the poll and make sure it's started, stopped and all > Haskell-Cafe subscribers get a ballot (Simon Marlow provided the email > addresses). Since I'm going on a (probably internet deprived) holiday > for a week _and_ to make sure I haven't overlooked anything, I'm > announcing it now but won't start the poll till March 16. Of course, > I'd love to hear about anything that I missed and/or that might > influence the voting process in a significant way. (There are probably > some people subscribed with multiple addresses, but I'll be using the > subscriber list from yesterday, so signing up now with lots of addresses > won't get you more ballots ;) Excellent work Eelco, and thanks for pushing this forward! -- Don From dmehrtash at gmail.com Thu Mar 5 18:36:07 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Thu Mar 5 18:24:40 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? Message-ID: In this chat server implementation http://www.haskell.org/haskellwiki/Implement_a_chat_server forkIO is used with fix as in: reader <- forkIO $ fix $ \loop -> do (nr', line) <- readChan chan' when (nr /= nr') $ hPutStrLn hdl line loop Do you have to use fix? Or is there a way to write this with a "let"? -- Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/7f47107b/attachment.htm From jonathanccast at fastmail.fm Thu Mar 5 19:12:55 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Mar 5 19:06:06 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: References: Message-ID: <1236298375.32464.26.camel@jcchost> On Thu, 2009-03-05 at 15:36 -0800, Daryoush Mehrtash wrote: > In this chat server implementation > http://www.haskell.org/haskellwiki/Implement_a_chat_server > > forkIO is used with fix as in: > > reader <- forkIO $ fix $ \loop -> do > > (nr', line) <- readChan chan' > when (nr /= nr') $ hPutStrLn hdl line > > loop > > Do you have to use fix? Or is there a way to write this with a "let"? You can certainly use let: reader <- forkIO $ let loop = do (nr', line) <- readChan chan' when (nr /= nr') $ hPutStrLn hdl line loop in loop But the version with fix is clearer (at least to people who have fix in their vocabulary) and arguably better style. jcc From derek.a.elkins at gmail.com Thu Mar 5 19:26:46 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Mar 5 19:15:26 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: <1236298375.32464.26.camel@jcchost> References: <1236298375.32464.26.camel@jcchost> Message-ID: <1236299206.5837.2.camel@derek-laptop> On Thu, 2009-03-05 at 16:12 -0800, Jonathan Cast wrote: > On Thu, 2009-03-05 at 15:36 -0800, Daryoush Mehrtash wrote: > > In this chat server implementation > > http://www.haskell.org/haskellwiki/Implement_a_chat_server > > > > forkIO is used with fix as in: > > > > reader <- forkIO $ fix $ \loop -> do > > > > (nr', line) <- readChan chan' > > when (nr /= nr') $ hPutStrLn hdl line > > > > loop > > > > Do you have to use fix? Or is there a way to write this with a "let"? > > You can certainly use let: > > reader <- forkIO $ let loop = do > (nr', line) <- readChan chan' > when (nr /= nr') $ hPutStrLn hdl line > loop > in loop > > But the version with fix is clearer (at least to people who have fix in > their vocabulary) and arguably better style. Both are poorish style. reader <- forkIO $ forever $ do (nr', line) <- readChan; when (nr /= nr') $ putStrLn hdl line From dgorin at dc.uba.ar Thu Mar 5 20:18:02 2009 From: dgorin at dc.uba.ar (=?ISO-8859-1?Q?Daniel_Gor=EDn?=) Date: Thu Mar 5 20:06:45 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: <49B05696.7010808@gmail.com> References: <49B01E7D.6000207@gmail.com> <2f9b2d30903051325j1ba98cc3i755540e33671eaa5@mail.gmail.com> <49B05696.7010808@gmail.com> Message-ID: <105919D9-8547-4C50-B898-6590673D5EAF@dc.uba.ar> Hi I've downloaded Hackmain from patch-tag, but I'm getting a different error. The error I get is: Hackmain.hs:63:10: No instance for (Data.Typeable.Typeable2 Control.Monad.Reader.Reader) arising from a use of `interpret' at Hackmain.hs:63:10-67 Hint requires the interpreted values to be an instance of Typeable in order to check, in runtime, that the interpreted value matches the type declared at compile. Therefore, you need to make sure that (Filter a) is indeed an instance of Typeable. Since you have Filter a = Reader (Config, Email) a, you probably need to - Derive Config and Email instances for Filter, - Manually provide Typeable instances for Reader a b, something along the lines of: instance (Typeable a, Typeable b) => Typeable (Reader a b) where... (I don't know why this isn't done in the mtl....) - Change the signature to: getFilterMain :: (Typeable a, Deliverable a) => FilePath -> Interpreter (Filter a) Also, you can try using "infer" instead of "as :: ...." Hope that helps Daniel On Mar 5, 2009, at 8:47 PM, Joseph Fredette wrote: > So, I tried both of those things, both each alone and together. No > dice. Same error, so I reverted back to the > original. :( > However, I was, after some random type signature insertions, able to > convert the problem into a different one, via: > > getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter > a) getFilterMain MainLoc = do > loadModules [fMainLoc]; setTopLevelModules [(takeWhile (/='.') > fMainLoc)] fMain <- (interpret > "(filterMain)" infer) > return (fMain :: Deliverable a => Filter a) > > Inferred type is less polymorphic than expected > Quantified type variable `a' is mentioned in the environment: > fMain :: Filter a (bound at Hackmain.hs:77:1) > In the first argument of `return', namely > `(fMain :: (Deliverable a) => Filter a)' > In the expression: return (fMain :: (Deliverable a) => Filter a) > In the expression: > do loadModules [fMainLoc] > setTopLevelModules [(takeWhile (/= '.') fMainLoc)] > fMain <- (interpret "(filterMain)" infer) > return (fMain :: (Deliverable a) => Filter a) > I'm > thinking that this might be more easily solved -- I do think I > understand the issue. somehow, I need to tell the compiler > that the 'a' used in the return statement (return (fMain :: ...)) is > the same as the 'a' in the type sig for the whole function. > > While I ponder this, and hopefully receive some more help -- thanks > again Dan, Ryan -- Are there any other options besides Hint that > might -- at least in the short term -- make this easier? I'd really > like to finish this up. I'm _so_ close to getting it done. > > Thanks, > > /Joe > > Ryan Ingram wrote: >> So, by using the Haskell interpreter, you're using the >> not-very-well-supported dynamically-typed subset of Haskell. You can >> tell this from the type signature of "interpret": >> >> >>> interpret :: Typeable a => String -> a -> Interpreter a >>> >> >> >>> as :: Typeable a => a >>> as = undefined >>> >> >> (from http://hackage.haskell.org/packages/archive/hint/0.2.1/doc/html/src/Language-Haskell-Interpreter-GHC.html) >> >> In particular, the "as" argument to interpret is specifying what type >> you want the interpreted result to be typechecked against; the >> interpretation fails if it doesn't match that type. But you need the >> result type to be an instance of Typeable; (forall a. Deliverable a >> => >> Filter a) most certainly is not. >> >> >> Off the top of my head, you have a couple of directions you can >> take this. >> >> (1) Make Typeable a superclass of Deliverable, saying that all >> deliverable things must be dynamically typeable. Then derive >> Typeable >> on Filter, and have the result be of type "Filter a" using >> ScopedTypeVariables as suggested before. (You can also pass "infer" >> to >> the interpreter and let the compiler try to figure out the result >> type >> instead of passing (as :: SomeType).) >> >> (2) Make a newtype wrapper around Filter and give it an instance of >> Typeable, and add a constraint to filterMain that the result type in >> the filter is also typeable. Then unwrap the newtype after the >> interpreter completes. >> >> Good luck; I've never tried to use the Haskell interpreter before, so >> I'm curious how well it works and what problems you have with it! >> >> >> -- ryan >> >> 2009/3/5 Joseph Fredette : >> >>> I've been working on a little project, and one of the things I >>> need to do is >>> dynamically compile and import a Haskell Source file containing >>> filtering >>> definitions. I've written a small monad called Filter which is >>> simply: >>> >>> type Filter a = Reader (Config, Email) a >>> >>> To encompass all the email filtering. The method I need to import, >>> filterMain, has type: >>> >>> filterMain :: Deliverable a => Filter a >>> >>> where Deliverable is a type class which abstracts over delivery to >>> a path in >>> the file system. The notion is that I can write a type like: >>> >>> data DEmail = {email :: Email, path :: FilePath} >>> newtype Maildir = MD DEmail >>> >>> instance Deliverable Maildir where >>> {- ... omitted -} >>> >>> However, Filter a should not be restricted to Deliverable types- >>> it also >>> encompasses the results of regular expression matching, etc, which >>> are not >>> -- in general -- Deliverable instances. >>> >>> My question is this, when importing the file containing the >>> definitions of >>> filterMain, I have the following code to grab filterMain and >>> return it as a >>> function. >>> >>> getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter >>> a) >>> getFilterMain fMainLoc = do >>> loadModules >>> [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] >>> fMain <- (interpret "(filterMain)" (as :: >>> Deliverable a >>> => Filter a)) return (fMain) >>> >>> However, when I try to >>> compile >>> this, I get the type error: >>> >>> Hackmain.hs:70:43: >>> Ambiguous type variable `a' in the constraint: >>> `Deliverable a' >>> arising from a use of `getFilterMainStuff' at Hackmain.hs: >>> 70:43-60 >>> Probable fix: add a type signature that fixes these type >>> variable(s) >>> >>> My understanding is that a type like "Foo a => Bar a" (where Foo >>> is a class >>> and Bar is a datatype) would simply restrict >>> the values of a to only those implementing Foo. But evidently I'm >>> wrong. Is >>> there a good (read, easy... :) ) fix to this? >>> >>> Any help would be greatly appreciated. >>> >>> /Joe >>> >>> PS. All the actual code is on patch-tag, here >>> http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to >>> look at that >>> directly, the relevant files are in Src, namely, Hackmain.hs, >>> Filter.hs, and >>> Deliverable.hs >>> >>> _______________________________________________ >>> 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 Mar 5 20:20:37 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Mar 5 20:09:15 2009 Subject: [Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked? In-Reply-To: References: <9979e72e0903040329p4c873a7bp30b011b5b109df5a@mail.gmail.com> Message-ID: <1236302437.22402.179.camel@localhost> On Thu, 2009-03-05 at 23:52 +0100, Henning Thielemann wrote: > On Wed, 4 Mar 2009, John Lato wrote: > > >> John A. De Goes schrieb: > >> > >>> Elsewhere, laziness can be a real boon, so I don't understand your > >>> question, "Why have laziness in Haskell at all?" > >> > >> As I have written, many libaries process their data lazily (or could be > >> changed to do so without altering their interface) but their interface > >> can forbid application to data that is fetched from the outside world. > >> Say you are used to 'map', 'filter', 'foldr' - you cannot use them on > >> data fetched by the iteratee/enumerator approach. > >> > > > > Thank you for replying to this; it's good to see what features people > > would like to make iteratees more useful. > > > > Where did you get the idea that you can't use 'map'? > > What I meant was, that you cannot just use the functions you are used from > Data.List. You need functions adapted to Iteratee. This also implies that > all libraries written in terms of Data.List functions cannot be used as > they are. Maybe it's a good time to review those libraries, whether they > need lists at all, or whether they would also work with functionality that > can be provided by Iteratees. The question, whether libraries should be > bound to lists and Strings did already arise with ByteStrings. So > Iteratees may be just one more reason to generalize the libraries. In most cases we can get the list version from a continuation based version. A continuation based version can also be used to implement an iterator version. Leaving aside the amount of work, I've been trying to think of how to do a iterator version at all for some libs. Specifically, my zlib binding. Currently the zlib package provides functions on lazy bytestrings: compress, decompress :: ByteString -> ByteString This hides all the complications of blocks and filling and draining buffers. However since it uses lazy bytestrings it is most naturally used with lazy io. The question is can I make an interface that also keeps the devotees of iterator based IO happy and also lets me implement the existing api above. I cannot see how to do it. Note that compress and decompress are pure. This is something that I want to keep. I don't want to go back to using IO for a pure operation like compression just for the sake of iterator IO. The problem of course is that while zlib compression is pure overall, there is an internal state thread. That must be threaded linearly. We cannot hand out a continuation that can be run multiple times. Lining up the zlib state thread with the memoising lazy list works perfectly. I cannot see how we do the same with an iterator interface. I'm not saying it cannot be done. On the contrary, I would like to see it done. Duncan From leather at cs.uu.nl Thu Mar 5 20:22:20 2009 From: leather at cs.uu.nl (Sean Leather) Date: Thu Mar 5 20:10:54 2009 Subject: [Haskell-cafe] Difficulties in accessing inner elements of data types In-Reply-To: <200903032057.57448.davidmiani@gmail.com> References: <200903032057.57448.davidmiani@gmail.com> Message-ID: <3c6288ab0903051722l27f7f582u2a29a3b05ccccce9@mail.gmail.com> Hi David, I'm working on a Haskell library for interacting with emacs org files. For > those that do not know, an org file is a structured outline style file that > has nested headings, text, tables and other elements. > > Great! Sounds like fun. :) Now, this all works as expected (files are correctly being parsed and > written), however I am having a lot of trouble trying to come up with a > decent API to work with this. While writing an OrgFile is fairly easy, > reading (and accessing inner parts) of an org file is very tedious, and > modifying them is horrendous. > I can imagine. > However, I don't know if this is even possible, how to do it, or if there > is a better alternative to this. I would really apreciate any hints with > regards to this. It would be useful to know if there are other libraries > that also face this problem, and how they solved it. > I definite agree with Neil: I think generic programming is exactly what you are looking for. Fortunately, there are a number of libraries available to help you solve your problem. The next problem is figuring out which one and learning how to it. For this purpose, a comparison of libraries for generic programming in Haskell was recently published: http://www.cs.uu.nl/wiki/Alexey/ComparingLibrariesForGenericProgrammingInHaskell That should give you an idea of what's out there and the pros and cons of each library. I found your example particularly interesting, so I decided to try out a solution in EMGM (Extensible and Modular Generics for the Masses). I wrote up my experiment here: http://splonderzoek.blogspot.com/2009/03/experiments-with-emgm-emacs-org-files.html More information on EMGM is here: http://www.cs.uu.nl/wiki/GenericProgramming/EMGM I'd be happy to help you figure out if EMGM is appropriate for other things you want to do. Good luck with your library! Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/bbf74641/attachment.htm From jfredett at gmail.com Thu Mar 5 20:26:53 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Thu Mar 5 20:15:29 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: <105919D9-8547-4C50-B898-6590673D5EAF@dc.uba.ar> References: <49B01E7D.6000207@gmail.com> <2f9b2d30903051325j1ba98cc3i755540e33671eaa5@mail.gmail.com> <49B05696.7010808@gmail.com> <105919D9-8547-4C50-B898-6590673D5EAF@dc.uba.ar> Message-ID: <49B07BDD.3030501@gmail.com> Oh, crap- I must have never pushed the latest patches, I did put the typeable instances in all the appropriate places. And provided a (maybe incorrect? Though I'm fairly sure that shouldn't affect the bug I'm having now) Typeable implementation for Reader, but I still get this ambiguous type. I'll push the current version asap. Thanks. /Joe Daniel Gor?n wrote: > Hi > > I've downloaded Hackmain from patch-tag, but I'm getting a different > error. The error I get is: > > Hackmain.hs:63:10: > No instance for (Data.Typeable.Typeable2 > Control.Monad.Reader.Reader) > arising from a use of `interpret' at Hackmain.hs:63:10-67 > > Hint requires the interpreted values to be an instance of Typeable in > order to check, in runtime, that the interpreted value matches the > type declared at compile. Therefore, you need to make sure that > (Filter a) is indeed an instance of Typeable. > > Since you have Filter a = Reader (Config, Email) a, you probably need to > > - Derive Config and Email instances for Filter, > > - Manually provide Typeable instances for Reader a b, something along > the lines of: > > instance (Typeable a, Typeable b) => Typeable (Reader a b) where... > > (I don't know why this isn't done in the mtl....) > > - Change the signature to: > > getFilterMain :: (Typeable a, Deliverable a) => FilePath -> > Interpreter (Filter a) > > Also, you can try using "infer" instead of "as :: ...." > > Hope that helps > > Daniel > > On Mar 5, 2009, at 8:47 PM, Joseph Fredette wrote: > >> So, I tried both of those things, both each alone and together. No >> dice. Same error, so I reverted back to the >> original. :( >> However, I was, after some random type signature insertions, able to >> convert the problem into a different one, via: >> >> getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter >> a) getFilterMain MainLoc = do >> loadModules [fMainLoc]; setTopLevelModules [(takeWhile (/='.') >> fMainLoc)] fMain <- (interpret >> "(filterMain)" infer) >> return (fMain :: Deliverable a => Filter a) >> >> Inferred type is less polymorphic than expected >> Quantified type variable `a' is mentioned in the environment: >> fMain :: Filter a (bound at Hackmain.hs:77:1) >> In the first argument of `return', namely >> `(fMain :: (Deliverable a) => Filter a)' >> In the expression: return (fMain :: (Deliverable a) => Filter a) >> In the expression: >> do loadModules [fMainLoc] >> setTopLevelModules [(takeWhile (/= '.') fMainLoc)] >> fMain <- (interpret "(filterMain)" infer) >> return (fMain :: (Deliverable a) => Filter a) >> >> I'm thinking that this might be more easily solved -- I do think I >> understand the issue. somehow, I need to tell the compiler >> that the 'a' used in the return statement (return (fMain :: ...)) is >> the same as the 'a' in the type sig for the whole function. >> >> While I ponder this, and hopefully receive some more help -- thanks >> again Dan, Ryan -- Are there any other options besides Hint that >> might -- at least in the short term -- make this easier? I'd really >> like to finish this up. I'm _so_ close to getting it done. >> >> Thanks, >> >> /Joe >> >> Ryan Ingram wrote: >>> So, by using the Haskell interpreter, you're using the >>> not-very-well-supported dynamically-typed subset of Haskell. You can >>> tell this from the type signature of "interpret": >>> >>> >>>> interpret :: Typeable a => String -> a -> Interpreter a >>>> >>> >>> >>>> as :: Typeable a => a >>>> as = undefined >>>> >>> >>> (from >>> http://hackage.haskell.org/packages/archive/hint/0.2.1/doc/html/src/Language-Haskell-Interpreter-GHC.html) >>> >>> >>> In particular, the "as" argument to interpret is specifying what type >>> you want the interpreted result to be typechecked against; the >>> interpretation fails if it doesn't match that type. But you need the >>> result type to be an instance of Typeable; (forall a. Deliverable a => >>> Filter a) most certainly is not. >>> >>> >>> Off the top of my head, you have a couple of directions you can take >>> this. >>> >>> (1) Make Typeable a superclass of Deliverable, saying that all >>> deliverable things must be dynamically typeable. Then derive Typeable >>> on Filter, and have the result be of type "Filter a" using >>> ScopedTypeVariables as suggested before. (You can also pass "infer" to >>> the interpreter and let the compiler try to figure out the result type >>> instead of passing (as :: SomeType).) >>> >>> (2) Make a newtype wrapper around Filter and give it an instance of >>> Typeable, and add a constraint to filterMain that the result type in >>> the filter is also typeable. Then unwrap the newtype after the >>> interpreter completes. >>> >>> Good luck; I've never tried to use the Haskell interpreter before, so >>> I'm curious how well it works and what problems you have with it! >>> >>> >>> -- ryan >>> >>> 2009/3/5 Joseph Fredette : >>> >>>> I've been working on a little project, and one of the things I need >>>> to do is >>>> dynamically compile and import a Haskell Source file containing >>>> filtering >>>> definitions. I've written a small monad called Filter which is simply: >>>> >>>> type Filter a = Reader (Config, Email) a >>>> >>>> To encompass all the email filtering. The method I need to import, >>>> filterMain, has type: >>>> >>>> filterMain :: Deliverable a => Filter a >>>> >>>> where Deliverable is a type class which abstracts over delivery to >>>> a path in >>>> the file system. The notion is that I can write a type like: >>>> >>>> data DEmail = {email :: Email, path :: FilePath} >>>> newtype Maildir = MD DEmail >>>> >>>> instance Deliverable Maildir where >>>> {- ... omitted -} >>>> >>>> However, Filter a should not be restricted to Deliverable types- it >>>> also >>>> encompasses the results of regular expression matching, etc, which >>>> are not >>>> -- in general -- Deliverable instances. >>>> >>>> My question is this, when importing the file containing the >>>> definitions of >>>> filterMain, I have the following code to grab filterMain and return >>>> it as a >>>> function. >>>> >>>> getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter a) >>>> getFilterMain fMainLoc = do >>>> loadModules >>>> [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] >>>> fMain <- (interpret "(filterMain)" (as :: >>>> Deliverable a >>>> => Filter a)) return (fMain) >>>> >>>> However, when I try to compile >>>> this, I get the type error: >>>> >>>> Hackmain.hs:70:43: >>>> Ambiguous type variable `a' in the constraint: >>>> `Deliverable a' >>>> arising from a use of `getFilterMainStuff' at >>>> Hackmain.hs:70:43-60 >>>> Probable fix: add a type signature that fixes these type >>>> variable(s) >>>> >>>> My understanding is that a type like "Foo a => Bar a" (where Foo is >>>> a class >>>> and Bar is a datatype) would simply restrict >>>> the values of a to only those implementing Foo. But evidently I'm >>>> wrong. Is >>>> there a good (read, easy... :) ) fix to this? >>>> >>>> Any help would be greatly appreciated. >>>> >>>> /Joe >>>> >>>> PS. All the actual code is on patch-tag, here >>>> http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to >>>> look at that >>>> directly, the relevant files are in Src, namely, Hackmain.hs, >>>> Filter.hs, and >>>> Deliverable.hs >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>>> >>>> >>> >>> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/fbdcb11c/jfredett.vcf From donn at avvanta.com Thu Mar 5 20:27:11 2009 From: donn at avvanta.com (Donn Cave) Date: Thu Mar 5 20:15:46 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? References: <1236298375.32464.26.camel@jcchost> Message-ID: <20090306012711.C7D9A276CBA@mail.avvanta.com> Quoth Jonathan Cast : > You can certainly use let: > > reader <- forkIO $ let loop = do > (nr', line) <- readChan chan' > when (nr /= nr') $ hPutStrLn hdl line > loop > in loop > > But the version with fix is clearer (at least to people who have fix in > their vocabulary) and arguably better style. Would you mind presenting the better style argument? To me, the above could not be clearer, so it seems like the version with fix could be only as clear, at best. Thanks, Donn cave PS - granted that "forever" is a fine alternative to either, I suppose it doesn't affect the style comparison above. From lrpalmer at gmail.com Thu Mar 5 20:33:29 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Mar 5 20:22:01 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: <20090306012711.C7D9A276CBA@mail.avvanta.com> References: <1236298375.32464.26.camel@jcchost> <20090306012711.C7D9A276CBA@mail.avvanta.com> Message-ID: <7ca3f0160903051733y1e9c80ddn4af30284d73f9e@mail.gmail.com> On Thu, Mar 5, 2009 at 6:27 PM, Donn Cave wrote: > Quoth Jonathan Cast : > > > You can certainly use let: > > > > reader <- forkIO $ let loop = do > > (nr', line) <- readChan chan' > > when (nr /= nr') $ hPutStrLn hdl line > > loop > > in loop > > > > But the version with fix is clearer (at least to people who have fix in > > their vocabulary) and arguably better style. > > Would you mind presenting the better style argument? To me, the > above could not be clearer, so it seems like the version with fix > could be only as clear, at best. I like using fix when it's simple rather than let, because it tells me the purpose of the binding. eg., when I see let foo = ... Where ... is fairly long, I'm not sure what the purpose of foo is, or what its role is in the final computation. It may not be used at all, or passed to some modifier function, or I don't know what. Whereas with: fix $ \foo -> ... I know that whatever ... is, it is what is returne, and the purpose of foo is to use that return value in the expression itself. I know that it's a simple matter of scanning to the corresponding "in", but let can be used for a lot of things, where as fix $ \foo is basically only for simple knot-tying. Now, that doesn't say anything about the use of fix without an argument (passed to an HOF) or with a tuple as an argument or many other cases, which my brain has not chunked nearly as effectively. I think fix is best with a single, named argument. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/2bb1cbe1/attachment.htm From rj248842 at hotmail.com Thu Mar 5 21:32:31 2009 From: rj248842 at hotmail.com (R J) Date: Thu Mar 5 21:21:04 2009 Subject: [Haskell-cafe] Calculating with list comprehension Message-ID: I can calculate non-nested list comprehensions without a problem, but am unable to calculate nested comprehensions involving, for example, the generation of a list of pairs where the first and separate elements are drawn from two separate lists, as in: [(a, b) | a <- [1..3], b <- [1..2]] How does one calculate the expansion of this list? The two rules for expanding list comprehensions are: 1. Generator rule: [e | x <- xs, Q] = concat (map f xs) where f x = [e | Q] 2. Guard rule: [e | p, Q] = if p then [e | Q] else [] There is a third rule that I've seen on the Internet, not in an authoritative text: [e | Q1 , Q2] = concat [ [e | Q 2] | Q1 ] I don't understand what this third rule means, or whether it's relevant. Concat and map are defined as: concat :: [[a]] -> [a] concat [] = [] concat (xs:xss) = xs ++ concat xss map :: (a -> b) -> [a] -> [b] map f [] = [] map f (x:xs) = f x : (map f xs) Any help is appreciated. _________________________________________________________________ Windows Live?: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/cdbd6d22/attachment.htm From westondan at imageworks.com Thu Mar 5 22:14:38 2009 From: westondan at imageworks.com (Dan Weston) Date: Thu Mar 5 22:03:15 2009 Subject: [Haskell-cafe] Calculating with list comprehension In-Reply-To: References: Message-ID: <49B0951E.7040404@imageworks.com> Keep in mind this is a *lexical* rewrite. In the generator rule x and e are not independent: x is a pattern (which introduces a bind variable) and e is an expression (with free variables, one of which may be bound by x) After one application of the generator rule, we get (using a lambda expression instead of introducing a fresh function name f): concatMap (\a -> [(a,b) | b <- [1..2]]) [1..3] After another: concatMap (\a -> concatMap (\b -> [(a,b)]) [1..2]) [1..3] Note that the "a <-" and "b <-" map into \a -> and \b -> and bind the free variables a and b in the expression (a,b). Dan R J wrote: > I can calculate non-nested list comprehensions without a problem, but am > unable to calculate nested comprehensions involving, for example, the > generation of a list of pairs where the first and separate elements are > drawn from two separate lists, as in: > > [(a, b) | a <- [1..3], b <- [1..2]] > > How does one calculate the expansion of this list? The two rules for > expanding list comprehensions are: > > 1. Generator rule: [e | x <- xs, Q] = concat (map f xs) > where > f x = [e | Q] > > 2. Guard rule: [e | p, Q] = if p then [e | Q] else [] > > > There is a third rule that I've seen on the Internet, not in an > authoritative text: > > [e | Q1 , Q2] = concat [ [e | Q 2] | Q1 ] > > I don't understand what this third rule means, or whether it's relevant. > > Concat and map are defined as: > > concat :: [[a]] -> [a] > concat [] = [] > concat (xs:xss) = xs ++ concat xss > > map :: (a -> b) -> [a] -> [b] > map f [] = [] > map f (x:xs) = f x : (map f xs) > > Any help is appreciated. > > > > ------------------------------------------------------------------------ > Windows Live?: Keep your life in sync. Check it out. > > From dgorin at dc.uba.ar Thu Mar 5 23:13:16 2009 From: dgorin at dc.uba.ar (=?ISO-8859-1?Q?Daniel_Gor=EDn?=) Date: Thu Mar 5 23:01:57 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: <49B07BDD.3030501@gmail.com> References: <49B01E7D.6000207@gmail.com> <2f9b2d30903051325j1ba98cc3i755540e33671eaa5@mail.gmail.com> <49B05696.7010808@gmail.com> <105919D9-8547-4C50-B898-6590673D5EAF@dc.uba.ar> <49B07BDD.3030501@gmail.com> Message-ID: <52AD821E-7415-4EA3-AD6D-21D4C930E8B2@dc.uba.ar> Ok, so I've pulled the latest version and the error I get now is: Hackmain.hs:70:43: Ambiguous type variable `a' in the constraint: `Deliverable a' arising from a use of `getFilterMainStuff' at Hackmain.hs: 70:43-60 Probable fix: add a type signature that fixes these type variable(s) Function getFilterMainStuff compiles just fine . The offending line is in buildConf and reads: > (inboxL, fMain) <- runUnsafeInterpreter . getFilterMainStuff $ filterMainL The problem is that GHC can't figure out the type of fMain. It infers (Filter a), but doesn't know what is a and therefore how to build a proper dictionary to pass to getFilterMainStuff. Observe that you would get a similar error message if you just defined: > f = show . read I can get it to compile by providing a type annotation for fMain: > (inboxL, fMain) <- runUnsafeInterpreter . getFilterMainStuff $ filterMainL > let _ = fMain :: Filter MaildirEmail So once you use fMain somewhere and GHC can infer it's type, everything should work fine. Daniel On Mar 5, 2009, at 11:26 PM, Joseph Fredette wrote: > Oh, crap- I must have never pushed the latest patches, I did put the > typeable instances in all the appropriate places. And provided a > (maybe incorrect? Though I'm fairly sure that shouldn't affect the > bug I'm having now) Typeable implementation for Reader, but I still > get this ambiguous type. I'll push the current version asap. > > Thanks. > > /Joe > > Daniel Gor?n wrote: >> Hi >> >> I've downloaded Hackmain from patch-tag, but I'm getting a >> different error. The error I get is: >> >> Hackmain.hs:63:10: >> No instance for (Data.Typeable.Typeable2 >> Control.Monad.Reader.Reader) >> arising from a use of `interpret' at Hackmain.hs:63:10-67 >> >> Hint requires the interpreted values to be an instance of Typeable >> in order to check, in runtime, that the interpreted value matches >> the type declared at compile. Therefore, you need to make sure >> that (Filter a) is indeed an instance of Typeable. >> >> Since you have Filter a = Reader (Config, Email) a, you probably >> need to >> >> - Derive Config and Email instances for Filter, >> >> - Manually provide Typeable instances for Reader a b, something >> along the lines of: >> >> instance (Typeable a, Typeable b) => Typeable (Reader a b) where... >> >> (I don't know why this isn't done in the mtl....) >> >> - Change the signature to: >> >> getFilterMain :: (Typeable a, Deliverable a) => FilePath -> >> Interpreter (Filter a) >> >> Also, you can try using "infer" instead of "as :: ...." >> >> Hope that helps >> >> Daniel >> >> On Mar 5, 2009, at 8:47 PM, Joseph Fredette wrote: >> >>> So, I tried both of those things, both each alone and together. No >>> dice. Same error, so I reverted back to the >>> original. :( >>> However, I was, after some random type signature insertions, able >>> to convert the problem into a different one, via: >>> >>> getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter >>> a) getFilterMain MainLoc = do >>> loadModules [fMainLoc]; setTopLevelModules [(takeWhile (/ >>> ='.') fMainLoc)] fMain <- >>> (interpret "(filterMain)" infer) >>> return (fMain :: Deliverable a => Filter a) >>> >>> Inferred type is less polymorphic than expected >>> Quantified type variable `a' is mentioned in the environment: >>> fMain :: Filter a (bound at Hackmain.hs:77:1) >>> In the first argument of `return', namely >>> `(fMain :: (Deliverable a) => Filter a)' >>> In the expression: return (fMain :: (Deliverable a) => Filter a) >>> In the expression: >>> do loadModules [fMainLoc] >>> setTopLevelModules [(takeWhile (/= '.') fMainLoc)] >>> fMain <- (interpret "(filterMain)" infer) >>> return (fMain :: (Deliverable a) => Filter a) >>> I'm >>> thinking that this might be more easily solved -- I do think I >>> understand the issue. somehow, I need to tell the compiler >>> that the 'a' used in the return statement (return (fMain :: ...)) >>> is the same as the 'a' in the type sig for the whole function. >>> >>> While I ponder this, and hopefully receive some more help -- >>> thanks again Dan, Ryan -- Are there any other options besides Hint >>> that might -- at least in the short term -- make this easier? I'd >>> really like to finish this up. I'm _so_ close to getting it done. >>> >>> Thanks, >>> >>> /Joe >>> >>> Ryan Ingram wrote: >>>> So, by using the Haskell interpreter, you're using the >>>> not-very-well-supported dynamically-typed subset of Haskell. You >>>> can >>>> tell this from the type signature of "interpret": >>>> >>>> >>>>> interpret :: Typeable a => String -> a -> Interpreter a >>>>> >>>> >>>> >>>>> as :: Typeable a => a >>>>> as = undefined >>>>> >>>> >>>> (from http://hackage.haskell.org/packages/archive/hint/0.2.1/doc/html/src/Language-Haskell-Interpreter-GHC.html) >>>> >>>> In particular, the "as" argument to interpret is specifying what >>>> type >>>> you want the interpreted result to be typechecked against; the >>>> interpretation fails if it doesn't match that type. But you need >>>> the >>>> result type to be an instance of Typeable; (forall a. Deliverable >>>> a => >>>> Filter a) most certainly is not. >>>> >>>> >>>> Off the top of my head, you have a couple of directions you can >>>> take this. >>>> >>>> (1) Make Typeable a superclass of Deliverable, saying that all >>>> deliverable things must be dynamically typeable. Then derive >>>> Typeable >>>> on Filter, and have the result be of type "Filter a" using >>>> ScopedTypeVariables as suggested before. (You can also pass >>>> "infer" to >>>> the interpreter and let the compiler try to figure out the result >>>> type >>>> instead of passing (as :: SomeType).) >>>> >>>> (2) Make a newtype wrapper around Filter and give it an instance of >>>> Typeable, and add a constraint to filterMain that the result type >>>> in >>>> the filter is also typeable. Then unwrap the newtype after the >>>> interpreter completes. >>>> >>>> Good luck; I've never tried to use the Haskell interpreter >>>> before, so >>>> I'm curious how well it works and what problems you have with it! >>>> >>>> >>>> -- ryan >>>> >>>> 2009/3/5 Joseph Fredette : >>>> >>>>> I've been working on a little project, and one of the things I >>>>> need to do is >>>>> dynamically compile and import a Haskell Source file containing >>>>> filtering >>>>> definitions. I've written a small monad called Filter which is >>>>> simply: >>>>> >>>>> type Filter a = Reader (Config, Email) a >>>>> >>>>> To encompass all the email filtering. The method I need to import, >>>>> filterMain, has type: >>>>> >>>>> filterMain :: Deliverable a => Filter a >>>>> >>>>> where Deliverable is a type class which abstracts over delivery >>>>> to a path in >>>>> the file system. The notion is that I can write a type like: >>>>> >>>>> data DEmail = {email :: Email, path :: FilePath} >>>>> newtype Maildir = MD DEmail >>>>> >>>>> instance Deliverable Maildir where >>>>> {- ... omitted -} >>>>> >>>>> However, Filter a should not be restricted to Deliverable types- >>>>> it also >>>>> encompasses the results of regular expression matching, etc, >>>>> which are not >>>>> -- in general -- Deliverable instances. >>>>> >>>>> My question is this, when importing the file containing the >>>>> definitions of >>>>> filterMain, I have the following code to grab filterMain and >>>>> return it as a >>>>> function. >>>>> >>>>> getFilterMain :: Deliverable a => FilePath -> Interpreter >>>>> (Filter a) >>>>> getFilterMain fMainLoc = do >>>>> loadModules >>>>> [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] >>>>> fMain <- (interpret "(filterMain)" (as :: >>>>> Deliverable a >>>>> => Filter a)) return (fMain) >>>>> >>>>> However, when I try to >>>>> compile >>>>> this, I get the type error: >>>>> >>>>> Hackmain.hs:70:43: >>>>> Ambiguous type variable `a' in the constraint: >>>>> `Deliverable a' >>>>> arising from a use of `getFilterMainStuff' at >>>>> Hackmain.hs:70:43-60 >>>>> Probable fix: add a type signature that fixes these type >>>>> variable(s) >>>>> >>>>> My understanding is that a type like "Foo a => Bar a" (where Foo >>>>> is a class >>>>> and Bar is a datatype) would simply restrict >>>>> the values of a to only those implementing Foo. But evidently >>>>> I'm wrong. Is >>>>> there a good (read, easy... :) ) fix to this? >>>>> >>>>> Any help would be greatly appreciated. >>>>> >>>>> /Joe >>>>> >>>>> PS. All the actual code is on patch-tag, here >>>>> http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to >>>>> look at that >>>>> directly, the relevant files are in Src, namely, Hackmain.hs, >>>>> Filter.hs, and >>>>> Deliverable.hs >>>>> >>>>> _______________________________________________ >>>>> 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 allbery at ece.cmu.edu Thu Mar 5 23:13:49 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Mar 5 23:02:57 2009 Subject: [Haskell-cafe] Re: [Haskell] Lazy IO breaks purity In-Reply-To: <49AFCEB9.7090008@gmail.com> References: <20090305021220.7FC65AB11@Adric.metnet.fnmoc.navy.mil> <49AFCEB9.7090008@gmail.com> Message-ID: <20A6A553-CDBC-4BA9-820C-4F4575B77409@ece.cmu.edu> On 2009 Mar 5, at 8:08, Simon Marlow wrote: > So the argument is something like: we can think of the result of a > call to unsafeInterleaveIO as having been chosen at the time we > called unsafeInterleaveIO, rather than when its result is actually > evaluated. This is on dodgy ground, IMO: either you admit that the > IO monad contains an Oracle, or you admit it can time-travel. I > don't believe in either of those things :-) ...hasn't sigfpe demonstrated "time travel" using comonads? -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090305/19984472/PGP.bin From davidmiani at gmail.com Fri Mar 6 00:08:10 2009 From: davidmiani at gmail.com (David Miani) Date: Thu Mar 5 23:56:53 2009 Subject: [Haskell-cafe] Difficulties in accessing inner elements of data types In-Reply-To: <3c6288ab0903051722l27f7f582u2a29a3b05ccccce9@mail.gmail.com> References: <200903032057.57448.davidmiani@gmail.com> <3c6288ab0903051722l27f7f582u2a29a3b05ccccce9@mail.gmail.com> Message-ID: <200903061508.10804.davidmiani@gmail.com> Well thanks to everyone that has replied so far - I've had an interesting time trying out different ideas. Firstly, for Neil Mitchell's suggestions regarding uniplate: I read through both uniplate and scrap your boilerplate libraries (found the second after reading about uniplate). For whatever reason, I understood syb better than uniplate (but thats probably just me). This actually worked quite well (note that I've changed the data types slightly, but it doesn't change the code that much): eitherOr :: Either a b -> Either a b -> Either a b eitherOr x@(Right _) _ = x eitherOr _ y = y getP14Desc :: OrgElement -> Either ErrString String getP14Desc org = everything eitherOr (Left descError `mkQ` findDesc) =<< everything eitherOr (Left findError `mkQ` findP14) org where findP14 h@(Heading {headingName=name}) | name == "Project14" = Right h findP14 _ = Left findError findDesc (Paragraph {paragraphText=text}) | text =~ "Description" = Right text findDesc _ = Left findError descError = "Couldn't find description for project" findError = "Couldn't find project." While it isn't that many less loc than my original code, it was much simpler to get working. Also, the find methods could easily be factored out. My second problem, adding the tag "Hard" to Project2 was also fairly simple: addHardTag org = everywhere (mkT addTagToP2) org where addTagToP2 h@(Heading {headingName=name}) | name == "Project 2" = everywhere (mkT addTag) h addTagToP2 x = x addTag text | text =~ "Tags:" = text ++ ",newtag" However, I also wanted to try out Tim Docker's suggestion for using data- accessor. That seemed to also be very promising, except for one thing - data- accessor doesn't seem to be able to cope with multiple constructors! The code for this was faily simple though, so I went about making it work for multiple constructors. The original definition for an Accessor d f (where d is the datatype and f is the type of the field) was Cons {decons :: d -> f -> (d, f)} -- (this wasn't exported by the module though) There is a problem with that for multiple constructors though - its possible that there will be no return for a given accessor. Eg running get headingName' (Paragraph "some text") would not be possible. So I changed the code to this: newtype Accessor1 d f = Accessor (d -> Maybe f, f -> d -> d) If the getter failed, Nothing is returned. If the setter failed, it acts like id. After using that for a while I realized there was potential to have an accessor automatically access all the children of a data type. This could be achieved by changing the return type of the getter to [f], and changing the setter function to a modifier function: newtype MultiConAccessor d f = MultiConAccessor ((d -> [f]),((f -> f) -> d -> d)) I also wrote the chain function, which joins to accessors together After a lot of definitions (although most should be able to be automated with template haskell), I could use the code: projectAccessor name = headingChildren' `chain` -- top level elements headingChildren' `chain` -- level 2 liftFilterS (== name) headingName' getP14Desc2 = getVal $ projectAccessor "Project14" `chain` headingChildren' `chain` liftFilterS (=~ "Description:") paragraphText' `chain` paragraphText' addHardTag2 = modVal (projectAccessor "Project 2" `chain` headingChildren' `chain` liftFilterS (=~ "Tags:") paragraphText' `chain` paragraphText') (++ ",newtag") I've posted all the code at http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=1778#a1778 It isn't very well documented, as I was just experimenting with this. Finally, thanks Sean for your response. That blog post was very nice! Your solution also looks good (especially since most of the code was automated). I haven't had a chance to have a close look at EMGM but will in the next couple of days. So I've gone from having no solution a few days ago to having 3 or 4 now! Not sure which solution I will stick with, any seem to do the job. So thanks everyone! David From dmehrtash at gmail.com Fri Mar 6 03:48:19 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Fri Mar 6 03:36:51 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: <7ca3f0160903051733y1e9c80ddn4af30284d73f9e@mail.gmail.com> References: <1236298375.32464.26.camel@jcchost> <20090306012711.C7D9A276CBA@mail.avvanta.com> <7ca3f0160903051733y1e9c80ddn4af30284d73f9e@mail.gmail.com> Message-ID: Two questions: a) This chat server implementation doesn't actually close the connection as a real one would need to do. If you use "forever" is there a way to end the loop so as to end the connection? b) In Section 5 of this paper: http://www.cs.yale.edu/~hl293/download/leak.pdf Comparing the definition of eSF and e reveals that the primary difference is > in > the fixed-point operators they use. e uses Haskell?s built-in fixed-point > operator, > which is equivalent to the standard: > > fix f = f (fix f) > eSF, on the other hand, is defined in terms of the loop combinator, which > ties the loop > tighter than the standard fixed-point operator. In particular, note in > Figure 6 that > loop computes the value-level fixed point as z, but re-uses itself in the > continuation > part. This is the key to avoiding the space leak. > My reading is that the fix operator, at least in some cases, causes space leak. Where as the arrow's loop, which uses "let" model, doesn't have this issue. Question: Do I need to worry about space leak if I am using the fix to instead of the "let"? Thanks Daryoush 2009/3/5 Luke Palmer > On Thu, Mar 5, 2009 at 6:27 PM, Donn Cave wrote: > >> Quoth Jonathan Cast : >> >> > You can certainly use let: >> > >> > reader <- forkIO $ let loop = do >> > (nr', line) <- readChan chan' >> > when (nr /= nr') $ hPutStrLn hdl line >> > loop >> > in loop >> > >> > But the version with fix is clearer (at least to people who have fix in >> > their vocabulary) and arguably better style. >> >> Would you mind presenting the better style argument? To me, the >> above could not be clearer, so it seems like the version with fix >> could be only as clear, at best. > > > I like using fix when it's simple rather than let, because it tells me the > purpose of the binding. eg., when I see > > let foo = ... > > Where ... is fairly long, I'm not sure what the purpose of foo is, or what > its role is in the final computation. It may not be used at all, or passed > to some modifier function, or I don't know what. Whereas with: > > fix $ \foo -> ... > > I know that whatever ... is, it is what is returne, and the purpose of foo > is to use that return value in the expression itself. > > I know that it's a simple matter of scanning to the corresponding "in", but > let can be used for a lot of things, where as fix $ \foo is basically only > for simple knot-tying. Now, that doesn't say anything about the use of fix > without an argument (passed to an HOF) or with a tuple as an argument or > many other cases, which my brain has not chunked nearly as effectively. I > think fix is best with a single, named argument. > > Luke > > _______________________________________________ > 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/20090306/ef5b6d4c/attachment.htm From lennart at augustsson.net Fri Mar 6 04:04:25 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri Mar 6 03:53:35 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: References: Message-ID: Personally I would not use fix. I don't think it improves readability. -- Lennart 2009/3/5 Daryoush Mehrtash : > In this chat server implementation > http://www.haskell.org/haskellwiki/Implement_a_chat_server > > forkIO is used with fix as in: > > reader <- forkIO $ fix $ \loop -> do > > (nr', line) <- readChan chan' > when (nr /= nr') $ hPutStrLn hdl line > > loop > > Do you have to use fix?? Or is there a way to write this with a "let"? > > -- > Daryoush > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From Alistair.Bayley at invesco.com Fri Mar 6 04:08:00 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Mar 6 03:56:36 2009 Subject: [Haskell-cafe] Haskell Logo Voting will start soon! In-Reply-To: References: Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025EE7@GBLONXMB02.corp.amvescap.net> > The voting system we'll use is the Condorcet Internet Voting > System (http://www.cs.cornell.edu/andru/civs.html > ). The poll won't be public, but every subscriber to Haskell-Cafe > will get a (private) voting ballot by email. > I'll supervise the poll and make sure it's started, stopped and all > Haskell-Cafe subscribers get a ballot (Simon Marlow provided > the email addresses). > I'd love to hear about anything that I missed and/or that might > influence the voting process in a significant way. (There are > probably some people subscribed with multiple addresses, but I'll be > using the subscriber list from yesterday, so signing up now > with lots of addresses won't get you more ballots ;) I was wondering if you were addressing duplication. I've been subscribed to caf? for a long time with at least two email addresses (work and home) but I don't think I should be getting two votes. 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 gleb.alexeev at gmail.com Fri Mar 6 04:12:40 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Fri Mar 6 04:01:17 2009 Subject: [Haskell-cafe] Re: Interesting problem from Bird (4.2.13) In-Reply-To: References: Message-ID: Gleb Alexeyev wrote: > instance Eq a => Eq (CatList a) where > a == b = case (viewCL a, viewCL b) of > (Just (x, xs), Just (y, ys)) -> x==y && xs == ys > (Nothing, Nothing) -> True > _ -> False I just realized that my solution is needlessly verbose, the following instance suffices: > instance Eq a => Eq (CatList a) where > a == b = viewCL a == viewCL b From magnus at therning.org Fri Mar 6 04:16:55 2009 From: magnus at therning.org (Magnus Therning) Date: Fri Mar 6 04:05:28 2009 Subject: [Haskell-cafe] Haskell Logo Voting will start soon! In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025EE7@GBLONXMB02.corp.amvescap.net> References: <125EACD0CAE4D24ABDB4D148C4593DA911025EE7@GBLONXMB02.corp.amvescap.net> Message-ID: On Fri, Mar 6, 2009 at 9:08 AM, Bayley, Alistair wrote: >> The voting system we'll use is the Condorcet Internet Voting >> System (http://www.cs.cornell.edu/andru/civs.html >> ). ?The poll won't be public, but every subscriber to Haskell-Cafe >> will get a (private) voting ballot by email. > >> I'll supervise the poll and make sure it's started, stopped and all >> Haskell-Cafe subscribers get a ballot (Simon Marlow provided >> the email addresses). > >> I'd love to hear about anything that I missed and/or that might >> influence the voting process in a significant way. ?(There are >> probably some people subscribed with multiple addresses, but I'll be >> using the subscriber list from yesterday, so signing up now >> with lots of addresses won't get you more ballots ;) > > I was wondering if you were addressing duplication. I've been subscribed to caf? for a long time with at least two email addresses (work and home) but I don't think I should be getting two votes. Given the size of the group, and the extremely high standard of the members when it comes to moral fibre, common sense, intelligense, etc, etc, do we really need to enforce prevention of duplication? :-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From Alistair.Bayley at invesco.com Fri Mar 6 04:26:31 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Mar 6 04:15:04 2009 Subject: [Haskell-cafe] Haskell Logo Voting will start soon! In-Reply-To: References: <125EACD0CAE4D24ABDB4D148C4593DA911025EE7@GBLONXMB02.corp.amvescap.net> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025EE8@GBLONXMB02.corp.amvescap.net> > >> I'd love to hear about anything that I missed and/or that might > >> influence the voting process in a significant way. ?(There are > >> probably some people subscribed with multiple addresses, > but I'll be > >> using the subscriber list from yesterday, so signing up now > >> with lots of addresses won't get you more ballots ;) > > > > I was wondering if you were addressing duplication. I've > been subscribed to caf? for a long time with at least two > email addresses (work and home) but I don't think I should be > getting two votes. > > Given the size of the group, and the extremely high standard of the > members when it comes to moral fibre, common sense, intelligense, etc, > etc, do we really need to enforce prevention of duplication? Well, that is one possible solution (let it ride). I don't know what the level of email address duplication is, so I don't know the risk. Voting systems generally have to make a lot of effort to be fair, otherwise detractors can reasonably claim that the result is not valid. And as this is somewhat of a bike-shed level decision, you should expect a great deal of interest and passion! 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 Fri Mar 6 04:26:57 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Mar 6 04:15:41 2009 Subject: [Haskell-cafe] Re: [Haskell] Lazy IO breaks purity In-Reply-To: <49AFCEB9.7090008@gmail.com> References: <20090305021220.7FC65AB11@Adric.metnet.fnmoc.navy.mil> <49AFCEB9.7090008@gmail.com> Message-ID: <1236331617.22402.233.camel@localhost> On Thu, 2009-03-05 at 13:08 +0000, Simon Marlow wrote: > Lennart Augustsson wrote: > > I don't see any breaking of referential transparence in your code. > > Every time you do an IO operation the result is basically > > non-deterministic since you are talking to the outside world. > > You're assuming the IO has some kind of semantics that Haskell makes > > no promises about. > > > > I'm not saying that this isn't a problem, because it is. > > But it doesn't break referential transparency, it just makes the > > semantics of IO even more complicated. > > > > (I don't have a formal proof that unsafeInterleaveIO cannot break RT, > > but I've not seen an example where it does yet.) > > So the argument is something like: we can think of the result of a call to > unsafeInterleaveIO as having been chosen at the time we called > unsafeInterleaveIO, rather than when its result is actually evaluated. But surely that is the mistake. With IO, bound values depend solely on the effects that happened previously (no time travel). With ordinary sequential IO, that's easy to understand and explain because the binding and the effects happen at the same time/place. The extension to unsafeInterleaveIO is not to pretend that the value is chosen at the point it is bound. The value depends on the effects not the binding. The extension is that we separate the binding point and the effects. The effects can be arbitrarily interleaved with other effects. The value we get does potentially depend on all those prior effects. The arbitrary interleaving of effects is obviously weaker than them happening now, in sequence, before the next action. This works well when the deferred side effect do not interfere with other side effects and is non-deterministic when they do interfere, as in Oleg's example. It doesn't break referential transparency though, thanks to memoisation we only observe one final value. The standard libs, being sensible, mostly only use unsafeInterleaveIO in the cases where we expect little interference. Note how Oleg has to go out of his way to construct the example, circumventing the semi-closed Handle state which was designed to stop people from shooting themselves in the foot. There used to be a real example where unsafeInterleaveIO did break referential transparency. That was due to concurrency and lack of locking. http://hackage.haskell.org/trac/ghc/ticket/986 When the bug was around there was a *single* pure value that if used by two different threads could be observed to be different. There's nothing similar happening here. Duncan From bugfact at gmail.com Fri Mar 6 05:17:50 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Mar 6 05:06:22 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics Message-ID: Regarding hpysics, did anybody did some experiments with this? The blog seems to be inactive since december 2008; has development ceased? Do alternatives exist? Maybe good wrappers (hopefully pure...) around existing engines? Integrating hpysics with Grapefruit might be a good topic for the Hackaton, trying to make a simple game (e.g. Pong or Breakout) without using recursive signal functions, but with correct collision response and better-than-Euler integration, all handled by the physics engine. Other FRP engines could be tried, but Grapefruit hacking is already a topic on the Hackaton, so it would combine efforts. It feels as if none of the current FRP engines can handle physics correctly, since a typical physics implementations requires "time backtracking", in the sense that when you want to advance the current simulation time by a timestep, collision events can happen during that time interval, and hence the FRP engine can only advance time until the earliest collision event. So to do physics *with* an FRP engine, the implementation and maybe even semantics of the FRP system might need to be changed. *Using* a physics engine as a blackbox inside an FRP system might make more sense. Thanks to Wolfgang Jeltsch and Christopher Lane Hinson for having a discussion with me that lead to this. Interestingly a similar discussion was help by other people in the Reactive mailing list at the same time :-) Cheers, Peter Verswyvelen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/8afacf3f/attachment.htm From eelco at lempsink.nl Fri Mar 6 05:40:46 2009 From: eelco at lempsink.nl (Eelco Lempsink) Date: Fri Mar 6 05:29:23 2009 Subject: [Haskell-cafe] Re: Haskell Logo Voting will start soon! In-Reply-To: <20090306000351.61146bca@solaris> References: <20090306000351.61146bca@solaris> Message-ID: <96AEB170-00EB-4FCD-BD18-3C04E14210C4@lempsink.nl> On 6 mrt 2009, at 00:03, Achim Schneider wrote: > Eelco Lempsink wrote: > >> The poll won't be public, but every subscriber to Haskell-Cafe >> will get a (private) voting ballot by email. >> > What about us gmane users? Good point! All of you can send me your email address (directly, please don't use the group/list) if you want to participate. I'll merge that with the subscribers list. Please include "haskell logo voting ballot request" in the subject or body and write a small but unique message so I can (more or less) check you're not just trying to get extra votes and to make it more likely it passes my spamfilter (I'll check my spamfolder, but with the thousands messages a day pouring in to it I might miss your message). As Magnus Therning remarked, I also trust "the size of the group, and the extremely high standard of the members when it comes to moral fibre, common sense, intelligense, etc" to prevent duplication or at least a significant impact on the result ;) Consider yourself added to the ballot list, Achim, and thanks for bringing this point up. -- Regards, Eelco Lempsink -------------- 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/20090306/6170d202/PGP.bin From jeanchristophe.mincke at gmail.com Fri Mar 6 05:59:01 2009 From: jeanchristophe.mincke at gmail.com (jean-christophe mincke) Date: Fri Mar 6 05:47:36 2009 Subject: [Haskell-cafe] Re: [reactive] FRP + physics / status of hpysics In-Reply-To: References: Message-ID: Hello Peter, The backtraking in time to solve the collision problem you mentionned is not, in my opinion, efficient. >From a previous life as an aerospace engineer, I remember that two other solutions exist to handle contact or collision constraints, at least if 2nd order diff. equations are used to describe the motion of a solid with mass. In any case, you have to use a 'serious' variable time step integration algorithm (I.E Runge-Kutta). 1. The naive one: introduce a (virtual) spring between every 2 objets that may collide. When these objets get closer, the spring is compressed and tries to push them back. If the mass/velocity are high, that leads to a stiff system and the time steps may become very small. However, this solution does not require any modification of the equations of motion. 2. The serious one: modify or augment the equations of motion so that the collision constraints are implicitly taken into account. If I remember well, the magical trick is to use langrangian multipliers. The difficult here (especially in the context of aFRP) is to derive the new equations. Hope it helps Regards Jean-Christophe Mincke 2009/3/6 Peter Verswyvelen > Regarding hpysics, did anybody did some experiments with this? The blog > seems to be inactive since december 2008; has development ceased? > Do alternatives exist? Maybe good wrappers (hopefully pure...) around > existing engines? > > Integrating hpysics with Grapefruit might be a good topic for the Hackaton, > trying to make a simple game (e.g. Pong or Breakout) without using recursive > signal functions, but with correct collision response and better-than-Euler > integration, all handled by the physics engine. Other FRP engines could be > tried, but Grapefruit hacking is already a topic on the Hackaton, so it > would combine efforts. > > It feels as if none of the current FRP engines can handle physics > correctly, since a typical physics implementations requires "time > backtracking", in the sense that when you want to advance the current > simulation time by a timestep, collision events can happen during that time > interval, and hence the FRP engine can only advance time until the earliest > collision event. So to do physics *with* an FRP engine, the implementation > and maybe even semantics of the FRP system might need to be changed. *Using* > a physics engine as a blackbox inside an FRP system might make more sense. > > Thanks to Wolfgang Jeltsch and Christopher Lane Hinson for having a > discussion with me that lead to this. Interestingly a similar discussion > was help by other people in the Reactive mailing list at the same time :-) > > Cheers, > Peter Verswyvelen > > > > > > > _______________________________________________ > Reactive mailing list > Reactive@haskell.org > http://www.haskell.org/mailman/listinfo/reactive > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/0c1fb7a6/attachment.htm From sanzhiyan at gmail.com Fri Mar 6 06:00:08 2009 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Fri Mar 6 05:48:40 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: References: <1236298375.32464.26.camel@jcchost> <20090306012711.C7D9A276CBA@mail.avvanta.com> <7ca3f0160903051733y1e9c80ddn4af30284d73f9e@mail.gmail.com> Message-ID: <8625cd9c0903060300peffd4abyc269c99d88c3938b@mail.gmail.com> 2009/3/6 Daryoush Mehrtash : > Two questions: > > a)?? This? chat server implementation doesn't actually close the connection > as a real one would need to do.? If you use "forever"? is there a way to end > the loop so as to end the connection? Yes, throw an exception and catch it from outside the forever. > b) In Section 5 of this paper: > http://www.cs.yale.edu/~hl293/download/leak.pdf > >> Comparing the definition of eSF and e reveals that the primary difference >> is in >> the fixed-point operators they use. e uses Haskell?s built-in fixed-point >> operator, >> which is equivalent to the standard: >> >> fix f = f (fix f) >> eSF, on the other hand, is defined in terms of the loop combinator, which >> ties the loop >> tighter than the standard fixed-point operator. In particular, note in >> Figure 6 that >> loop computes the value-level fixed point as z, but re-uses itself in the >> continuation >> part. This is the key to avoiding the space leak. > > My reading is that the fix operator, at least in some cases, causes space > leak.?? Where as the arrow's loop, which uses "let" model,?? doesn't have > this issue. > > Question:? Do I need to worry about space leak if I am using the fix to > instead of the "let"? the definition of fix in Data.Function[1] actually uses let: fix :: (a -> a) -> a fix f = let x = f x in x [1] http://darcs.haskell.org/packages/base/Data/Function.hs > Thanks > > Daryoush > 2009/3/5 Luke Palmer >> >> On Thu, Mar 5, 2009 at 6:27 PM, Donn Cave wrote: >>> >>> Quoth Jonathan Cast : >>> >>> > You can certainly use let: >>> > >>> > ? reader <- forkIO $ let loop = do >>> > ? ? ? (nr', line) <- readChan chan' >>> > ? ? ? when (nr /= nr') $ hPutStrLn hdl line >>> > ? ? ? loop >>> > ? ? in loop >>> > >>> > But the version with fix is clearer (at least to people who have fix in >>> > their vocabulary) and arguably better style. >>> >>> Would you mind presenting the better style argument? ?To me, the >>> above could not be clearer, so it seems like the version with fix >>> could be only as clear, at best. >> >> I like using fix when it's simple rather than let, because it tells me the >> purpose of the binding. ?eg., when I see >> ?? ?let foo = ... >> Where ... is fairly long, I'm not sure what the purpose of foo is, or what >> its role is in the final computation. ?It may not be used at all, or passed >> to some modifier function, or I don't know what. ?Whereas with: >> ?? fix $ \foo -> ... >> I know that whatever ... is, it is what is returne, and the purpose of foo >> is to use that return value in the expression itself. >> I know that it's a simple matter of scanning to the corresponding "in", >> but let can be used for a lot of things, where as fix $ \foo is basically >> only for simple knot-tying. ?Now, that doesn't say anything about the use of >> fix without an argument (passed to an HOF) or with a tuple as an argument or >> many other cases, which my brain has not chunked nearly as effectively. ?I >> think fix is best with a single, named argument. >> Luke >> _______________________________________________ >> 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 dgorin at dc.uba.ar Fri Mar 6 06:25:05 2009 From: dgorin at dc.uba.ar (=?ISO-8859-1?Q?Daniel_Gor=EDn?=) Date: Fri Mar 6 06:13:47 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: <49B0A78A.5050006@gmail.com> References: <49B01E7D.6000207@gmail.com> <2f9b2d30903051325j1ba98cc3i755540e33671eaa5@mail.gmail.com> <49B05696.7010808@gmail.com> <105919D9-8547-4C50-B898-6590673D5EAF@dc.uba.ar> <49B07BDD.3030501@gmail.com> <52AD821E-7415-4EA3-AD6D-21D4C930E8B2@dc.uba.ar> <49B0A78A.5050006@gmail.com> Message-ID: I think you can achieve what you want but you need to use the correct types for it. Remember that when you write: getFilterMainStuff :: Deliverable a => FilePath -> Interpreter (Path, Filter a) the proper way to read the signature is "the caller of getFilterMainStuff is entitled to pick the type of a, as long as it picks an instance of Deliverable". Contrast this with a method declaration in Java where: public Set getKeys() is to be read: "The invoked object may pick the type of the result, as long as it is a subclass of (or implements) Set". When you say that you want "to apply fMain to a (Config, Email) and get back a Deliverable a", I think you mean that fMain picks the type for a (and has to be an instance of Deliverable). There two ways to do this in Haskell: 1) You don't. If you know that your possible Deliverables are just FlatEmail and MaildirEmail, then the idiomatic way of doing this would be to turn Deliverable into an ADT: data Deliverable = FlatEmail .... | MaildirEmail .... deriving (Typeable) getFilterMainStuff :: FilePath -> Interpreter (Path, Filter Deliverable) 2) Existential types. If, for some reason, you need your "dynamic code" to be able to define new "deliverables", then you need to use the extension called "existential types". -- using GADT syntax data SomeDeliverable where Wrap :: Deliverable a => a -> SomeDeliverable getFilterMainStuff :: FilePath -> Interpreter (Path, Filter SomeDeliverable) This basically resembles the contract of the Java world: if you run fMain you will get a value of type SomeDeliverable; you can pattern- match it and will get something whose actual type you don't know, but that it is an instance of class Deliverable. See http://www.haskell.org/haskellwiki/Existential_type Good luck! Daniel On Mar 6, 2009, at 2:33 AM, Joseph Fredette wrote: > Okay, I think I understand... I got so hung up thinking the error > had to be in the Interpreter code, I didn't bother to look in the > caller... > > But every answer breeds another question... The practical reason for > inferring fMain as being of type "Deliverable a => Filter a", is to > apply it (via runReader) to a (Config, Email) and get back a > Deliverable a, then to use the deliverIO method on the result -- my > question is, it appears I have to "know" the specific type of a in > order to get the thing to typecheck, but in order to use it, I need > to not know it... > > Perhaps, in fact, I'm doing this wrong. Thanks for the help Daniel, > everyone... > > /Joe > > Daniel Gor?n wrote: >> Ok, so I've pulled the latest version and the error I get now is: >> >> Hackmain.hs:70:43: >> Ambiguous type variable `a' in the constraint: >> `Deliverable a' >> arising from a use of `getFilterMainStuff' at Hackmain.hs: >> 70:43-60 >> Probable fix: add a type signature that fixes these type >> variable(s) >> >> Function getFilterMainStuff compiles just fine . The offending line >> is in buildConf and reads: >> >> > (inboxL, fMain) <- runUnsafeInterpreter . getFilterMainStuff $ >> filterMainL >> >> The problem is that GHC can't figure out the type of fMain. It >> infers (Filter a), but doesn't know what is a and therefore how to >> build a proper dictionary to pass to getFilterMainStuff. >> >> Observe that you would get a similar error message if you just >> defined: >> >> > f = show . read >> >> I can get it to compile by providing a type annotation for fMain: >> >> > (inboxL, fMain) <- runUnsafeInterpreter . getFilterMainStuff $ >> filterMainL >> > let _ = fMain :: Filter MaildirEmail >> >> So once you use fMain somewhere and GHC can infer it's type, >> everything should work fine. >> >> Daniel >> >> On Mar 5, 2009, at 11:26 PM, Joseph Fredette wrote: >> >>> Oh, crap- I must have never pushed the latest patches, I did put >>> the typeable instances in all the appropriate places. And provided >>> a (maybe incorrect? Though I'm fairly sure that shouldn't affect >>> the bug I'm having now) Typeable implementation for Reader, but I >>> still get this ambiguous type. I'll push the current version asap. >>> >>> Thanks. >>> >>> /Joe >>> >>> Daniel Gor?n wrote: >>>> Hi >>>> >>>> I've downloaded Hackmain from patch-tag, but I'm getting a >>>> different error. The error I get is: >>>> >>>> Hackmain.hs:63:10: >>>> No instance for (Data.Typeable.Typeable2 >>>> Control.Monad.Reader.Reader) >>>> arising from a use of `interpret' at Hackmain.hs:63:10-67 >>>> >>>> Hint requires the interpreted values to be an instance of >>>> Typeable in order to check, in runtime, that the interpreted >>>> value matches the type declared at compile. Therefore, you need >>>> to make sure that (Filter a) is indeed an instance of Typeable. >>>> >>>> Since you have Filter a = Reader (Config, Email) a, you probably >>>> need to >>>> >>>> - Derive Config and Email instances for Filter, >>>> >>>> - Manually provide Typeable instances for Reader a b, something >>>> along the lines of: >>>> >>>> instance (Typeable a, Typeable b) => Typeable (Reader a b) where... >>>> >>>> (I don't know why this isn't done in the mtl....) >>>> >>>> - Change the signature to: >>>> >>>> getFilterMain :: (Typeable a, Deliverable a) => FilePath -> >>>> Interpreter (Filter a) >>>> >>>> Also, you can try using "infer" instead of "as :: ...." >>>> >>>> Hope that helps >>>> >>>> Daniel >>>> >>>> On Mar 5, 2009, at 8:47 PM, Joseph Fredette wrote: >>>> >>>>> So, I tried both of those things, both each alone and together. >>>>> No dice. Same error, so I reverted back to the >>>>> original. :( >>>>> However, I was, after some random type signature insertions, >>>>> able to convert the problem into a different one, via: >>>>> >>>>> getFilterMain :: Deliverable a => FilePath -> Interpreter >>>>> (Filter a) getFilterMain MainLoc = do >>>>> loadModules [fMainLoc]; setTopLevelModules [(takeWhile (/ >>>>> ='.') fMainLoc)] fMain <- >>>>> (interpret "(filterMain)" infer) >>>>> return (fMain :: Deliverable a => Filter a) >>>>> >>>>> Inferred type is less polymorphic than expected >>>>> Quantified type variable `a' is mentioned in the environment: >>>>> fMain :: Filter a (bound at Hackmain.hs:77:1) >>>>> In the first argument of `return', namely >>>>> `(fMain :: (Deliverable a) => Filter a)' >>>>> In the expression: return (fMain :: (Deliverable a) => Filter a) >>>>> In the expression: >>>>> do loadModules [fMainLoc] >>>>> setTopLevelModules [(takeWhile (/= '.') fMainLoc)] >>>>> fMain <- (interpret "(filterMain)" infer) >>>>> return (fMain :: (Deliverable a) => Filter a) >>>>> I'm >>>>> thinking that this might be more easily solved -- I do think I >>>>> understand the issue. somehow, I need to tell the compiler >>>>> that the 'a' used in the return statement (return >>>>> (fMain :: ...)) is the same as the 'a' in the type sig for the >>>>> whole function. >>>>> >>>>> While I ponder this, and hopefully receive some more help -- >>>>> thanks again Dan, Ryan -- Are there any other options besides >>>>> Hint that might -- at least in the short term -- make this >>>>> easier? I'd really like to finish this up. I'm _so_ close to >>>>> getting it done. >>>>> >>>>> Thanks, >>>>> >>>>> /Joe >>>>> >>>>> Ryan Ingram wrote: >>>>>> So, by using the Haskell interpreter, you're using the >>>>>> not-very-well-supported dynamically-typed subset of Haskell. >>>>>> You can >>>>>> tell this from the type signature of "interpret": >>>>>> >>>>>> >>>>>>> interpret :: Typeable a => String -> a -> Interpreter a >>>>>>> >>>>>> >>>>>> >>>>>>> as :: Typeable a => a >>>>>>> as = undefined >>>>>>> >>>>>> >>>>>> (from http://hackage.haskell.org/packages/archive/hint/0.2.1/doc/html/src/Language-Haskell-Interpreter-GHC.html) >>>>>> >>>>>> In particular, the "as" argument to interpret is specifying >>>>>> what type >>>>>> you want the interpreted result to be typechecked against; the >>>>>> interpretation fails if it doesn't match that type. But you >>>>>> need the >>>>>> result type to be an instance of Typeable; (forall a. >>>>>> Deliverable a => >>>>>> Filter a) most certainly is not. >>>>>> >>>>>> >>>>>> Off the top of my head, you have a couple of directions you can >>>>>> take this. >>>>>> >>>>>> (1) Make Typeable a superclass of Deliverable, saying that all >>>>>> deliverable things must be dynamically typeable. Then derive >>>>>> Typeable >>>>>> on Filter, and have the result be of type "Filter a" using >>>>>> ScopedTypeVariables as suggested before. (You can also pass >>>>>> "infer" to >>>>>> the interpreter and let the compiler try to figure out the >>>>>> result type >>>>>> instead of passing (as :: SomeType).) >>>>>> >>>>>> (2) Make a newtype wrapper around Filter and give it an >>>>>> instance of >>>>>> Typeable, and add a constraint to filterMain that the result >>>>>> type in >>>>>> the filter is also typeable. Then unwrap the newtype after the >>>>>> interpreter completes. >>>>>> >>>>>> Good luck; I've never tried to use the Haskell interpreter >>>>>> before, so >>>>>> I'm curious how well it works and what problems you have with it! >>>>>> >>>>>> >>>>>> -- ryan >>>>>> >>>>>> 2009/3/5 Joseph Fredette : >>>>>> >>>>>>> I've been working on a little project, and one of the things I >>>>>>> need to do is >>>>>>> dynamically compile and import a Haskell Source file >>>>>>> containing filtering >>>>>>> definitions. I've written a small monad called Filter which is >>>>>>> simply: >>>>>>> >>>>>>> type Filter a = Reader (Config, Email) a >>>>>>> >>>>>>> To encompass all the email filtering. The method I need to >>>>>>> import, >>>>>>> filterMain, has type: >>>>>>> >>>>>>> filterMain :: Deliverable a => Filter a >>>>>>> >>>>>>> where Deliverable is a type class which abstracts over >>>>>>> delivery to a path in >>>>>>> the file system. The notion is that I can write a type like: >>>>>>> >>>>>>> data DEmail = {email :: Email, path :: FilePath} >>>>>>> newtype Maildir = MD DEmail >>>>>>> >>>>>>> instance Deliverable Maildir where >>>>>>> {- ... omitted -} >>>>>>> >>>>>>> However, Filter a should not be restricted to Deliverable >>>>>>> types- it also >>>>>>> encompasses the results of regular expression matching, etc, >>>>>>> which are not >>>>>>> -- in general -- Deliverable instances. >>>>>>> >>>>>>> My question is this, when importing the file containing the >>>>>>> definitions of >>>>>>> filterMain, I have the following code to grab filterMain and >>>>>>> return it as a >>>>>>> function. >>>>>>> >>>>>>> getFilterMain :: Deliverable a => FilePath -> Interpreter >>>>>>> (Filter a) >>>>>>> getFilterMain fMainLoc = do >>>>>>> loadModules >>>>>>> [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] >>>>>>> fMain <- (interpret "(filterMain)" (as :: >>>>>>> Deliverable a >>>>>>> => Filter a)) return (fMain) >>>>>>> >>>>>>> However, when I try to >>>>>>> compile >>>>>>> this, I get the type error: >>>>>>> >>>>>>> Hackmain.hs:70:43: >>>>>>> Ambiguous type variable `a' in the constraint: >>>>>>> `Deliverable a' >>>>>>> arising from a use of `getFilterMainStuff' at >>>>>>> Hackmain.hs:70:43-60 >>>>>>> Probable fix: add a type signature that fixes these type >>>>>>> variable(s) >>>>>>> >>>>>>> My understanding is that a type like "Foo a => Bar a" (where >>>>>>> Foo is a class >>>>>>> and Bar is a datatype) would simply restrict >>>>>>> the values of a to only those implementing Foo. But evidently >>>>>>> I'm wrong. Is >>>>>>> there a good (read, easy... :) ) fix to this? >>>>>>> >>>>>>> Any help would be greatly appreciated. >>>>>>> >>>>>>> /Joe >>>>>>> >>>>>>> PS. All the actual code is on patch-tag, here >>>>>>> http://patch-tag.com/repo/Hackmail/home -- if anyone prefers >>>>>>> to look at that >>>>>>> directly, the relevant files are in Src, namely, Hackmain.hs, >>>>>>> Filter.hs, and >>>>>>> Deliverable.hs >>>>>>> >>>>>>> _______________________________________________ >>>>>>> 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 bugfact at gmail.com Fri Mar 6 07:01:41 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Mar 6 06:50:14 2009 Subject: [Haskell-cafe] Re: [reactive] FRP + physics / status of hpysics In-Reply-To: References: Message-ID: Thanks for the info. With backtracking I actually meant the computation of the exact collision time, and let (part of the simulation) only go that far, so it's not really "back tracking" in the physics engine; does that correspond to your 2nd proposal. I just got this from a physics bookthat implements it that way (at least that why I got from reading it diagonally, the books contains a lot of advanced math...) But do you mean that with your proposed methods the simulation will advance a full "time step" anyway, so the time interval does not need to broken up into smaller ones, where each sub-interval ends with a collision event? I wander how this could work since most of the time in a game when a collision happens, the game logic decides what forces to apply next, so the simulation can't really advance a full time step anyway (although that could be hacked I guess). Converting the game logic into differential equations with constraints seems very hard. However, I must admit I haven't used any modern physics engines the last 5 years or so... But it's interesting to hear from people that did. On Fri, Mar 6, 2009 at 11:59 AM, jean-christophe mincke < jeanchristophe.mincke@gmail.com> wrote: > Hello Peter, > > The backtraking in time to solve the collision problem you mentionned is > not, in my opinion, efficient. > > From a previous life as an aerospace engineer, I remember that two other > solutions exist to handle contact or collision constraints, at least if 2nd > order diff. equations are used to describe the motion of a solid with mass. > > In any case, you have to use a 'serious' variable time step integration > algorithm (I.E Runge-Kutta). > > 1. The naive one: introduce a (virtual) spring between every 2 objets that > may collide. When these objets get closer, the spring is compressed and > tries to push them back. > If the mass/velocity are high, that leads to a stiff system and the time > steps may become very small. > However, this solution does not require any modification of the equations > of motion. > > 2. The serious one: modify or augment the equations of motion so that the > collision constraints are implicitly taken into account. If I remember well, > the magical trick is to use langrangian multipliers. > The difficult here (especially in the context of aFRP) is to derive the new > equations. > > Hope it helps > > Regards > > Jean-Christophe Mincke > > > 2009/3/6 Peter Verswyvelen > >> Regarding hpysics, did anybody did some experiments with this? The blog >> seems to be inactive since december 2008; has development ceased? >> >> Do alternatives exist? Maybe good wrappers (hopefully pure...) around >> existing engines? >> >> Integrating hpysics with Grapefruit might be a good topic for the >> Hackaton, trying to make a simple game (e.g. Pong or Breakout) without using >> recursive signal functions, but with correct collision response and >> better-than-Euler integration, all handled by the physics engine. Other FRP >> engines could be tried, but Grapefruit hacking is already a topic on the >> Hackaton, so it would combine efforts. >> >> It feels as if none of the current FRP engines can handle physics >> correctly, since a typical physics implementations requires "time >> backtracking", in the sense that when you want to advance the current >> simulation time by a timestep, collision events can happen during that time >> interval, and hence the FRP engine can only advance time until the earliest >> collision event. So to do physics *with* an FRP engine, the implementation >> and maybe even semantics of the FRP system might need to be changed. *Using* >> a physics engine as a blackbox inside an FRP system might make more sense. >> >> Thanks to Wolfgang Jeltsch and Christopher Lane Hinson for having a >> discussion with me that lead to this. Interestingly a similar discussion >> was help by other people in the Reactive mailing list at the same time :-) >> >> Cheers, >> Peter Verswyvelen >> >> >> >> >> >> >> _______________________________________________ >> Reactive mailing list >> Reactive@haskell.org >> http://www.haskell.org/mailman/listinfo/reactive >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/79d107c1/attachment.htm From barsoap at web.de Fri Mar 6 07:23:24 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Mar 6 07:13:32 2009 Subject: [Haskell-cafe] Re: FRP + physics / status of hpysics References: Message-ID: <20090306132324.2767f833@solaris> Peter Verswyvelen wrote: > Integrating hpysics with Grapefruit might be a good topic for the > Hackaton, trying to make a simple game (e.g. Pong or Breakout) > Be sure to have "more than two simultaneously moving collision objects besides paddles" in the specs, or it won't get close enough to a real physics simulation... well, at least I know how to get an A for a breakout by not allowing the ball to travel below the top of the paddle to hide a bug. Devastatingly simple vector equations get quite complex if you happen to stare at their assembly incarnations. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From jeanchristophe.mincke at gmail.com Fri Mar 6 08:26:31 2009 From: jeanchristophe.mincke at gmail.com (jean-christophe mincke) Date: Fri Mar 6 08:15:09 2009 Subject: [Haskell-cafe] Re: [reactive] FRP + physics / status of hpysics In-Reply-To: References: Message-ID: Peter, Backtracking: yes it is the computation of the exact collision time. I gave 2 solutions that can be used in multi-body dynamics, in general (that is, with 2nd order derivatives). I am not a game writing specialist but, if I understand you, I would say that, in a game, we have 1st order diff equations of the form x(T) = integrate(speed(x(t), t), T0, T) or on a diff form : dx/dt = f( x(t), t) where speed depends, without any lost of generality, on t and x(t). In case of a collision, that is when x(t) = Collision_position (i.e a ball boucing against a fixed wall), the speed may change discontinuously (i.e. speed = - speed). It will happen at an unknown time Tc. It is possible to find Tc, accurately, by solving the equation (i.e Newton Raphson or another root finding method). x(Tc) = Collision_position where x(Tc) = integrate(speed'(x(t), t), T0, Tc) where speed' is the speed as if there were no obstacle. So I would say that the main algorithm to solve such a problem is 1.Suppose that S(t) is the description (equations) of your system with t >= some initial t0. This system will behave continuously (that is, all its state variables will be continuous) between t0 and t1. In your example t1 is the exact moment of the collision. 2. With a combination of a integration/root finding algorithm, find t1 - you get all the state variables for free because to find t1, we need to integrate the system. 3 Change S(t) to S'(t) where t >= t1. S'(t) is a description of the system that takes into account the effect of the collision. Continue with first step. Rem: If a accurate root finding algorithm is too costly, another solution is, knowing S(t) at some tn, compute S(t) at tn+1 without paying attention to any collision. Than using S(tn) to check whether a collision took place. If no collision: continue and compute S(tn+2) etc. If collision: Assume that the system is linear between tn and tn+1 and then solve the linear equation: On Fri, Mar 6, 2009 at 1:01 PM, Peter Verswyvelen wrote: > Thanks for the info. With backtracking I actually meant the computation of > the exact collision time, and let (part of the simulation) only go that far, > so it's not really "back tracking" in the physics engine; does that > correspond to your 2nd proposal. I just got this from a physics bookthat implements it that way (at least that why I got from reading it > diagonally, the books contains a lot of advanced math...) > But do you mean that with your proposed methods the simulation will advance > a full "time step" anyway, so the time interval does not need to broken up > into smaller ones, where each sub-interval ends with a collision event? I > wander how this could work since most of the time in a game when a collision > happens, the game logic decides what forces to apply next, so the simulation > can't really advance a full time step anyway (although that could be hacked > I guess). Converting the game logic into differential equations with > constraints seems very hard. > > However, I must admit I haven't used any modern physics engines the last 5 > years or so... But it's interesting to hear from people that did. > > > On Fri, Mar 6, 2009 at 11:59 AM, jean-christophe mincke < > jeanchristophe.mincke@gmail.com> wrote: > >> Hello Peter, >> >> The backtraking in time to solve the collision problem you mentionned is >> not, in my opinion, efficient. >> >> From a previous life as an aerospace engineer, I remember that two other >> solutions exist to handle contact or collision constraints, at least if 2nd >> order diff. equations are used to describe the motion of a solid with mass. >> >> In any case, you have to use a 'serious' variable time step integration >> algorithm (I.E Runge-Kutta). >> >> 1. The naive one: introduce a (virtual) spring between every 2 objets that >> may collide. When these objets get closer, the spring is compressed and >> tries to push them back. >> If the mass/velocity are high, that leads to a stiff system and the time >> steps may become very small. >> However, this solution does not require any modification of the equations >> of motion. >> >> 2. The serious one: modify or augment the equations of motion so that the >> collision constraints are implicitly taken into account. If I remember well, >> the magical trick is to use langrangian multipliers. >> The difficult here (especially in the context of aFRP) is to derive the >> new equations. >> >> Hope it helps >> >> Regards >> >> Jean-Christophe Mincke >> >> >> 2009/3/6 Peter Verswyvelen >> >>> Regarding hpysics, did anybody did some experiments with this? The blog >>> seems to be inactive since december 2008; has development ceased? >>> >>> Do alternatives exist? Maybe good wrappers (hopefully pure...) around >>> existing engines? >>> >>> Integrating hpysics with Grapefruit might be a good topic for the >>> Hackaton, trying to make a simple game (e.g. Pong or Breakout) without using >>> recursive signal functions, but with correct collision response and >>> better-than-Euler integration, all handled by the physics engine. Other FRP >>> engines could be tried, but Grapefruit hacking is already a topic on the >>> Hackaton, so it would combine efforts. >>> >>> It feels as if none of the current FRP engines can handle physics >>> correctly, since a typical physics implementations requires "time >>> backtracking", in the sense that when you want to advance the current >>> simulation time by a timestep, collision events can happen during that time >>> interval, and hence the FRP engine can only advance time until the earliest >>> collision event. So to do physics *with* an FRP engine, the implementation >>> and maybe even semantics of the FRP system might need to be changed. *Using* >>> a physics engine as a blackbox inside an FRP system might make more sense. >>> >>> Thanks to Wolfgang Jeltsch and Christopher Lane Hinson for having a >>> discussion with me that lead to this. Interestingly a similar discussion >>> was help by other people in the Reactive mailing list at the same time :-) >>> >>> Cheers, >>> Peter Verswyvelen >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Reactive mailing list >>> Reactive@haskell.org >>> http://www.haskell.org/mailman/listinfo/reactive >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/c61af9d1/attachment-0001.htm From jeanchristophe.mincke at gmail.com Fri Mar 6 08:33:10 2009 From: jeanchristophe.mincke at gmail.com (jean-christophe mincke) Date: Fri Mar 6 08:21:44 2009 Subject: [Haskell-cafe] Re: [reactive] FRP + physics / status of hpysics In-Reply-To: References: Message-ID: Sorry, my message was inadvertently sent - hit the wrong key - a gmail feature Peter, Backtracking: yes it is the computation of the exact collision time. I gave 2 solutions that can be used in multi-body dynamics, in general (that is, with 2nd order derivatives). I am not a game writing specialist but, if I understand you, I would say that, in a game, we have 1st order diff equations of the form x(T) = integrate(speed(x(t), t), T0, T) or on a diff form : dx/dt = f( x(t), t) where speed depends, without any lost of generality, on t and x(t). In case of a collision, that is when x(t) = Collision_position (i.e a ball boucing against a fixed wall), the speed may change discontinuously (i.e. speed = -speed). It will happen at an unknown time Tc. It is possible to find Tc, accurately, by solving the equation (i.e Newton Raphson or another root finding method). x(Tc) = Collision_position where x(Tc) = integrate(speed'(x(t), t), T0, Tc) where speed' is the speed as if there were no obstacle. So I would say that the main algorithm to solve such a problem is: 1.Suppose that S(t) is the description (equations) of your system with t >= some initial t0. This system will behave continuously (that is, all its state variables will be continuous) between t0 and t1. In your example t1 is the exact moment of the collision. 2. With a combination of a integration/root finding algorithm, find t1 - you get all the state variables for free because to find t1, we need to integrate the system. 3 Change S(t) to S'(t) where t >= t1. S'(t) is a description of the system that takes into account the effect of the collision. 4 Continue with first step. Rem: If an accurate root finding algorithm is too costly, another solution is: knowing S(t) at some tn, compute S(t) at tn+1 without paying attention to any collision. Than use S(tn+1) to check whether a collision took place. If no collision: continue and compute S(tn+2) etc. If collision: Assume that the system is linear between tn and tn+1 and then solve the linear equation: x(tc) = x(tn) + (x(tn+1) - x(tn))/(tn+1 - tn) * tc = Collision_position Once tc is known, replace your system as explained above with S'(t) , t>= tc The condition here is that [tn, tn+1] must be choosen small enough in order that the assumption if linearity holds. Regards Jean-Christophe Mincke On Fri, Mar 6, 2009 at 2:26 PM, jean-christophe mincke < jeanchristophe.mincke@gmail.com> wrote: > Peter, > > Backtracking: yes it is the computation of the exact collision time. > > I gave 2 solutions that can be used in multi-body dynamics, in general > (that is, with 2nd order derivatives). I am not a game writing specialist > but, if I understand you, I would say that, in a game, we have 1st order > diff equations of the form > > x(T) = integrate(speed(x(t), t), T0, T) or on a diff form : dx/dt = f( > x(t), t) > > where speed depends, without any lost of generality, on t and x(t). > > In case of a collision, that is when x(t) = Collision_position (i.e a ball > boucing against a fixed wall), the speed may change discontinuously (i.e. > speed = - speed). It will happen at an unknown time Tc. It is possible to > find Tc, accurately, by solving the equation (i.e Newton Raphson or another > root finding method). > > x(Tc) = Collision_position > where > x(Tc) = integrate(speed'(x(t), t), T0, Tc) where speed' is the speed as if > there were no obstacle. > > So I would say that the main algorithm to solve such a problem is > > 1.Suppose that S(t) is the description (equations) of your system with t > >= some initial t0. This system will behave continuously (that is, all its > state variables will be continuous) between t0 and t1. In your example t1 is > the exact moment of the collision. > > 2. With a combination of a integration/root finding algorithm, find t1 - > you get all the state variables for free because to find t1, we need to > integrate the system. > > 3 Change S(t) to S'(t) where t >= t1. S'(t) is a description of the system > that takes into account the effect of the collision. > > Continue with first step. > > Rem: If a accurate root finding algorithm is too costly, another solution > is, knowing S(t) at some tn, compute S(t) at tn+1 without paying attention > to any collision. Than using S(tn) to check whether a collision took place. > > If no collision: continue and compute S(tn+2) etc. > If collision: Assume that the system is linear between tn and tn+1 and then > solve the linear equation: > > > > > > > > > > > > On Fri, Mar 6, 2009 at 1:01 PM, Peter Verswyvelen wrote: > >> Thanks for the info. With backtracking I actually meant the computation of >> the exact collision time, and let (part of the simulation) only go that far, >> so it's not really "back tracking" in the physics engine; does that >> correspond to your 2nd proposal. I just got this from a physics bookthat implements it that way (at least that why I got from reading it >> diagonally, the books contains a lot of advanced math...) >> But do you mean that with your proposed methods the simulation will >> advance a full "time step" anyway, so the time interval does not need to >> broken up into smaller ones, where each sub-interval ends with a collision >> event? I wander how this could work since most of the time in a game when a >> collision happens, the game logic decides what forces to apply next, so the >> simulation can't really advance a full time step anyway (although that could >> be hacked I guess). Converting the game logic into differential equations >> with constraints seems very hard. >> >> However, I must admit I haven't used any modern physics engines the last 5 >> years or so... But it's interesting to hear from people that did. >> >> >> On Fri, Mar 6, 2009 at 11:59 AM, jean-christophe mincke < >> jeanchristophe.mincke@gmail.com> wrote: >> >>> Hello Peter, >>> >>> The backtraking in time to solve the collision problem you mentionned is >>> not, in my opinion, efficient. >>> >>> From a previous life as an aerospace engineer, I remember that two other >>> solutions exist to handle contact or collision constraints, at least if 2nd >>> order diff. equations are used to describe the motion of a solid with mass. >>> >>> In any case, you have to use a 'serious' variable time step integration >>> algorithm (I.E Runge-Kutta). >>> >>> 1. The naive one: introduce a (virtual) spring between every 2 objets >>> that may collide. When these objets get closer, the spring is compressed >>> and tries to push them back. >>> If the mass/velocity are high, that leads to a stiff system and the time >>> steps may become very small. >>> However, this solution does not require any modification of the equations >>> of motion. >>> >>> 2. The serious one: modify or augment the equations of motion so that the >>> collision constraints are implicitly taken into account. If I remember well, >>> the magical trick is to use langrangian multipliers. >>> The difficult here (especially in the context of aFRP) is to derive the >>> new equations. >>> >>> Hope it helps >>> >>> Regards >>> >>> Jean-Christophe Mincke >>> >>> >>> 2009/3/6 Peter Verswyvelen >>> >>>> Regarding hpysics, did anybody did some experiments with this? The blog >>>> seems to be inactive since december 2008; has development ceased? >>>> >>>> Do alternatives exist? Maybe good wrappers (hopefully pure...) around >>>> existing engines? >>>> >>>> Integrating hpysics with Grapefruit might be a good topic for the >>>> Hackaton, trying to make a simple game (e.g. Pong or Breakout) without using >>>> recursive signal functions, but with correct collision response and >>>> better-than-Euler integration, all handled by the physics engine. Other FRP >>>> engines could be tried, but Grapefruit hacking is already a topic on the >>>> Hackaton, so it would combine efforts. >>>> >>>> It feels as if none of the current FRP engines can handle physics >>>> correctly, since a typical physics implementations requires "time >>>> backtracking", in the sense that when you want to advance the current >>>> simulation time by a timestep, collision events can happen during that time >>>> interval, and hence the FRP engine can only advance time until the earliest >>>> collision event. So to do physics *with* an FRP engine, the implementation >>>> and maybe even semantics of the FRP system might need to be changed. *Using* >>>> a physics engine as a blackbox inside an FRP system might make more sense. >>>> >>>> Thanks to Wolfgang Jeltsch and Christopher Lane Hinson for having a >>>> discussion with me that lead to this. Interestingly a similar discussion >>>> was help by other people in the Reactive mailing list at the same time :-) >>>> >>>> Cheers, >>>> Peter Verswyvelen >>>> >>>> >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> Reactive mailing list >>>> Reactive@haskell.org >>>> http://www.haskell.org/mailman/listinfo/reactive >>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/7e5c36d9/attachment.htm From jgoerzen at complete.org Fri Mar 6 09:37:43 2009 From: jgoerzen at complete.org (John Goerzen) Date: Fri Mar 6 09:26:15 2009 Subject: [Haskell-cafe] Re: Migration to QuickCheck 2.0 In-Reply-To: <20090306143627.GA22980@hustlerturf.com> References: <20090306143627.GA22980@hustlerturf.com> Message-ID: <49B13537.9050504@complete.org> John Goerzen wrote: > Hi, > > My google skills must be faulty, because I can't find much stuff on > migrating from QuickCheck 1.0 to 2.0. > > I've got a number of questions: > > What's the deal with Result and reason being in two different places > in QuickCheck with two different definitions? > > All the QC.Config -- configMaxTest, defaultConfig, arguments, etc. are > missing. Are there direct replacements? OK, ignore the second one. That was an HUnit question; sorry. > > Thanks, > > -- John From g9ks157k at acme.softbase.org Fri Mar 6 11:51:32 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Mar 6 11:40:05 2009 Subject: [Haskell-cafe] Re: [reactive] FRP + physics / status of hpysics In-Reply-To: <78B6251E-2D03-4963-B6CB-E03369AA44B8@erratique.ch> References: <78B6251E-2D03-4963-B6CB-E03369AA44B8@erratique.ch> Message-ID: <200903061751.32880.g9ks157k@acme.softbase.org> Am Freitag, 6. M?rz 2009 14:34 schrieb Daniel B?nzli: > > without using recursive signal functions, > > If this is because there's this limitation in the frp system you use It is. > then better fix the system. The system is Grapefruit, by the way. And I?m its developer, by the way. :-) I have to say that it?s hard, if not impossible, to combine recursive signal definitions with other features, I want to have. The point of recursive definitions is that you want to turn recursive equations from your problem domain directly into Haskell definitions. This is nice from a user?s point of view but hard from a programmers point of view. Standard Haskell already shows that. While it is possible to define an infinite list of ones by ones = 1 : ones, it is not possible to do the same for sequences of type Seq. The above definition of ones relies very much on the structure of lists. Analogously, the ability to define signals recursively restricts the set of possible signal implementations seriously. Haskell?s recursive definitions are very general. They have to find fixpoints of arbitrary functions over arbitrary type. Therefore, their semantics are rather weak. They give you the least defined fixpoint. The consequence is that you get bottom if you use something like x = 0 * x although x = 0 might be what you prefered. What I want to say is that coming up with a signal implementation that allows Haskell recursion and has other advantages at the same time is a big challenge. There are three features, you might want from a signal implementation: 1. support for recursive signal definitions using Haskell equations 2. memoization (for avoiding time leaks, for example) 3. signals which may depend on external sources I tried hard to support 2 and 3 well in Grapefruit. Fran has 1 but has problems with 2 and 3. I don?t know whether Reactive has a solution for 2 in the context of recursive definitions, i.e., whether the space and time leak problems of Fran were solved. I think, it has at least problems with 3. For me, 2 and 3 are more important than 1. One reason is that 1 has other problems than being in conflict with 2 and 3. The result of a recursively defined signal depends on when sampling occurs. Since a recursive definition tends to result in accumulation of values, errors introduced by sampling may accumulate too. So you have to use clever approximation algorithms in addition. My new idea is to view the problem in a different way. Let?s take the problem where the position of a ball is the integral of the difference between the mouse position and the ball position. As far as I can see, the transformation of the mouse position signal into the ball position signal forms a linear system. So the ball position signal is the mouse position signal convoluted with another signal. If we would have a function that performes convolution, we could probably implement many problems using this function. Using convolution would let us get rid of the problems with accumulating errors. I suppose that most of the recursive definitions you would use in FRP are differential or integral equations. Let?s look at the equation for the ball-following-the-mouse example: ballPos = integral (mousePos - ballPos) ballPos can be represented in terms of mousePos as follows: ballPos = (exp . negate) * mousePos where * means convolution. We could provide a library which supports common stuff like distance-dependent acceleration, friction etc. Of course, you could say that now the programmer isn?t able anymore to enter his equations directly which isn?t nice. However, this situation is not different to other areas. For example, you cannot write x = 5 - x / 2 and expect x to be 10 / 3. Instead, you have to transform the equation first. > Soon or later it you'll want it elsewhere. A recursive reactive signal just > means that some of what your reactive program computed will be > usefull/necessary for the next step. You can do this with convolution, I think. By the way, continuous signals don?t have steps. These are just introduced by sampling. > You'll see that happen very quickly (e.g. any simple reactive state > machine). ?State machine? sounds like a discrete problem. You can use accumulation over event sequences here (as, for example, provided by the scan function in FRP.Grapefruit.Signal.Discrete). By the way, the adress of the Grapefruit mailing list is grapefruit@projects.haskell.org, not grapefruit@haskell.org. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Mar 6 11:57:53 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Mar 6 11:46:24 2009 Subject: [Haskell-cafe] Re: [reactive] FRP + physics / status of hpysics In-Reply-To: <200903061751.32880.g9ks157k@acme.softbase.org> References: <78B6251E-2D03-4963-B6CB-E03369AA44B8@erratique.ch> <200903061751.32880.g9ks157k@acme.softbase.org> Message-ID: <200903061757.53755.g9ks157k@acme.softbase.org> Am Freitag, 6. M?rz 2009 17:51 schrieb Wolfgang Jeltsch: > By the way, the adress of the Grapefruit mailing list is > grapefruit@projects.haskell.org, not grapefruit@haskell.org. Oh, this is really strange: I addressed my e-mail to grapefruit@projects.haskell.org but the version arriving at the Reactive mailing list has grapefruit@haskell.org in its To: header. However, my e-mail also reached the Grapefruit mailing list (but Daniel B?nzli?s didn?t) and the version there has the correct address in its To: headers. Does anyone know who is responsible for the Haskell mail server? Best wishes, Wolfgang From jfredett at gmail.com Fri Mar 6 12:10:50 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Fri Mar 6 11:59:23 2009 Subject: [Haskell-cafe] Hint and Ambiguous Type issue In-Reply-To: References: <49B01E7D.6000207@gmail.com> <2f9b2d30903051325j1ba98cc3i755540e33671eaa5@mail.gmail.com> <49B05696.7010808@gmail.com> <105919D9-8547-4C50-B898-6590673D5EAF@dc.uba.ar> <49B07BDD.3030501@gmail.com> <52AD821E-7415-4EA3-AD6D-21D4C930E8B2@dc.uba.ar> <49B0A78A.5050006@gmail.com> Message-ID: <49B1591A.9050903@gmail.com> Thanks so much, I think I understand. This definitely sounds like what I want to do. I guess I've got some learning to do... Thats why I love Haskell so much, every other day it gives me something new to learn. Thanks again, /Joe Daniel Gor?n wrote: > I think you can achieve what you want but you need to use the correct > types for it. Remember that when you write: > > getFilterMainStuff :: Deliverable a => FilePath -> Interpreter (Path, > Filter a) > > the proper way to read the signature is "the caller of > getFilterMainStuff is entitled to pick the type of a, as long as it > picks an instance of Deliverable". Contrast this with a method > declaration in Java where: > > public Set getKeys() > > is to be read: "The invoked object may pick the type of the result, as > long as it is a subclass of (or implements) Set". > > When you say that you want "to apply fMain to a (Config, Email) and > get back a Deliverable a", I think you mean that fMain picks the type > for a (and has to be an instance of Deliverable). There two ways to do > this in Haskell: > > 1) You don't. If you know that your possible Deliverables are just > FlatEmail and MaildirEmail, then the idiomatic way of doing this would > be to turn Deliverable into an ADT: > > data Deliverable = FlatEmail .... | MaildirEmail .... deriving (Typeable) > getFilterMainStuff :: FilePath -> Interpreter (Path, Filter Deliverable) > > 2) Existential types. If, for some reason, you need your "dynamic > code" to be able to define new "deliverables", then you need to use > the extension called "existential types". > > -- using GADT syntax > data SomeDeliverable where Wrap :: Deliverable a => a -> SomeDeliverable > > getFilterMainStuff :: FilePath -> Interpreter (Path, Filter > SomeDeliverable) > > This basically resembles the contract of the Java world: if you run > fMain you will get a value of type SomeDeliverable; you can > pattern-match it and will get something whose actual type you don't > know, but that it is an instance of class Deliverable. > > See http://www.haskell.org/haskellwiki/Existential_type > > Good luck! > > Daniel > > On Mar 6, 2009, at 2:33 AM, Joseph Fredette wrote: > >> Okay, I think I understand... I got so hung up thinking the error had >> to be in the Interpreter code, I didn't bother to look in the caller... >> >> But every answer breeds another question... The practical reason for >> inferring fMain as being of type "Deliverable a => Filter a", is to >> apply it (via runReader) to a (Config, Email) and get back a >> Deliverable a, then to use the deliverIO method on the result -- my >> question is, it appears I have to "know" the specific type of a in >> order to get the thing to typecheck, but in order to use it, I need >> to not know it... >> >> Perhaps, in fact, I'm doing this wrong. Thanks for the help Daniel, >> everyone... >> >> /Joe >> >> Daniel Gor?n wrote: >>> Ok, so I've pulled the latest version and the error I get now is: >>> >>> Hackmain.hs:70:43: >>> Ambiguous type variable `a' in the constraint: >>> `Deliverable a' >>> arising from a use of `getFilterMainStuff' at >>> Hackmain.hs:70:43-60 >>> Probable fix: add a type signature that fixes these type variable(s) >>> >>> Function getFilterMainStuff compiles just fine . The offending line >>> is in buildConf and reads: >>> >>> > (inboxL, fMain) <- runUnsafeInterpreter . getFilterMainStuff $ >>> filterMainL >>> >>> The problem is that GHC can't figure out the type of fMain. It >>> infers (Filter a), but doesn't know what is a and therefore how to >>> build a proper dictionary to pass to getFilterMainStuff. >>> >>> Observe that you would get a similar error message if you just defined: >>> >>> > f = show . read >>> >>> I can get it to compile by providing a type annotation for fMain: >>> >>> > (inboxL, fMain) <- runUnsafeInterpreter . getFilterMainStuff $ >>> filterMainL >>> > let _ = fMain :: Filter MaildirEmail >>> >>> So once you use fMain somewhere and GHC can infer it's type, >>> everything should work fine. >>> >>> Daniel >>> >>> On Mar 5, 2009, at 11:26 PM, Joseph Fredette wrote: >>> >>>> Oh, crap- I must have never pushed the latest patches, I did put >>>> the typeable instances in all the appropriate places. And provided >>>> a (maybe incorrect? Though I'm fairly sure that shouldn't affect >>>> the bug I'm having now) Typeable implementation for Reader, but I >>>> still get this ambiguous type. I'll push the current version asap. >>>> >>>> Thanks. >>>> >>>> /Joe >>>> >>>> Daniel Gor?n wrote: >>>>> Hi >>>>> >>>>> I've downloaded Hackmain from patch-tag, but I'm getting a >>>>> different error. The error I get is: >>>>> >>>>> Hackmain.hs:63:10: >>>>> No instance for (Data.Typeable.Typeable2 >>>>> Control.Monad.Reader.Reader) >>>>> arising from a use of `interpret' at Hackmain.hs:63:10-67 >>>>> >>>>> Hint requires the interpreted values to be an instance of Typeable >>>>> in order to check, in runtime, that the interpreted value matches >>>>> the type declared at compile. Therefore, you need to make sure >>>>> that (Filter a) is indeed an instance of Typeable. >>>>> >>>>> Since you have Filter a = Reader (Config, Email) a, you probably >>>>> need to >>>>> >>>>> - Derive Config and Email instances for Filter, >>>>> >>>>> - Manually provide Typeable instances for Reader a b, something >>>>> along the lines of: >>>>> >>>>> instance (Typeable a, Typeable b) => Typeable (Reader a b) where... >>>>> >>>>> (I don't know why this isn't done in the mtl....) >>>>> >>>>> - Change the signature to: >>>>> >>>>> getFilterMain :: (Typeable a, Deliverable a) => FilePath -> >>>>> Interpreter (Filter a) >>>>> >>>>> Also, you can try using "infer" instead of "as :: ...." >>>>> >>>>> Hope that helps >>>>> >>>>> Daniel >>>>> >>>>> On Mar 5, 2009, at 8:47 PM, Joseph Fredette wrote: >>>>> >>>>>> So, I tried both of those things, both each alone and together. >>>>>> No dice. Same error, so I reverted back to the >>>>>> original. :( >>>>>> However, I was, after some random type signature insertions, able >>>>>> to convert the problem into a different one, via: >>>>>> >>>>>> getFilterMain :: Deliverable a => FilePath -> Interpreter (Filter >>>>>> a) getFilterMain MainLoc = do >>>>>> loadModules [fMainLoc]; setTopLevelModules [(takeWhile >>>>>> (/='.') fMainLoc)] fMain <- >>>>>> (interpret "(filterMain)" infer) >>>>>> return (fMain :: Deliverable a => Filter a) >>>>>> >>>>>> Inferred type is less polymorphic than expected >>>>>> Quantified type variable `a' is mentioned in the environment: >>>>>> fMain :: Filter a (bound at Hackmain.hs:77:1) >>>>>> In the first argument of `return', namely >>>>>> `(fMain :: (Deliverable a) => Filter a)' >>>>>> In the expression: return (fMain :: (Deliverable a) => Filter a) >>>>>> In the expression: >>>>>> do loadModules [fMainLoc] >>>>>> setTopLevelModules [(takeWhile (/= '.') fMainLoc)] >>>>>> fMain <- (interpret "(filterMain)" infer) >>>>>> return (fMain :: (Deliverable a) => Filter a) >>>>>> >>>>>> I'm thinking that this might be more easily solved -- I do think >>>>>> I understand the issue. somehow, I need to tell the compiler >>>>>> that the 'a' used in the return statement (return (fMain :: ...)) >>>>>> is the same as the 'a' in the type sig for the whole function. >>>>>> >>>>>> While I ponder this, and hopefully receive some more help -- >>>>>> thanks again Dan, Ryan -- Are there any other options besides >>>>>> Hint that might -- at least in the short term -- make this >>>>>> easier? I'd really like to finish this up. I'm _so_ close to >>>>>> getting it done. >>>>>> >>>>>> Thanks, >>>>>> >>>>>> /Joe >>>>>> >>>>>> Ryan Ingram wrote: >>>>>>> So, by using the Haskell interpreter, you're using the >>>>>>> not-very-well-supported dynamically-typed subset of Haskell. >>>>>>> You can >>>>>>> tell this from the type signature of "interpret": >>>>>>> >>>>>>> >>>>>>>> interpret :: Typeable a => String -> a -> Interpreter a >>>>>>>> >>>>>>> >>>>>>> >>>>>>>> as :: Typeable a => a >>>>>>>> as = undefined >>>>>>>> >>>>>>> >>>>>>> (from >>>>>>> http://hackage.haskell.org/packages/archive/hint/0.2.1/doc/html/src/Language-Haskell-Interpreter-GHC.html) >>>>>>> >>>>>>> >>>>>>> In particular, the "as" argument to interpret is specifying what >>>>>>> type >>>>>>> you want the interpreted result to be typechecked against; the >>>>>>> interpretation fails if it doesn't match that type. But you >>>>>>> need the >>>>>>> result type to be an instance of Typeable; (forall a. >>>>>>> Deliverable a => >>>>>>> Filter a) most certainly is not. >>>>>>> >>>>>>> >>>>>>> Off the top of my head, you have a couple of directions you can >>>>>>> take this. >>>>>>> >>>>>>> (1) Make Typeable a superclass of Deliverable, saying that all >>>>>>> deliverable things must be dynamically typeable. Then derive >>>>>>> Typeable >>>>>>> on Filter, and have the result be of type "Filter a" using >>>>>>> ScopedTypeVariables as suggested before. (You can also pass >>>>>>> "infer" to >>>>>>> the interpreter and let the compiler try to figure out the >>>>>>> result type >>>>>>> instead of passing (as :: SomeType).) >>>>>>> >>>>>>> (2) Make a newtype wrapper around Filter and give it an instance of >>>>>>> Typeable, and add a constraint to filterMain that the result >>>>>>> type in >>>>>>> the filter is also typeable. Then unwrap the newtype after the >>>>>>> interpreter completes. >>>>>>> >>>>>>> Good luck; I've never tried to use the Haskell interpreter >>>>>>> before, so >>>>>>> I'm curious how well it works and what problems you have with it! >>>>>>> >>>>>>> >>>>>>> -- ryan >>>>>>> >>>>>>> 2009/3/5 Joseph Fredette : >>>>>>> >>>>>>>> I've been working on a little project, and one of the things I >>>>>>>> need to do is >>>>>>>> dynamically compile and import a Haskell Source file containing >>>>>>>> filtering >>>>>>>> definitions. I've written a small monad called Filter which is >>>>>>>> simply: >>>>>>>> >>>>>>>> type Filter a = Reader (Config, Email) a >>>>>>>> >>>>>>>> To encompass all the email filtering. The method I need to import, >>>>>>>> filterMain, has type: >>>>>>>> >>>>>>>> filterMain :: Deliverable a => Filter a >>>>>>>> >>>>>>>> where Deliverable is a type class which abstracts over delivery >>>>>>>> to a path in >>>>>>>> the file system. The notion is that I can write a type like: >>>>>>>> >>>>>>>> data DEmail = {email :: Email, path :: FilePath} >>>>>>>> newtype Maildir = MD DEmail >>>>>>>> >>>>>>>> instance Deliverable Maildir where >>>>>>>> {- ... omitted -} >>>>>>>> >>>>>>>> However, Filter a should not be restricted to Deliverable >>>>>>>> types- it also >>>>>>>> encompasses the results of regular expression matching, etc, >>>>>>>> which are not >>>>>>>> -- in general -- Deliverable instances. >>>>>>>> >>>>>>>> My question is this, when importing the file containing the >>>>>>>> definitions of >>>>>>>> filterMain, I have the following code to grab filterMain and >>>>>>>> return it as a >>>>>>>> function. >>>>>>>> >>>>>>>> getFilterMain :: Deliverable a => FilePath -> Interpreter >>>>>>>> (Filter a) >>>>>>>> getFilterMain fMainLoc = do >>>>>>>> loadModules >>>>>>>> [fMainLoc]; setTopLevelModules [(takeWhile (/='.') fMainLoc)] >>>>>>>> fMain <- (interpret "(filterMain)" (as :: >>>>>>>> Deliverable a >>>>>>>> => Filter a)) return (fMain) >>>>>>>> >>>>>>>> However, when I try to >>>>>>>> compile >>>>>>>> this, I get the type error: >>>>>>>> >>>>>>>> Hackmain.hs:70:43: >>>>>>>> Ambiguous type variable `a' in the constraint: >>>>>>>> `Deliverable a' >>>>>>>> arising from a use of `getFilterMainStuff' at >>>>>>>> Hackmain.hs:70:43-60 >>>>>>>> Probable fix: add a type signature that fixes these type >>>>>>>> variable(s) >>>>>>>> >>>>>>>> My understanding is that a type like "Foo a => Bar a" (where >>>>>>>> Foo is a class >>>>>>>> and Bar is a datatype) would simply restrict >>>>>>>> the values of a to only those implementing Foo. But evidently >>>>>>>> I'm wrong. Is >>>>>>>> there a good (read, easy... :) ) fix to this? >>>>>>>> >>>>>>>> Any help would be greatly appreciated. >>>>>>>> >>>>>>>> /Joe >>>>>>>> >>>>>>>> PS. All the actual code is on patch-tag, here >>>>>>>> http://patch-tag.com/repo/Hackmail/home -- if anyone prefers to >>>>>>>> look at that >>>>>>>> directly, the relevant files are in Src, namely, Hackmain.hs, >>>>>>>> Filter.hs, and >>>>>>>> Deliverable.hs >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> Haskell-Cafe mailing list >>>>>>>> Haskell-Cafe@haskell.org >>>>>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>> _______________________________________________ >>>>>> Haskell-Cafe mailing list >>>>>> Haskell-Cafe@haskell.org >>>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>>> >>>> >>> >>> >> > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/6839c079/jfredett.vcf From dons at galois.com Fri Mar 6 12:30:58 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 6 12:20:18 2009 Subject: [Haskell-cafe] Re: MPI In-Reply-To: References: Message-ID: <20090306173058.GA15408@whirlpool.galois.com> fft1976: > On Wed, Mar 4, 2009 at 5:03 PM, FFT wrote: > > Are MPI bindings still the best way of using Haskell on Beowulf > > clusters? It's my feeling that the bindings stagnated, or are they > > just very mature? > > What's the story with distributed memory multiprocessing? Are Haskell > programmers uninterested in it, or are things other than MPI used with > it? http://haskell.org/haskellwiki/Applications_and_libraries/Concurrency_and_parallelism#Distributed_Haskell From bos at serpentine.com Fri Mar 6 14:39:51 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Mar 6 14:28:22 2009 Subject: [Haskell-cafe] Re: MPI In-Reply-To: References: Message-ID: On Thu, Mar 5, 2009 at 10:43 AM, FFT wrote: > > > Are MPI bindings still the best way of using Haskell on Beowulf > > clusters? It's my feeling that the bindings stagnated, or are they > > just very mature? > MPI itself hasn't changed in 14 years, so it's not exactly a moving target. (There's an MPI 2.0, but its most visible changes are not really usable.) What's the story with distributed memory multiprocessing? Are Haskell > programmers uninterested in it, or are things other than MPI used with > it? The ratio of work to payoff is unfortunately very high, so it seems to have been abandoned as a topic of fruitful research. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/668140d2/attachment.htm From leimy2k at gmail.com Fri Mar 6 15:37:15 2009 From: leimy2k at gmail.com (David Leimbach) Date: Fri Mar 6 15:25:45 2009 Subject: [Haskell-cafe] Re: MPI In-Reply-To: References: Message-ID: <3e1162e60903061237t21ea432pbc106b18f11350c0@mail.gmail.com> 2009/3/6 Bryan O'Sullivan > On Thu, Mar 5, 2009 at 10:43 AM, FFT wrote: > >> >> > Are MPI bindings still the best way of using Haskell on Beowulf >> > clusters? It's my feeling that the bindings stagnated, or are they >> > just very mature? >> > > MPI itself hasn't changed in 14 years, so it's not exactly a moving target. > (There's an MPI 2.0, but its most visible changes are not really usable.) > MPI forum meetings are ongoing now to update it once again :-) Having implemented MPI 2, I find the comment that the visible changes not being very usable to be interesting, and really more of an opinion (one that I typically share for some parts of the API, but not others). > > > What's the story with distributed memory multiprocessing? Are Haskell >> programmers uninterested in it, or are things other than MPI used with >> it? > > > The ratio of work to payoff is unfortunately very high, so it seems to have > been abandoned as a topic of fruitful research. > I think you're better off with some message passing system in almost all cases than most when it comes to distributed, concurrent, and even some kinds of parallel programs, but that's based on my real world experience implementing efficient implementations of message passing for customers for about 5 or 6 years.... so I'm a bit biased. > > _______________________________________________ > 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/20090306/d50789d1/attachment.htm From dons at galois.com Fri Mar 6 15:42:18 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 6 15:31:36 2009 Subject: [Haskell-cafe] Re: MPI In-Reply-To: References: Message-ID: <20090306204218.GE15408@whirlpool.galois.com> bos: > On Thu, Mar 5, 2009 at 10:43 AM, FFT wrote: > > > > Are MPI bindings still the best way of using Haskell on Beowulf > > clusters? It's my feeling that the bindings stagnated, or are they > > just very mature? > > > MPI itself hasn't changed in 14 years, so it's not exactly a moving target. > (There's an MPI 2.0, but its most visible changes are not really usable.) > > > What's the story with distributed memory multiprocessing? Are Haskell > programmers uninterested in it, or are things other than MPI used with > it? > > > The ratio of work to payoff is unfortunately very high, so it seems to have > been abandoned as a topic of fruitful research. Though note the new paper for ICPP: "In this paper, we investigate the differences and tradeoffs imposed by two parallel Haskell dialects running on multicore machines. GpH and Eden are both constructed using the highly-optimising sequential GHC compiler, and share thread scheduling, and other elements, from a common code base. The GpH implementation investigated here uses a physically-shared heap, which should be well-suited to multicore architectures. In contrast, the Eden implementation adopts an approach that has been designed for use on distributed-memory parallel machines " http://www-fp.cs.st-and.ac.uk/~kh/mainICPP09.pdf -- Don From lrpalmer at gmail.com Fri Mar 6 16:33:00 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Mar 6 16:21:30 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: References: <1236298375.32464.26.camel@jcchost> <20090306012711.C7D9A276CBA@mail.avvanta.com> <7ca3f0160903051733y1e9c80ddn4af30284d73f9e@mail.gmail.com> Message-ID: <7ca3f0160903061333s6d2bcfafqab3804672af5c655@mail.gmail.com> On Fri, Mar 6, 2009 at 1:48 AM, Daryoush Mehrtash wrote: > Question: Do I need to worry about space leak if I am using the fix to > instead of the "let"? If you need to worry about a space leak with fix, you need to worry about it with let. The reason arrows can tie the loop tighter is more about the nature of recursion in streams; an arrow "sees" that prior values of a signal are not used, whereas value recursion is much less restricted. If, for example, the arrow were a kleisli arrow over the list monad, this would not be possible. With the definition fix f = let x = f x in x, you should not see any performance difference, other than the standard HOF penalty if there is not enough inlining... but that should not be asymptotic anyway. Luke > > Thanks > > Daryoush > 2009/3/5 Luke Palmer > >> On Thu, Mar 5, 2009 at 6:27 PM, Donn Cave wrote: >> >>> Quoth Jonathan Cast : >>> >>> > You can certainly use let: >>> > >>> > reader <- forkIO $ let loop = do >>> > (nr', line) <- readChan chan' >>> > when (nr /= nr') $ hPutStrLn hdl line >>> > loop >>> > in loop >>> > >>> > But the version with fix is clearer (at least to people who have fix in >>> > their vocabulary) and arguably better style. >>> >>> Would you mind presenting the better style argument? To me, the >>> above could not be clearer, so it seems like the version with fix >>> could be only as clear, at best. >> >> >> I like using fix when it's simple rather than let, because it tells me the >> purpose of the binding. eg., when I see >> >> let foo = ... >> >> Where ... is fairly long, I'm not sure what the purpose of foo is, or what >> its role is in the final computation. It may not be used at all, or passed >> to some modifier function, or I don't know what. Whereas with: >> >> fix $ \foo -> ... >> >> I know that whatever ... is, it is what is returne, and the purpose of foo >> is to use that return value in the expression itself. >> >> I know that it's a simple matter of scanning to the corresponding "in", >> but let can be used for a lot of things, where as fix $ \foo is basically >> only for simple knot-tying. Now, that doesn't say anything about the use of >> fix without an argument (passed to an HOF) or with a tuple as an argument or >> many other cases, which my brain has not chunked nearly as effectively. I >> think fix is best with a single, named argument. >> >> Luke >> >> _______________________________________________ >> 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/20090306/6f105c59/attachment.htm From roma at ro-che.info Fri Mar 6 16:39:58 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Fri Mar 6 16:29:01 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics In-Reply-To: References: Message-ID: <20090306213958.GA6963@flit> * Peter Verswyvelen [2009-03-06 11:17:50+0100] > Regarding hpysics, did anybody did some experiments with this? Nothing I'm aware of. > The blog > seems to be inactive since december 2008; has development ceased? Sort of. One reason is that DPH does not seem to be ready for hpysics yet, another one is that I don't see any potential users around (read: I just need a kick in the ass). > Integrating hpysics with Grapefruit might be a good topic for the Hackaton, > trying to make a simple game (e.g. Pong or Breakout) without using recursive > signal functions, but with correct collision response and better-than-Euler > integration, all handled by the physics engine. Other FRP engines could be > tried, but Grapefruit hacking is already a topic on the Hackaton, so it > would combine efforts. Yes, I'm actively pondering Hpysics+Grapefruit (it's the primary reason of my interest in Grapefruit). But first of all we need to get graphics support into Grapefruit. Does your proposal re Hackathon indicate that you'd like to join? -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From ed at edmccaffrey.net Fri Mar 6 18:35:56 2009 From: ed at edmccaffrey.net (Ed McCaffrey) Date: Fri Mar 6 18:24:25 2009 Subject: [Haskell-cafe] Looking for a co-founder for a startup using Haskell Message-ID: <86f16dc10903061535y2cce6fdeja811f4f7d4f7380c@mail.gmail.com> Hello, I'm turning a project involving music into a startup, and I will be using Haskell for most and possibly all of it. I had an angel investor interested until the market collapse forced him to turn his focus away from new investments. Other investors I have spoken with want me to contact them again when it is further developed; basically, I think that I am optimistic at the prospect of funding with the right team. I am looking for one or more co-founders in the Boston, MA, area who would be willing to work on this full-time in the near future, after funding is secured, and in their spare time until then. Since many investors are currently moving towards larger investments in growth-stage companies, I am going to apply to incubators who specialize in early-stage companies. Anyone who wants more info send a reply to ed@edmccaffrey.net Thanks, Ed McCaffrey ed@edmccaffrey.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/89cdd7c0/attachment.htm From paul at cogito.org.uk Fri Mar 6 18:59:22 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Fri Mar 6 18:47:59 2009 Subject: [Haskell-cafe] Looking for a co-founder for a startup using Haskell In-Reply-To: <86f16dc10903061535y2cce6fdeja811f4f7d4f7380c@mail.gmail.com> References: <86f16dc10903061535y2cce6fdeja811f4f7d4f7380c@mail.gmail.com> Message-ID: <49B1B8DA.6080207@cogito.org.uk> Ed McCaffrey wrote: > Other investors I have spoken with want me to contact them again when > it is further developed; That means "no". See http://blog.guykawasaki.com/2006/01/the_top_ten_lie.html Paul. From fft1976 at gmail.com Fri Mar 6 19:17:22 2009 From: fft1976 at gmail.com (FFT) Date: Fri Mar 6 19:05:53 2009 Subject: [Haskell-cafe] Re: MPI In-Reply-To: <20090306173058.GA15408@whirlpool.galois.com> References: <20090306173058.GA15408@whirlpool.galois.com> Message-ID: On Fri, Mar 6, 2009 at 9:30 AM, Don Stewart wrote: > > http://haskell.org/haskellwiki/Applications_and_libraries/Concurrency_and_parallelism#Distributed_Haskell > These are all Haskell-derived languages, not libraries, right? From duncan.coutts at worc.ox.ac.uk Fri Mar 6 19:29:52 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Mar 6 19:18:27 2009 Subject: [Haskell-cafe] Re: [Haskell] string type class In-Reply-To: <49B17691.9010402@list.mightyreason.com> References: <200903061233.36400.matthew.pocock@ncl.ac.uk> <49B17691.9010402@list.mightyreason.com> Message-ID: <1236385792.22402.273.camel@localhost> On Fri, 2009-03-06 at 19:16 +0000, Chris Kuklewicz wrote: > Matthew Pocock wrote: > > It seems every time I look at hackage there is yet another stringy > > datatype. For lots of apps, the particular stringy datatype you use > > matters for performance but not algorithmic reasons. Perhaps this is a > > good time for someone to propose a stringy class? > > Not likely. > > I did define my own (private) class for regular expressions, to abstract over > String, the ByteStrings, and Seq Char. But it is used in one place and is a > wart that should be removed. > > The simple task of looping over the contents of a String (once, forward) is > quite different from a Strict ByteString (using an index and a lookup). > > This means for decent efficiency I need two copies of my code, hand specialized > to each case. > > "tail" or "(x:xs)" : very efficient for String (no allocation) > "tail" or "uncons" : not efficient for ByteString (allocation, might as well > convert to [Char] head/tail/uncons on a strict or lazy ByteString is perfectly ok. I would recommend it over using length+index. If you are using tail in a tail recursion then ghc can almost always optimise it to unbox the various ByteString components and so there is no allocation of fresh BS constructors, just adjusting offsets and lengths held in registers. It's also possible to use unsafeHead and unsafeTail if you've checked for null. Duncan From gwern0 at gmail.com Fri Mar 6 20:19:40 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Mar 6 20:08:12 2009 Subject: [Haskell-cafe] Data.Binary stack overflow with Data.Sequence String In-Reply-To: <404396ef0903050351q3ad4bf5emc26148ae8a30d936@mail.gmail.com> References: <3a9962070903032050o4221663y77128df44b5cf965@mail.gmail.com> <404396ef0903050351q3ad4bf5emc26148ae8a30d936@mail.gmail.com> Message-ID: On Thu, Mar 5, 2009 at 6:51 AM, Neil Mitchell wrote: > Hi Gwern, > > I get String/Data.Binary issues too. My suggestion would be to change > your strings to ByteString's, serisalise, and then do the reverse > conversion when reading. Interestingly, a String and a ByteString have > identical Data.Binary reps, but in my experiments converting, > including the cost of BS.unpack, makes the reading substantially > cheaper. > > Thanks > > Neil Ah, thanks for the advice. Switching to (strict) ByteString seems to resolve the stack overflow. (And thank goodness too, I need my ireader!) I hadn't realized it was the String that was messing things up and being lazy. Very annoying! (The String code was cleaner - fewer packs/unpacks.) -- gwern From gwern0 at gmail.com Fri Mar 6 20:23:16 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Mar 6 20:11:48 2009 Subject: [Haskell-cafe] Data.Binary stack overflow with Data.Sequence String In-Reply-To: <404396ef0903051155t19cf1a75m8b98e8709c1cae9e@mail.gmail.com> References: <3a9962070903032050o4221663y77128df44b5cf965@mail.gmail.com> <404396ef0903050351q3ad4bf5emc26148ae8a30d936@mail.gmail.com> <20090305193543.GF11109@whirlpool.galois.com> <404396ef0903051155t19cf1a75m8b98e8709c1cae9e@mail.gmail.com> Message-ID: On Thu, Mar 5, 2009 at 2:55 PM, Neil Mitchell wrote: > Avoid massive reductions in runtime while maintaining the same API? > > I did move to using ByteString's internally for those bits later on, > but reading String's from Data.Binary with a ByteString+unpack went > much more quickly than reading String's > > On Thu, Mar 5, 2009 at 7:35 PM, Don Stewart wrote: >> Avoid unpack! I wish I could use ByteStrings throughout and avoid packing/unpacking, but unfortunately I don't control the Yi interfaces! If I want to stick something in a buffer, String it is. This is where recent discussions about Stringable classes certainly seem apropos - it would be nice if we didn't have to do all this marshalling and converting by hand, indeed. -- gwern From anishmuttreja at gmail.com Fri Mar 6 21:38:58 2009 From: anishmuttreja at gmail.com (Anish Muttreja) Date: Fri Mar 6 21:27:31 2009 Subject: [Haskell-cafe] Test if a file is empty or stat in haskell In-Reply-To: <4c44d90b0903051243h15a24a8ek3512a1d696147afb@mail.gmail.com> References: <20090305185642.GB23065@amuttreja-dt> <200903052015.03294.daniel.is.fischer@web.de> <20090305192446.GA23662@amuttreja-dt> <4c44d90b0903051243h15a24a8ek3512a1d696147afb@mail.gmail.com> Message-ID: <20090307023858.GA23952@amuttreja-dt> On Thu, Mar 05, 2009 at 03:43:22PM -0500, Thomas DuBuisson wrote: > >> getFileStatus, fileSize ... > > > > Great, thanks. > > BTW, Hoogle does not seem to ?know about > > System.Posix.Files, though it did point me to System.IO.FileSize > > which would also have served the purpose. > > Yep, this was discussed in a Hoogle and Network.Socket thread I > started last week. There is a wiki for summarizing thoughts [1]. > Some time this weekend or next week I intend to submit a Hoogle ticket > proposing what I see as an agreeable outcome. At that point I hope > Neil will accept and maybe even find time to write code. The final > step would involve me buying Neil a beer - I've lots of beer-debt to > the Haskell community. > > [1] http://haskell.org/haskellwiki/Hoogle/Packages Thanks Michael and Neil, for maintaining Hoogle. Hoogle is becoming a victim of it's own success. We depend on it and so want it to do everything :-). I cannot edit the wiki page because creating new logins is currently disabled. My only suggestion is that perhaps the Hoogle front page should have a discrete disclaimer about the current scope of indexed packages until a solution is found. It might be useful for someone new. Anish From rj248842 at hotmail.com Fri Mar 6 22:39:46 2009 From: rj248842 at hotmail.com (R J) Date: Fri Mar 6 22:28:17 2009 Subject: [Haskell-cafe] Type question re: map Message-ID: Given the following (usual) definition of "map": map :: (a -> b) -> [a] -> [b] map f [] = [] map f (x : xs) = f x : map f xs What's the type of "map map"? GHCi's :t command reveals: *Main> :t map map map map :: [a -> b] -> [[a] -> [b]] I'd be grateful if anyone could provide a systematic type calculation so that I can reason through more complicated examples myself. Thanks. _________________________________________________________________ Windows Live?: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090307/2c7e9995/attachment.htm From lrpalmer at gmail.com Fri Mar 6 23:35:19 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Mar 6 23:23:48 2009 Subject: [Haskell-cafe] Type question re: map In-Reply-To: References: Message-ID: <7ca3f0160903062035t8566b47je52533458c0d4cbd@mail.gmail.com> 2009/3/6 R J > > Given the following (usual) definition of "map": > > map :: (a -> b) -> [a] -> [b] > > What's the type of "map map"? > The definition is irrelevant, so I removed it. To make it easier to reason about, I'm going to rename the second map to map'. It means the same thing, but this is just so we can talk about each "instance" of it clearly. Now I'm going to rename the free variables: map :: (a -> b) -> [a] -> [b] map' :: (c -> d) -> [c] -> [d] -> is right-associative, so I'll add the implied parentheses: map :: (a -> b) -> ([a] -> [b]) map' :: (c -> d) -> ([c] -> [d]) Whenever we have an application like f x, if f has type a -> b and x has type a, then f x has type b. So map map' says that (a -> b) should be unified with the type of map', and then the type of the result will be ([a] -> [b]). So the equation is: a -> b = (c -> d) -> ([c] -> [d]) Which implies a = c -> d b = [c] -> [d] That's as far as we can go with the unification, so the result will be [a] -> [b]. Substituting, we have [c -> d] -> [[c] -> [d]]. Does that help? What I have done is more-or-less the Hindley-Milner type inference algorithm. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/5ca3bef0/attachment.htm From skynare at gmail.com Fri Mar 6 23:43:39 2009 From: skynare at gmail.com (sam lee) Date: Fri Mar 6 23:32:08 2009 Subject: [Haskell-cafe] Type question re: map In-Reply-To: References: Message-ID: <4e7aa0f80903062043y5c3a15c5nfa06833a007c19a5@mail.gmail.com> map :: (a -> b) -> [a] -> [b] map takes a function and transforms a list of a's to b's. map succ [1,2,3] ==> [succ 1, succ 2, succ 3] ==> [2, 3, 4] In general, map f :: [a] -> [b] where a is domain-type of f and b is image-type of f (f :: a -> b). map map [x, y, z] ==> [map x, map y, map z] so, x,y,z should functions of type (a -> b). and the result list, [map x, map y, map z], should have type [([a] -> [b])] because map x :: [a] -> [b] where x :: a -> b On 3/6/09, R J wrote: > > > Given the following (usual) definition of "map": > > map :: (a -> b) -> [a] -> [b] > map f [] = [] > map f (x : xs) = f x : map f xs > > What's the type of "map map"? > > GHCi's :t command reveals: > > *Main> :t map map > map map :: [a -> b] -> [[a] -> [b]] > > I'd be grateful if anyone could provide a systematic type calculation so > that I can reason through more complicated examples myself. > > Thanks. > > _________________________________________________________________ > Windows Live?: Life without walls. > http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 From wren at freegeek.org Fri Mar 6 23:49:19 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Mar 6 23:37:49 2009 Subject: [Haskell-cafe] Re: Interesting problem from Bird (4.2.13) In-Reply-To: References: Message-ID: <49B1FCCF.1060407@freegeek.org> Gleb Alexeyev wrote: > Here's my attempt though it's not really different from using built-in > lists: > > viewCL CatNil = Nothing > viewCL (Wrap a) = Just (a, CatNil) > viewCL (Cat a b) = case viewCL a of > Nothing -> viewCL b > Just (x, xs) -> Just (x, Cat xs b) My solution was a refinement on this. split = go id where go _ Nil = Nothing go k (Wrap a) = Just (a, k Nil) go k (xs :++: ys) = case go ((ys :++:) . k) xs of Nothing -> go k ys view -> view The trick is in the CPS instead of the direct approach of the original. In the original, if you have a strongly left-branching tree then you need to break the whole spine and you end up constructing another strongly left-branching spine. In this version we construct a right-branching spine instead, which allows future calls to be faster. *Main> inL[1..5] (((Wrap 1 :++: Wrap 2) :++: Wrap 3) :++: Wrap 4) :++: Wrap 5 *Main> viewCL $ inL[1..5] Just (1,(((Nil :++: Wrap 2) :++: Wrap 3) :++: Wrap 4) :++: Wrap 5) *Main> split $ inL[1..5] Just (1,Wrap 2 :++: (Wrap 3 :++: (Wrap 4 :++: Wrap 5))) -- Live well, ~wren From v.dijk.bas at gmail.com Sat Mar 7 03:58:50 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Sat Mar 7 03:47:19 2009 Subject: [Haskell-cafe] Interesting problem from Bird (4.2.13) In-Reply-To: References: Message-ID: 2009/3/4 R J : > Could someone provide an elegant solution to Bird problem 4.2.13? > > Here are the problem and my inelegant solution: > > Problem > ------- > > Since concatenation seems such a basic operation on lists, we can try to > construct a data type that captures > concatenation as a primitive. > > For example, > > data (CatList a)?????? =? CatNil > ?????????????????????? |? Wrap a > ?????????????????????? |? Cat (CatList a) (CatList a) > > The intention is that CatNil represents [], Wrap x represents [x], and Cat x > y represents > x ++ y. > > However, since "++" is associative, the expressions "Cat xs (Cat ys zs)" and > "Cat (Cat xs ys) zs" should be regarded as equal. > > Define appropriate instances of "Eq" and "Ord" for "CatList". > > Inelegant Solution > ------------------ > > The following solution works: > > instance (Eq a) => Eq (CatList a) where > ??? CatNil????? ==? CatNil?????? =??? True > ??? CatNil????? ==? Wrap?? z???? =??? False > ??? CatNil????? ==? Cat??? z w?? =? ( z == CatNil? && w == CatNil ) > > ??? Wrap?? x??? ==? CatNil?????? =??? False > ??? Wrap?? x??? ==? Wrap?? z???? =??? x == z > ??? Wrap?? x??? ==? Cat??? z w?? =? ( Wrap x == z? && w == CatNil ) || > ??????????????????????????????????? ( Wrap x == w? && z == CatNil ) > > ??? Cat??? x y? ==? CatNil?????? =??? x == CatNil? && y == CatNil > ??? Cat??? x y? ==? Wrap?? z???? =? ( x == Wrap z? && y == CatNil ) || > ??????????????????????????????????? ( x == CatNil? && y == Wrap z ) > ??? Cat??? x y? ==? Cat??? z w?? =? unwrap (Cat x y) == unwrap (Cat z w) > > unwrap??????????????? ? ? ? ? ?? :: CatList a -> [a] > unwrap CatNil??????????????????? =? [] > unwrap (Wrap x)?????? ? ? ? ? ?? =? [x] > unwrap (Cat x y)???????????????? =? unwrap x ++ unwrap y > > instance (Eq a, Ord a) => Ord (CatList a) where > ??? x < y = unwrap x < unwrap y > > This solution correctly recognizes the equality of the following, including > nested lists(represented, for example, by Wrap (Wrap 1), which corresponds > to [[1]]): > > Wrap 1?????????????????????????????? == Cat (Wrap 1) CatNil > Cat (Wrap 1) (Cat (Wrap 2) (Wrap 3)) == Cat (Wrap 1) (Cat (Wrap 2) (Wrap 3)) > Wrap (Wrap 1)??????????????????????? == Wrap (Cat (Wrap 1) CatNil) > > Although this solution works, it's a hack, because unwrap converts CatLists > to lists.? The question clearly seeks a pure solution that does not rely on > Haskell's built-in lists. > > What's the pure solution that uses cases and recursion on > CatList, not Haskell's built-in lists, to capture the equality of nested > CatLists? > > > ________________________________ > Windows Live? Contacts: Organize your contact list. Check it out. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > Here's my solution. I first "right factor" each catlist by converting a catlist into a difference catlist[1] and then turning that into a catlist again by applying it to Nil. At this point the converted catlist always has a right factored form: 'Cat a (Cat b (Cat c Nil)))' which also doesn't contain Nils except at the end. That right factored catlist is easy to compare with 'eq'. ------------------------------------------------------------------------------- data CatList a = Nil | Wrap a | Cat (CatList a) (CatList a) deriving Show type DiffCatList a = CatList a -> CatList a diff :: CatList a -> DiffCatList a diff (Cat xs ys) = diff xs . diff ys diff Nil = id diff w = Cat w rightFactor :: CatList a -> CatList a rightFactor xs = diff xs Nil instance Eq a => Eq (CatList a) where xs == ys = rightFactor xs `eq` rightFactor ys where Nil `eq` Nil = True Wrap x `eq` Wrap y = x == y Cat xs1 ys1 `eq` Cat xs2 ys2 = xs1 `eq` xs2 && ys1 `eq` ys2 _ `eq` _ = False ------------------------------------------------------------------------------- (Right now I'm thinking if it's possible to fuse the 'diff' and the 'eq' somehow so that we don't have to turn the DiffCatList into a catlist again...) regards, Bas [1] http://haskell.org/haskellwiki/Difference_list From colin at colina.demon.co.uk Sat Mar 7 08:59:33 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sat Mar 7 08:48:05 2009 Subject: [Haskell-cafe] Running HUnit tests when pushing to darcs on haskell.org Message-ID: Hello cafe, I've just followed the instructions at http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program to create my first library project on haskell.org, using darcs. I tried using the darcs setpref test command to execute: runhaskell tests/*.hs (which works locally) but it fails because it can't find Test.HUnit. When I looked back at the webpage, I see it specifically mentions QuickCheck and not HUnit, so I guess I should not have been surprised. But I would like to know if this is possible, and if so, how to arrange that runhaskell can find Test.HUnit. -- Colin Adams Preston Lancashire From colin at colina.demon.co.uk Sat Mar 7 12:18:24 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sat Mar 7 12:06:52 2009 Subject: [Haskell-cafe] Mystified by Cabal Message-ID: I have just attempted Cabal-izing my program (splitting it into a library and main program as well), and I'm mystified by some problems I am having. First, when I try to build the library I get: [colin@susannah game-tree]$ runhaskell Setup build Preprocessing library game-tree-1.0.0.0... Building game-tree-1.0.0.0... Data/Tree/Game/Negascout.hs:31:0: Unrecognised pragma [1 of 2] Compiling Data.Tree.Game.Tree ( Data/Tree/Game/Tree.hs, dist/build/Data/Tree/Game/Tree.o ) Data/Tree/Game/Tree.hs:1:0: Failed to load interface for `Prelude': it is a member of package base-3.0.3.0, which is hidden That mystifies me. Googling, it appears to be a common error in the past, but none of the reasons apparently apply to my case. Incidentally, Tree.hs imports nothing. It just looks like: -- | Nodes in game trees -- Copyright 2009 Colin Adams -- -- This file is part of game-tree. -- -- Game-tree is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- Game-tree is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- You should have received a copy of the GNU General Public License -- along with game-tree. If not, see . module Data.Tree.Game.Tree where -- | Nodes in a game search tree class Tree a where -- | Is this a game-terminating node (e.g. checkmate)? is_terminal :: a -> Bool -- | Heuristic value of node node_value :: a -> Int -- | Child nodes in the game tree (positions more deeply searched) children :: a -> [a] So I couldn't build my program using runhaskell, as I couldn't install the library. Instead, i tried ghc --make instead with the -idir option. It looks in the right place, but still doesn't recognise the module: Chasing modules from: *Chu-shogi.hs Generator.hs:27:7: Could not find module `Data.Tree.Game.Tree': locations searched: Data/Tree/Game/Tree.hs Data/Tree/Game/Tree.lhs dirs=../game-tree/Data/Tree/Game/Tree.hs dirs=../game-tree/Data/Tree/Game/Tree.lhs What am I doing wrong? Perhaps Cabal should be named Caballa instead. -- Colin Adams Preston Lancashire From svein.ove at aas.no Sat Mar 7 12:26:46 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sat Mar 7 12:15:13 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: References: Message-ID: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> On Sat, Mar 7, 2009 at 6:18 PM, Colin Paul Adams wrote: > I have just attempted Cabal-izing my program (splitting it into a > library and main program as well), and I'm mystified by some problems > I am having. > > First, when I try to build the library I get: > > [colin@susannah game-tree]$ runhaskell Setup build > Preprocessing library game-tree-1.0.0.0... > Building game-tree-1.0.0.0... > > Data/Tree/Game/Negascout.hs:31:0: Unrecognised pragma > [1 of 2] Compiling Data.Tree.Game.Tree ( Data/Tree/Game/Tree.hs, dist/build/Data/Tree/Game/Tree.o ) > > Data/Tree/Game/Tree.hs:1:0: > ? ?Failed to load interface for `Prelude': > ? ? ?it is a member of package base-3.0.3.0, which is hidden > What does your .cabal file look like? > > Perhaps Cabal should be named Caballa instead. > Nah, it's not /that/ bad. :P You might want to install the mkcabal package, use that to generate the initial .cabal file. Though I'm not sure what you might have gotten wrong.. well, show us the file first. - Svein Ove From colin at colina.demon.co.uk Sat Mar 7 12:30:43 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sat Mar 7 12:19:12 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> (Svein Ove Aas's message of "Sat\, 7 Mar 2009 18\:26\:46 +0100") References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> Message-ID: >>>>> "Svein" == Svein Ove Aas writes: >> Preprocessing library game-tree-1.0.0.0... Building >> game-tree-1.0.0.0... >> >> Data/Tree/Game/Negascout.hs:31:0: Unrecognised pragma [1 of 2] >> Compiling Data.Tree.Game.Tree ( Data/Tree/Game/Tree.hs, >> dist/build/Data/Tree/Game/Tree.o ) >> >> Data/Tree/Game/Tree.hs:1:0: ? ?Failed to load interface for >> `Prelude': ? ? ?it is a member of package base-3.0.3.0, which >> is hidden >> Svein> What does your .cabal file look like? name: game-tree version: 1.0.0.0 cabal-version: >= 1.6 synopsis: Searching game trees with alpha-beta pruning description: A data type for game trees, as used in decision theory and game theory, along with standard algorithms for searching the tree using alpha-beta pruning. Can be used as the basis of an AI for two-player zero-sum games, such as chess. category: Data license: GPL license-file: LICENSE author: Colin Adams maintainer: colin@colina.demon.co.uk copyright: Copyright: 2009 Colin Adams build-type: Simple build-depends: base >= 4 ghc-options: -Wall -fno-warn-unrecognised-pragmas Library exposed-modules: Data.Tree.Game.Tree, Data.Tree.Game.Negascout source-repository head type: darcs location: http://code.haskell.org/game-tree/ -- Colin Adams Preston Lancashire From bugfact at gmail.com Sat Mar 7 12:34:10 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Mar 7 12:22:40 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics In-Reply-To: <20090306213958.GA6963@flit> References: <20090306213958.GA6963@flit> Message-ID: On Fri, Mar 6, 2009 at 10:39 PM, Roman Cheplyaka wrote: > > The blog > > seems to be inactive since december 2008; has development ceased? > > Sort of. One reason is that DPH does not seem to be ready for hpysics > yet, another one is that I don't see any potential users around (read: I > just need a kick in the ass). > Is it a performance issue? > > > Integrating hpysics with Grapefruit might be a good topic for the > Hackaton, > > trying to make a simple game (e.g. Pong or Breakout) without using > recursive > > signal functions, but with correct collision response and > better-than-Euler > > integration, all handled by the physics engine. Other FRP engines could > be > > tried, but Grapefruit hacking is already a topic on the Hackaton, so it > > would combine efforts. > > Yes, I'm actively pondering Hpysics+Grapefruit (it's the primary reason > of my interest in Grapefruit). But first of all we need to get graphics > support into Grapefruit. > > Does your proposal re Hackathon indicate that you'd like to join? > Yes, Thomas 'Bob' Davie and I already joined the Hackaton, but the wiki is not yet updated.I see you've joined too, cool -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090307/5875d2ac/attachment.htm From bulat.ziganshin at gmail.com Sat Mar 7 12:36:07 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Mar 7 12:24:57 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> Message-ID: <1566756950.20090307203607@gmail.com> Hello Colin, Saturday, March 7, 2009, 8:30:43 PM, you wrote: > >> Data/Tree/Game/Tree.hs:1:0: ? ?Failed to load interface for > >> `Prelude': ? ? ?it is a member of package base-3.0.3.0, which > >> is hidden > build-depends: base >= 4 and which ghc version you are running? :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From greenrd at greenrd.org Sat Mar 7 12:43:47 2009 From: greenrd at greenrd.org (Robin Green) Date: Sat Mar 7 12:31:54 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> Message-ID: <20090307174347.11ae2a36@greenrd.org> On Sat, 07 Mar 2009 17:30:43 +0000 Colin Paul Adams wrote: > >>>>> "Svein" == Svein Ove Aas writes: > > >> Preprocessing library game-tree-1.0.0.0... Building > >> game-tree-1.0.0.0... > >> > >> Data/Tree/Game/Negascout.hs:31:0: Unrecognised pragma [1 of 2] > >> Compiling Data.Tree.Game.Tree ( Data/Tree/Game/Tree.hs, > >> dist/build/Data/Tree/Game/Tree.o ) > >> > >> Data/Tree/Game/Tree.hs:1:0: ? ?Failed to load interface for > >> `Prelude': ? ? ?it is a member of package base-3.0.3.0, which > >> is hidden > >> > Svein> What does your .cabal file look like? > > name: game-tree > version: 1.0.0.0 > cabal-version: >= 1.6 > synopsis: Searching game trees with alpha-beta pruning > description: A data type for game trees, as used in decision > theory and game theory, along with standard algorithms for searching > the tree using alpha-beta pruning. Can be used as the basis of an AI > for two-player zero-sum games, such as chess. category: > Data license: GPL > license-file: LICENSE > author: Colin Adams > maintainer: colin@colina.demon.co.uk > copyright: Copyright: 2009 Colin Adams > build-type: Simple > build-depends: base >= 4 > ghc-options: -Wall -fno-warn-unrecognised-pragmas > > Library > exposed-modules: Data.Tree.Game.Tree, Data.Tree.Game.Negascout > source-repository head > type: darcs > location: http://code.haskell.org/game-tree/ The build-depends line needs to go in the Library section, I think. It doesn't seem to be having any effect in its current location. Likewise for ghc-options. -- Robin From colin at colina.demon.co.uk Sat Mar 7 12:48:33 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sat Mar 7 12:37:02 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: <20090307174347.11ae2a36@greenrd.org> (Robin Green's message of "Sat\, 7 Mar 2009 17\:43\:47 +0000") References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> <20090307174347.11ae2a36@greenrd.org> Message-ID: >>>>> "Robin" == Robin Green writes: Robin> The build-depends line needs to go in the Library section, Robin> I think. It doesn't seem to be having any effect in its Robin> current location. Likewise for ghc-options. Thanks everyone - it's working now. -- Colin Adams Preston Lancashire From felipe.lessa at gmail.com Sat Mar 7 12:49:11 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Mar 7 12:37:39 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics In-Reply-To: References: Message-ID: 2009/3/6 Peter Verswyvelen : > Do alternatives exist? Maybe good wrappers?(hopefully pure...)??around > existing engines? There's Hipmunk, but it is not pure and not that good ;). But if you don't mess with the global variables (which you normally wouldn't mess anyway) then you can wrap everything in a separate monad with unsafePerformIO's, I guess. -- Felipe. From roma at ro-che.info Sat Mar 7 12:49:25 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Sat Mar 7 12:38:30 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics In-Reply-To: References: <20090306213958.GA6963@flit> Message-ID: <20090307174925.GA8835@flit> * Peter Verswyvelen [2009-03-07 18:34:10+0100] > On Fri, Mar 6, 2009 at 10:39 PM, Roman Cheplyaka wrote: > > > > The blog > > > seems to be inactive since december 2008; has development ceased? > > > > Sort of. One reason is that DPH does not seem to be ready for hpysics > > yet, another one is that I don't see any potential users around (read: I > > just need a kick in the ass). > > > > Is it a performance issue? Yes. As Roman Leshchinskiy explained it's because parallel arrays are not fused properly yet. But it's quite trivial to modify Hpysics to use ordinary lists or arrays, and I think it'll give reasonable performance. > > > Integrating hpysics with Grapefruit might be a good topic for the > > Hackaton, > > > trying to make a simple game (e.g. Pong or Breakout) without using > > recursive > > > signal functions, but with correct collision response and > > better-than-Euler > > > integration, all handled by the physics engine. Other FRP engines could > > be > > > tried, but Grapefruit hacking is already a topic on the Hackaton, so it > > > would combine efforts. > > > > Yes, I'm actively pondering Hpysics+Grapefruit (it's the primary reason > > of my interest in Grapefruit). But first of all we need to get graphics > > support into Grapefruit. > > > > Does your proposal re Hackathon indicate that you'd like to join? > > > > Yes, Thomas 'Bob' Davie and I already joined the Hackaton, but the wiki is > not yet updated.I see you've joined too, cool Great! I'll have more free time after March 15, and we can arrange an IRC meeting to discuss this. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From dons at galois.com Sat Mar 7 13:15:01 2009 From: dons at galois.com (Don Stewart) Date: Sat Mar 7 13:04:41 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: References: Message-ID: <20090307181501.GB19807@whirlpool.galois.com> colin: > I have just attempted Cabal-izing my program (splitting it into a > library and main program as well), and I'm mystified by some problems > I am having. > > First, when I try to build the library I get: > > [colin@susannah game-tree]$ runhaskell Setup build > Preprocessing library game-tree-1.0.0.0... > Building game-tree-1.0.0.0... > > Data/Tree/Game/Negascout.hs:31:0: Unrecognised pragma > [1 of 2] Compiling Data.Tree.Game.Tree ( Data/Tree/Game/Tree.hs, dist/build/Data/Tree/Game/Tree.o ) > > Data/Tree/Game/Tree.hs:1:0: > Failed to load interface for `Prelude': > it is a member of package base-3.0.3.0, which is hidden > build-depends: base You certainly depend on the base library, unless you're doing only haskell98 work. From apfelmus at quantentunnel.de Sat Mar 7 13:18:20 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sat Mar 7 13:05:58 2009 Subject: [Haskell-cafe] Re: Zippers In-Reply-To: References: <2f9b2d30903041800l71753c19p187d17d739275a8b@mail.gmail.com> Message-ID: Cristiano Paris wrote: > Heinrich Apfelmus wrote: >> ... >> Such self-reference is usually called "tying the knot", see also >> >> http://www.haskell.org/haskellwiki/Tying_the_Knot > > I didn't know. Would you call this "Tying the knot" as well? > > http://yi-editor.blogspot.com/2008/12/prototypes-encoding-oo-style.html Yes, or rather, I would call it "untying the knot". ;) Regards, apfelmus -- http://apfelmus.nfshost.com From briqueabraque at yahoo.com Sat Mar 7 14:28:21 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sat Mar 7 14:17:00 2009 Subject: [Haskell-cafe] Ambiguous type with PolymorphicComponents Message-ID: Hi, When reading this code in ghci, I get an ambiguous type at last line: {-# LANGUAGE PolymorphicComponents #-} {-# LANGUAGE RankNTypes #-} import Graphics.UI.Gtk data Test = Test (forall w. WidgetClass w => w) toAction (Test w) = toWidget w It's interesting that if I replace 'Integral' for 'WidgetClass' and 'toInteger' for 'toWidget', I get no error messages, and I see no essencial diference between both classes and both functions. Do you know what am I missing? Thanks, Maur?cio From kowey at darcs.net Sat Mar 7 14:32:01 2009 From: kowey at darcs.net (Eric Kow) Date: Sat Mar 7 14:20:31 2009 Subject: [Haskell-cafe] Re: a newbies confusion with repositories - darcs or git In-Reply-To: <20090301104046.GB32441@Macintosh.local> References: <20090301104046.GB32441@Macintosh.local> Message-ID: <20090307193201.GC12985@Macintosh.local> Hi again, I wanted to echo Iavor's comment that you shouldn't feel 'obliged' to use darcs out of Haskell brand loyalty. Try both systems out and see how they feel. My enthusiasm is really about what I find to be a great and very comfortable workflow. You'll have to see for yourself what suits you best. More importantly... On Sun, Mar 01, 2009 at 10:40:46 +0000, Eric Y. Kow wrote: > Why I love darcs > ================ One of the darcs team members, Thorkil Naur, felt that in my enthusiasm I was not being sufficiently forthright about darcs's shortcomings. First, I would like to express my gratitude to Thorkil for calling me out. Second, I wanted to state unequivocally that darcs, no matter how much I love it, is not perfect. > It's not just that it's written in Haskell; it's that the whole thing > is driven by something which is very clean, powerful and which > delivers a concrete impact in the real world. When I said this, I was focusing on one idea: namely that most of the darcs user interface is just as straightforward consequence of two operations: patch inverse and patch commutation. In my eyes, that was very clean, the whole of darcs basically just boils down to these two operations. What I failed to add is that /defining/ how patches should commute is not so beautiful. The problem occurs when patches conflicts; the question of how patches should commute when they conflict is still not completely well understood. We have some working ideas: code for darcs-1 and darcs-2 patch theories which seems to work reasonably well. But to call it clean and elegant would definitely be a stretch. Furthermore, darcs has bugs, some of which are fairly deep (where conflicts or duplicate patches are involved). Some of these bugs are documented and some we have only recently discovered, and some may be looming just around the corner. So far, these bugs have not affected a lot of repositories, and in those cases, it has been fairly straightforward to recover from them. But know that they are there. > We now have a stable and more sustainable development team (I'm working on 20% > darcs time at my job with the University of Brighton and have committed myself > to spending no more than 8 hours a week on darcs to avoid burnout; a lot of our > jobs have been assigned to dedicated managers -- hello!) and are adopting some > new practices (hacking sprints, 6-month time based release schedule) to keep > development running more smoothly. Another reason to be concerned about the darcs team is that since David Roundy retired from darcs life, we do not have anybody who deeply understands darcs, that is, all the way down to the inner workings of a darcs repository (for example the manipulation of the pending patch) and to its patch theory core. We have folks like me who have a rudimentary understanding of patch theory (i.e. who grasp the relationship between commutation, inversion and merging and who also understand some of what darcs-1 conflicts are), but what we lack are people who deeply understand the darcs-2 core (Ian Lynagh's work on camp is actually quite similar to darcs 2, so in a sense, he does understand it), especially as it's implemented. This puts us in an awkward position, one of not being able to quickly work through any fundamental bugs if they should arise. We would have to scamper up that learning curve fairly quickly. But I'm still optimistic over the long term. These things will come. We've made a lot of progress building up our community infrastructure, and we are learning how to make better use of our time. For what it's worth, a few of us on the team will be focusing on darcs fundamentals during the sprint. We need more testing, we need to look at our deep bugs more closely and we need to learn our way through darcs's guts. And I think we can do it. Thanks, Eric PS. We have started a fundraising effort to get folks to the darcs hacking sprint. More details on that shortly. -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090307/f2d4bf17/attachment.bin From frigginfriggins at gmail.com Sat Mar 7 14:57:04 2009 From: frigginfriggins at gmail.com (friggin friggin) Date: Sat Mar 7 14:45:31 2009 Subject: [Haskell-cafe] serializing large data structures, stack overflow Message-ID: <6c5a7ce40903071157m3a237a54r1529f38e02c473e5@mail.gmail.com> I'm playing around with Netflix, implementing a simple KNN-algorithm, I will later try SVD which seems to be the most successful approach. Using a database like Postgresqk is to slow so I want to serialize a datastructure containing the ratings. I'm not sure about the representation I will use just yet, if I should use multiple arrays or an Map/IntMap. However I tried Data.Binary and already for small sizes I get stack overflow when deserializing. The serializing works fine but when bringing it back it overflows. How can I solve this? This is just 2MB, I will eventually need soemthing like 2-500MB to store everything depending on what representatin I choose. module Serialize where import qualified Data.Binary as B import qualified Data.Binary.Put as P import qualified Data.Map as M import qualified Data.List as L genTest :: Int -> M.Map (Int,Int) Int genTest n = let movies = take n $ repeat 1 grades = take n $ repeat 4 in M.fromList $ ([1..n] `zip` movies) `zip` grades main = do let a = genTest 50000 B.encodeFile "C:/users/saftarn/desktop/bintest.txt" a print "Success" dec = B.decodeFile "C:/users/saftarn/desktop/bintest.txt" >>= \a -> return $ (a :: M.Map (Int,Int) Int) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090307/3bf22223/attachment.htm From dons at galois.com Sat Mar 7 14:57:57 2009 From: dons at galois.com (Don Stewart) Date: Sat Mar 7 14:47:14 2009 Subject: [Haskell-cafe] serializing large data structures, stack overflow In-Reply-To: <6c5a7ce40903071157m3a237a54r1529f38e02c473e5@mail.gmail.com> References: <6c5a7ce40903071157m3a237a54r1529f38e02c473e5@mail.gmail.com> Message-ID: <20090307195757.GC19807@whirlpool.galois.com> Increase the stack size, or use a different serialiser (they're only a half dozen lines to write), or different data structure? -- Don frigginfriggins: > I'm playing around with Netflix, implementing a simple KNN-algorithm, I will > later try SVD which seems to be the most successful approach. > > Using a database like Postgresqk is to slow so I want to serialize a > datastructure containing the ratings. I'm not sure about the > representation I will use just yet, if I should use multiple arrays or an Map/ > IntMap. > > However I tried Data.Binary and already for small sizes I get stack overflow > when deserializing. > The serializing works fine but when bringing it back it overflows. > How can I solve this? This is just 2MB, I will eventually need soemthing like > 2-500MB to store everything depending on what representatin I choose. > > module Serialize where > import qualified Data.Binary as B > import qualified Data.Binary.Put as P > import qualified Data.Map as M > import qualified Data.List as L > > genTest :: Int -> M.Map (Int,Int) Int > genTest n = let movies = take n $ repeat 1 > grades = take n $ repeat 4 in > M.fromList $ ([1..n] `zip` movies) `zip` grades > > main = do > let a = genTest 50000 > B.encodeFile "C:/users/saftarn/desktop/bintest.txt" a > print "Success" > > dec = B.decodeFile "C:/users/saftarn/desktop/bintest.txt" >>= \a -> > return $ (a :: M.Map (Int,Int) Int) > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Sat Mar 7 15:01:33 2009 From: dons at galois.com (Don Stewart) Date: Sat Mar 7 14:50:50 2009 Subject: [Haskell-cafe] serializing large data structures, stack overflow In-Reply-To: <6c5a7ce40903071200l358f467fkdfeaacba647974ea@mail.gmail.com> References: <6c5a7ce40903071157m3a237a54r1529f38e02c473e5@mail.gmail.com> <20090307195757.GC19807@whirlpool.galois.com> <6c5a7ce40903071200l358f467fkdfeaacba647974ea@mail.gmail.com> Message-ID: <20090307200133.GE19807@whirlpool.galois.com> import Data.Binary and then write a variant of something like how Maps are currently serialised: instance (Ord k, Binary k, Binary e) => Binary (Map.Map k e) where put m = put (Map.size m) >> mapM_ put (Map.toAscList m) get = liftM Map.fromDistinctAscList get So you might want something that avoids flattening it to a list first -- Don frigginfriggins: > can you link to a good example of writing your own because I couldn't find one. > > On Sat, Mar 7, 2009 at 8:57 PM, Don Stewart wrote: > > Increase the stack size, or use a different serialiser (they're only a > half dozen lines to write), or different data structure? > > -- Don > > frigginfriggins: > > I'm playing around with Netflix, implementing a simple KNN-algorithm, I > will > > later try SVD which seems to be the most successful approach. > > > > Using a database like Postgresqk is to slow so I want to serialize a > > datastructure containing the ratings. I'm not sure about the > > representation I will use just yet, if I should use multiple arrays or an > Map/ > > IntMap. > > > > However I tried Data.Binary and already for small sizes I get stack > overflow > > when deserializing. > > The serializing works fine but when bringing it back it overflows. > > How can I solve this? This is just 2MB, I will eventually need soemthing > like > > 2-500MB to store everything depending on what representatin I choose. > > > > module Serialize where > > import qualified Data.Binary as B > > import qualified Data.Binary.Put as P > > import qualified Data.Map as M > > import qualified Data.List as L > > > > genTest :: Int -> M.Map (Int,Int) Int > > genTest n = let movies = take n $ repeat 1 > > grades = take n $ repeat 4 in > > M.fromList $ ([1..n] `zip` movies) `zip` grades > > > > main = do > > let a = genTest 50000 > > B.encodeFile "C:/users/saftarn/desktop/bintest.txt" a > > print "Success" > > > > dec = B.decodeFile "C:/users/saftarn/desktop/bintest.txt" >>= \a -> > > return $ (a :: M.Map (Int,Int) Int) > > > > > > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From daniel.is.fischer at web.de Sat Mar 7 15:04:37 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Mar 7 14:53:06 2009 Subject: [Haskell-cafe] Ambiguous type with PolymorphicComponents In-Reply-To: References: Message-ID: <200903072104.37253.daniel.is.fischer@web.de> Am Samstag, 7. M?rz 2009 20:28 schrieb Maur??cio: > Hi, > > When reading this code in ghci, I get an > ambiguous type at last line: > > > {-# LANGUAGE PolymorphicComponents #-} > {-# LANGUAGE RankNTypes #-} > import Graphics.UI.Gtk > data Test = Test (forall w. WidgetClass w => w) > toAction (Test w) = toWidget w > > > It's interesting that if I replace 'Integral' for > 'WidgetClass' and 'toInteger' for 'toWidget', I > get no error messages, and I see no essencial > diference between both classes and both functions. > > Do you know what am I missing? Type defaulting. When you have data Test = Test (forall w. (C1 w, C2 w, ..., Cn w) => w) and function (Test w) = classmethod w, there is no way to decide which instance to use, hence the type variable is ambiguous. But if at least one of these classes is numeric and all of the classes are defined in the standard libraries, then (section 4.3.4 of the report, IIRC) the ambiguous type variable is defaultable. In the case of Integral and toInteger, defaulting kicks in and defaults the type to Integer (unless you specified other defaults): {-# LANGUAGE PolymorphicComponents #-} {-# LANGUAGE RankNTypes #-} data Test = Test (forall w. (Show w, Integral w) => w) toAction (Test w) = show w $ ghci Polymorph -fwarn-type-defaults GHCi, version 6.8.3: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling Main ( Polymorph.hs, interpreted ) Polymorph.hs:6:25: Warning: Defaulting the following constraint(s) to type `Integer' `Integral w' arising from a use of `w' at Polymorph.hs:6:25 In the first argument of `show', namely `w' In the expression: show w In the definition of `toAction': toAction (Test w) = show w Ok, modules loaded: Main. *Main> If you really want the contents of Test to bepolymorphic, before you use it, you must cast it to some specific type, toAction (Test w) = toWidget (w :: SomeSpecificWidget) should work. > > Thanks, > Maur?cio Cheers, Daniel From bulat.ziganshin at gmail.com Sat Mar 7 15:29:11 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Mar 7 15:18:02 2009 Subject: [Haskell-cafe] serializing large data structures, stack overflow In-Reply-To: <6c5a7ce40903071157m3a237a54r1529f38e02c473e5@mail.gmail.com> References: <6c5a7ce40903071157m3a237a54r1529f38e02c473e5@mail.gmail.com> Message-ID: <431190330.20090307232911@gmail.com> Hello friggin, Saturday, March 7, 2009, 10:57:04 PM, you wrote: > dec = B.decodeFile "C:/users/saftarn/desktop/bintest.txt" >>= \a -> > ????? return $ (a :: M.Map (Int,Int) Int) just a quick style hack: dec = B.decodeFile "C:/users/saftarn/desktop/bintest.txt" :: IO (M.Map (Int,Int) Int) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From briqueabraque at yahoo.com Sat Mar 7 15:48:25 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sat Mar 7 15:37:02 2009 Subject: [Haskell-cafe] Re: Ambiguous type with PolymorphicComponents In-Reply-To: <200903072104.37253.daniel.is.fischer@web.de> References: <200903072104.37253.daniel.is.fischer@web.de> Message-ID: >> (...) > When you have > > data Test = Test (forall w. (C1 w, C2 w, ..., Cn w) => w) > > and > > function (Test w) = classmethod w, > > there is no way to decide which instance to use, hence the type variable is > ambiguous. > (...) But, then, how can I reach the data inside a polymorphic component? Or, better, what can I do with it? If I say: function (Test w) = classmethod (w :: specificType) then I have to suppose that w is always of 'specificType', and this may not be true. Thanks, Maur?cio From daniel.is.fischer at web.de Sat Mar 7 16:11:21 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Mar 7 15:59:48 2009 Subject: [Haskell-cafe] Re: Ambiguous type with PolymorphicComponents In-Reply-To: References: <200903072104.37253.daniel.is.fischer@web.de> Message-ID: <200903072211.21327.daniel.is.fischer@web.de> Am Samstag, 7. M?rz 2009 21:48 schrieb Maur??cio: > >> (...) > > > > When you have > > > > data Test = Test (forall w. (C1 w, C2 w, ..., Cn w) => w) > > > > and > > > > function (Test w) = classmethod w, > > > > there is no way to decide which instance to use, hence the type variable > > is ambiguous. > > (...) > > But, then, how can I reach the data inside a > polymorphic component? Or, better, what can I > do with it? If I say: > > function (Test w) = classmethod (w :: specificType) > > then I have to suppose that w is always of > 'specificType', and this may not be true. If w :: forall a. (Class a) => a, then w is (can be) of all specific types which are instances of Class. Perhaps what you wanted was an existential type: {-# LANGUAGE ExistentialQuantification #-} data ETest = forall w. WidgetClass w => ETest w ? Or a GADT: data GTest where GTest :: forall a. WidgetClass a => a -> GTest ? > > Thanks, > Maur?cio > Cheers, Daniel From rj248842 at hotmail.com Sat Mar 7 17:06:37 2009 From: rj248842 at hotmail.com (R J) Date: Sat Mar 7 16:55:05 2009 Subject: [Haskell-cafe] Converting list comprehensions to combinatory style Message-ID: Can anyone help with this problem from Bird: a. Convert the following list comprehensions to combinatory style: i. [(x, y) | x <- [1..n], odd x, y <- [1..n]] ii. [(x, y) | x <- [1..n], y <- [1..n], odd x] b. Are they equal? c. Compare the costs of evaluating the two expressions. I gather that by combinatory style, he means the use of concat, map, and filter. While Bird provides the following conversion rules, he doesn't prove them, justify them, or even provide an example using them: R1. [ f x | x <- xs ] = map f xs R2. [ x | x <- xs, p x ] = filter p xs R3. [ e | Q, P ] = concat [[e | P] | Q] R4. [ e | x <- [d | P] ] = [e [x := d] | Q, P] Thanks. _________________________________________________________________ Windows Live? Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090307/f11ecd3b/attachment.htm From martijn at van.steenbergen.nl Sat Mar 7 17:12:36 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Mar 7 17:01:03 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: <1236299206.5837.2.camel@derek-laptop> References: <1236298375.32464.26.camel@jcchost> <1236299206.5837.2.camel@derek-laptop> Message-ID: <49B2F154.5010805@van.steenbergen.nl> Derek Elkins wrote: > Both are poorish style. > > reader <- forkIO $ forever $ do (nr', line) <- readChan; when (nr /= nr') $ putStrLn hdl line This is fine assuming you always want to re-enter the loop. If you want to loop conditionally (which is most often the case), forever isn't going to work, unless you use exceptions. Martijn. From rj248842 at hotmail.com Sat Mar 7 17:18:28 2009 From: rj248842 at hotmail.com (R J) Date: Sat Mar 7 17:06:55 2009 Subject: [Haskell-cafe] Naturality condition for inits Message-ID: Here's another Bird problem that's stymied me: The function "inits" computes the list of initial segments of a list; its type is inits :: [a] -> [[a]]. What is the appropriate naturality condition for "inits"? The only discussion in the text concerning naturality conditions concerns map, where the naturality conditions are stated in what seem to be quasi-commutativity laws over the composition operator, as follows: f . head = head . map f, where f is strict (i.e., f _|_ = _|_) map f . tail = tail . map f map f (xs ++ ys) = map f xs ++ map f ys map f . reverse = reverse . map f map f . concat = concat . map (map f) I believe that none of the following naturality conditions, extrapolated from those above, hold: a. head . inits = inits [head] b. tail . inits = inits . tail c. reverse . inits = inits . reverse d. concat . inits = inits . concat In case the definition of "inits" is relevant, my definition is: inits :: [a] -> [[a]] inits xs = [take n xs | n <- seglengths] where seglengths = [0..length xs] Thanks. _________________________________________________________________ Windows Live?: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090307/76e7d3c5/attachment.htm From derek.a.elkins at gmail.com Sat Mar 7 17:27:17 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Mar 7 17:15:49 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: <49B2F154.5010805@van.steenbergen.nl> References: <1236298375.32464.26.camel@jcchost> <1236299206.5837.2.camel@derek-laptop> <49B2F154.5010805@van.steenbergen.nl> Message-ID: <1236464837.5837.7.camel@derek-laptop> On Sat, 2009-03-07 at 23:12 +0100, Martijn van Steenbergen wrote: > Derek Elkins wrote: > > Both are poorish style. > > > > reader <- forkIO $ forever $ do (nr', line) <- readChan; when (nr /= nr') $ putStrLn hdl line > > This is fine assuming you always want to re-enter the loop. If you want > to loop conditionally (which is most often the case), forever isn't > going to work, unless you use exceptions. If you are doing something else, use something else. This makes it clear that you -aren't- going to break out (non-exceptionally), i.e. the control flow is more obvious in this code than in the other versions. By your logic 'map' would be bad because not everything is a map, of course, this is precisely why using map, when applicable, is good. From martijn at van.steenbergen.nl Sat Mar 7 17:34:42 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Mar 7 17:23:09 2009 Subject: [Haskell-cafe] do you have to use fix with forkio? In-Reply-To: <1236464837.5837.7.camel@derek-laptop> References: <1236298375.32464.26.camel@jcchost> <1236299206.5837.2.camel@derek-laptop> <49B2F154.5010805@van.steenbergen.nl> <1236464837.5837.7.camel@derek-laptop> Message-ID: <49B2F682.9040807@van.steenbergen.nl> Derek Elkins wrote: > If you are doing something else, use something else. This makes it > clear that you -aren't- going to break out (non-exceptionally), i.e. the > control flow is more obvious in this code than in the other versions. Oh yes, of course! I wasn't saying forever is bad; in fact I agree with you that it's the best solution in this case. I just wanted to note that forever isn't always a good substitute for "fix $ \loop ->", without implying that was what you were suggesting. Martijn. From daniel.is.fischer at web.de Sat Mar 7 17:36:29 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Mar 7 17:24:57 2009 Subject: [Haskell-cafe] Converting list comprehensions to combinatory style In-Reply-To: References: Message-ID: <200903072336.29808.daniel.is.fischer@web.de> Am Samstag, 7. M?rz 2009 23:06 schrieb R J: > Can anyone help with this problem from Bird: > > a. Convert the following list comprehensions to combinatory style: > > i. [(x, y) | x <- [1..n], odd x, y <- [1..n]] > ii. [(x, y) | x <- [1..n], y <- [1..n], odd x] > > b. Are they equal? > > c. Compare the costs of evaluating the two expressions. > > I gather that by combinatory style, he means the use of concat, map, and > filter. While Bird provides the following conversion rules, he doesn't > prove them, justify them, or even provide an example using them: > > R1. [ f x | x <- xs ] = map f xs > R2. [ x | x <- xs, p x ] = filter p xs > R3. [ e | Q, P ] = concat [[e | P] | Q] > R4. [ e | x <- [d | P] ] = [e [x := d] | Q, P] > > Thanks. You can take R1-R4 as definition of the list-comprehension syntax. Then you can rewrite i. step by step: [(x,y) | x <- [1 .. n], odd x, y <- [1 .. n]] ~> concat [[(x,y) | y <- [1 .. n]] | x <- [1 .. n], odd x]] ~> concat [map (\y -> (x,y)) [1 .. n] | x <- [1 .. n], odd x] ~> concat (map (\x -> map (\y -> (x,y)) [1 .. n]) (filter odd [1 .. n])) (okay, I cheated, the last step is actually a sequence of steps, transforming [f x | x <- xs, p x] into map f (filter p xs)). From derek.a.elkins at gmail.com Sat Mar 7 17:37:48 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Mar 7 17:26:19 2009 Subject: [Haskell-cafe] Naturality condition for inits In-Reply-To: References: Message-ID: <1236465468.5837.16.camel@derek-laptop> On Sat, 2009-03-07 at 22:18 +0000, R J wrote: > Here's another Bird problem that's stymied me: > > The function "inits" computes the list of initial segments of a list; > its type is inits :: [a] -> [[a]]. What is the appropriate naturality > condition for "inits"? A natural transformation is between two Functors f and g is a polymorphic function t :: (Functor f, Functor g) => f a -> g a. The naturality condition is the free theorem which states*: for any function f :: A -> B, t . fmap f = fmap f . t Note that fmap is being used in two different instances here. For lists, fmap = map and so we have for any polymorphic function [a] -> [a] using reverse as a representative, map f . reverse = reverse . map f. inits is a natural transformation between [] and [] . [] (where . is type-level composition and not expressible in Haskell). Functors compose just by composing their fmaps, so fmap for [] . [] is simply map . map, therefore the naturality condition for inits is the following: for any function f :: A -> B, inits . map f = map (map f) . inits which you can easily prove. * Actually there are some restrictions relating to bottom. From daniel.is.fischer at web.de Sat Mar 7 17:46:51 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Mar 7 17:35:18 2009 Subject: [Haskell-cafe] Naturality condition for inits In-Reply-To: References: Message-ID: <200903072346.51650.daniel.is.fischer@web.de> Am Samstag, 7. M?rz 2009 23:18 schrieb R J: > Here's another Bird problem that's stymied me: > > The function "inits" computes the list of initial segments of a list; its > type is inits :: [a] -> [[a]]. What is the appropriate naturality > condition for "inits"? > > The only discussion in the text concerning naturality conditions concerns > map, where the naturality conditions are stated in what seem to be > quasi-commutativity laws over the composition operator, as follows: > > f . head = head . map f, where f is strict (i.e., f _|_ = > _|_) map f . tail = tail . map f > map f (xs ++ ys) = map f xs ++ map f ys > map f . reverse = reverse . map f > map f . concat = concat . map (map f) > > I believe that none of the following naturality conditions, extrapolated > from those above, hold: > > a. head . inits = inits [head] > b. tail . inits = inits . tail > c. reverse . inits = inits . reverse > d. concat . inits = inits . concat How does inits interplay with (map f)? Though inits . tail =/= tail . inits, there is an interesting relation between inits (tail xs) and inits xs, which? When you also consider the function tails, there is an interesting relation involving inits and reverse, too. > > In case the definition of "inits" is relevant, my definition is: > > > > inits :: [a] -> [[a]] > > inits xs = [take n xs | n <- seglengths] > > where > > seglengths = [0..length xs] Better define it recursively. inits [] = [[]] inits (x:xs) = []:map (x:) (inits xs) > > Thanks. From gue.schmidt at web.de Sat Mar 7 17:58:28 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Sat Mar 7 17:47:08 2009 Subject: [Haskell-cafe] Purely Functional Data Structures Message-ID: Hi, is the above mentioned book still *the* authority on the subject? I bought the book, read about 10 pages and then put it back on the shelf. Um. In my app I have to deal with 4 csv files, each between 5 - 10 mb, and some static data. I had put all that data into an Sqlite3 database and used SQL on it. But, as the requirements keep changing the SQL becomes a bit messy. I guess we've all had that experience. So I'm wondering if I will find clues in this book how to do my querying and handling of moderately large data in a more haskellish way and be able to drop the SQL. Your suggestions appreciated. G?nther From dons at galois.com Sat Mar 7 17:59:45 2009 From: dons at galois.com (Don Stewart) Date: Sat Mar 7 17:49:05 2009 Subject: [Haskell-cafe] Purely Functional Data Structures In-Reply-To: References: Message-ID: <20090307225945.GM19807@whirlpool.galois.com> gue.schmidt: > Hi, > > is the above mentioned book still *the* authority on the subject? > > I bought the book, read about 10 pages and then put it back on the > shelf. Um. > In my app I have to deal with 4 csv files, each between 5 - 10 mb, and > some static data. > > I had put all that data into an Sqlite3 database and used SQL on it. > But, as the requirements keep changing the SQL becomes a bit messy. I > guess we've all had that experience. > > So I'm wondering if I will find clues in this book how to do my querying > and handling of moderately large data in a more haskellish way and be > able to drop the SQL. Use the fine libraries on http://hackage.haskell.org. E.g. bytestring-csv then load that into a finite map? These days it is rare to have to roll your own new data structures... -- don From redcom at fedoms.com Sat Mar 7 18:13:14 2009 From: redcom at fedoms.com (=?windows-1252?Q?G=3Fuenther_Schmidt?=) Date: Sat Mar 7 18:01:40 2009 Subject: [Haskell-cafe] Purely Functional Data Structures In-Reply-To: <20090307225945.GM19807@whirlpool.galois.com> References: <20090307225945.GM19807@whirlpool.galois.com> Message-ID: <49B2FF8A.50501@fedoms.com> Hi Don, damn, that was quick! And thx, I'll look into that. The reading it in wasn't much of a problem, I had been able to use MS-ODBC for that, there's a driver for ODBC files. The problem is more the type of data structure I'd be reading it into. In SQL I would have the data indexed by several different columns, if I use maps I'd only have one key, so if I need to lookup data in the map by a value that is not the key the lookups will become quite expensive. Any suggestions, what do you do in these cases? G?nther Don Stewart schrieb: > gue.schmidt: > >> Hi, >> >> is the above mentioned book still *the* authority on the subject? >> >> I bought the book, read about 10 pages and then put it back on the >> shelf. Um. >> In my app I have to deal with 4 csv files, each between 5 - 10 mb, and >> some static data. >> >> I had put all that data into an Sqlite3 database and used SQL on it. >> But, as the requirements keep changing the SQL becomes a bit messy. I >> guess we've all had that experience. >> >> So I'm wondering if I will find clues in this book how to do my querying >> and handling of moderately large data in a more haskellish way and be >> able to drop the SQL. >> > > Use the fine libraries on http://hackage.haskell.org. > > E.g. bytestring-csv then load that into a finite map? > > These days it is rare to have to roll your own new data structures... > > -- don > From trentbuck at gmail.com Sat Mar 7 18:21:39 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Sat Mar 7 18:08:36 2009 Subject: [Haskell-cafe] Re: a newbies confusion with repositories - darcs or git References: <20090301104046.GB32441@Macintosh.local> <20090307193201.GC12985@Macintosh.local> Message-ID: <30r618x6kc.fsf@Clio.twb.ath.cx> Eric Kow writes: > One of the darcs team members, Thorkil Naur, felt that in my enthusiasm I > was not being sufficiently forthright about darcs's shortcomings. As for me, I tend to start any review with a list of all the problems I have with , on the basis that it's a lot harder to find informed criticism of a technology than it is to find praise (informed or otherwise). So I would write an article "Why you shouldn't choose Darcs", and let readers decide whether the arguments are inadequate. From byorgey at seas.upenn.edu Sat Mar 7 18:20:26 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Mar 7 18:08:54 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 108 - March 7, 2009 Message-ID: <20090307232026.GA9160@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090307 Issue 108 - March 07, 2009 --------------------------------------------------------------------------- Welcome to issue 108 of HWN, a newsletter covering developments in the [1]Haskell community. The ICFP programming contest will be held from 26-29th June! It's not too early to start thinking about putting a team together. Announcements tar 0.3.0.0. Duncan Coutts [2]announceda major new release of the [3]tar package for handling ".tar" archive files. This release has a completely new and much improved API. storable 0.1 -- Storable type class for variable-sized data. Tom?? Janou?ek [4]announced the first release of the [5]storable library, which fills the gap between Foreign.Storable and Data.Binary by adding support for marshalling (finite) values of variable-sized data types, like lists or trees, while preserving the performance and memory efficiency one expects from the Storable class. It also provides a (monadic) syntactic sugar that takes care of alignment restrictions by itself and makes instance deriving easy. CFP: Submit a talk proposal to CUFP. Kathleen Fisher [6]requested talk proposals for [7]CUFP. The Industrial Haskell Group. Duncan Coutts [8]announced the creation of the [9]Industrial Haskell Group (IHG). The IHG is an organisation to support the needs of commercial users of the Haskell programming language. Currently, the main activity of the IHG is a collaborative development scheme, in which multiple companies fund work on the Haskell development platform to their mutual benefit. The scheme has started with three partners of the IHG, including Galois and Amgen. pandoc 1.2. John MacFarlane [10]announced the release of [11]pandoc version 1.2. The most significant new feature is support for literate Haskell; you can now use pandoc directly on literate Haskell source files to produce syntax-highlighted HTML output. A Haskell binding for the Augeas API. Jude [12]announced a [13]Haskell FFI binding for the Augeas configuration editing API. Haskell Logo Voting will start soon!. Eelco Lempsink [14]announced that [15]voting for the new Haskell logo will begin on March 16! Everyone subscribed to haskell-cafe will receive a ballot; if you are not subscribed but would like to vote, email Eelco with the subject "haskell logo voting ballot request" and include a short, unique message. Happstack 0.2 Released. Matthew Elder [16]announced the [17]release of [18]Happstack 0.2. Extensible and Modular Generics for the Masses: emgm-0.3. Sean Leather [19]announced the third major release of [20]Extensible and Modular Generics for the Masses (EMGM), a library for generic programming in Haskell using type classes and a sum-of-products view. Deriving is now greatly improved, and there are several new functions, including case, everywhere, and everywhere'. major speed improvement: regex-tdfa reaches 1.0.0. ChrisK proudly [21]announced the version 1.0.0 release of [22]regex-tdfa. This is is not just a bug fix release; it is a serious improvement in the asymptotic running time of the library algorithms. Discussion Definitions of purity and Lazy IO. Oleg began a [23]discussion on lazy IO. Left fold enumerator - a real pearl overlooked?. G?nther Schmidt began a [24]discussion of left-fold enumerators and their current status within the community. Jobs Looking for a co-founder for a startup using Haskell. Ed McCaffrey [25]is looking for a co-founder to work on a startup music project in Haskell. Email Ed for more information. Fully-funded doctoral studentships in dependently type programming at Oxford and Strathclyde. Jeremy Gibbons [26]announced two fully-funded doctoral student positions in dependently-typed programming at [27]Oxford and [28]Strathclyde. Blog noise [29]Haskell news from the [30]blogosphere. * Holumbus: [31]First release of Holumbus-MapReduce. * FP Lunch: [32]Breadth first labelling. * Sean Leather: [33]Experiments with EMGM: Emacs org files. * Galois, Inc: [34]Call for Proposals: CUFP 2009. * Matthew Elder: [35]Happstack 0.2 Released. * Yi: [36]Lazy and Incremental Parsing: the paper. * Xmonad: [37]xmonad as a multi-head sliding block puzzle. * Don Stewart (dons): [38]Playing with GHC's parallel runtime. * Bjorn Buckwalter: [39]Extended sessions with the Haskell Curl bindings. * Manuel M T Chakravarty: [40]Installing GtK2Hs on a Mac with the native GTK+ OS X Framework.. * Alex Mason: [41]If you need speed, don't talk to main!. * Luke Palmer: [42]New game: SpaceBattle. * Galois, Inc: [43]Galois Tech Talk: Specializing Generators for High-Performance Monte-Carlo Simulation in Haskell. * Bjorn Buckwalter: [44]Programmer Man. * Conrad Parker: [45]Random code: Pretty printing durations in Haskell. * The GHC Team: [46]New paper: Runtime Support for Multicore Haskell. * ganesh: [47]London Haskell Users Group. * Manuel M T Chakravarty: [48]This is the performance of a dot product of two vectors of 10.... * Sean Leather: [49]Template Haskell 2.3 or Cabal 1.2? EMGM can't have both!. * Tom Schrijvers: [50]Complete and Decidable Type Inference for GADTs. * Galois, Inc: [51]Trustworthy Voting Systems. * Well-Typed.Com: [52]The Industrial Haskell Group. * Sean Leather: [53]Incremental fold, a design pattern. * Darcs: [54]darcs weekly news #19. * FP Lunch: [55]Container eating. About the Haskell Weekly News New editions are posted to [56]the Haskell mailing list as well as to [57]the Haskell Sequence and [58]Planet Haskell. [59]RSS is also available, and headlines appear on [60]haskell.org. To help create new editions of this newsletter, please see the information on [61]how to contribute. Send stories to byorgey at cis 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://www.haskell.org//pipermail/haskell-cafe/2009-March/056870.html 3. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/tar 4. http://article.gmane.org/gmane.comp.lang.haskell.general/16934 5. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/storable 6. http://article.gmane.org/gmane.comp.lang.haskell.general/16904 7. http://cufp.galois.com/2009/call.html 8. http://article.gmane.org/gmane.comp.lang.haskell.general/16903 9. http://industry.haskell.org/ 10. http://article.gmane.org/gmane.comp.lang.haskell.general/16899 11. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc 12. http://article.gmane.org/gmane.comp.lang.haskell.general/16897 13. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/augeas 14. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54201 15. http://community.haskell.org/~eelco/poll.html 16. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54144 17. http://blog.happstack.com/2009/03/04/happstack-02-released 18. http://blog.happstack.com/2009/03/04/happstack-02-released 19. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54035 20. http://www.cs.uu.nl/wiki/GenericProgramming/EMGM 21. http://article.gmane.org/gmane.comp.lang.haskell.cafe/53943 22. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex%2Dtdfa 23. http://thread.gmane.org/gmane.comp.lang.haskell.general/16914 24. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/53873 25. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54246 26. http://article.gmane.org/gmane.comp.lang.haskell.general/16927 27. http://web.comlab.ox.ac.uk/news/72-full.html 28. http://personal.cis.strath.ac.uk/~conor/phds/ 29. http://planet.haskell.org/ 30. http://haskell.org/haskellwiki/Blog_articles 31. http://holumbus.fh-wedel.de/blog/?p=17 32. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=205 33. http://feedproxy.google.com/~r/splonderzoek/~3/6bxI33NIRMc/experiments-with-emgm-emacs-org-files.html 34. http://www.galois.com/blog/2009/03/05/call-for-proposals-cufp-2009/ 35. http://blog.happstack.com/2009/03/04/happstack-02-released/ 36. http://yi-editor.blogspot.com/2009/03/lazy-and-incremental-parsing-paper.html 37. http://xmonad.wordpress.com/2009/03/04/xmonad-as-a-multi-head-sliding-block-puzzle/ 38. http://donsbot.wordpress.com/2009/03/04/playing-with-ghcs-parallel-runtime/ 39. http://flygdynamikern.blogspot.com/2009/03/extended-sessions-with-haskell-curl.html 40. http://justtesting.org/post/83333955 41. http://axman6.homeip.net/blog/2009/03/if-you-need-speed-dont-talk-to-main.html 42. http://lukepalmer.wordpress.com/2009/03/04/new-game-spacebattle/ 43. http://www.galois.com/blog/2009/03/03/galois-tech-talk-specializing-generators-for-high-performance-monte-carlo-simulation-in-haskell/ 44. http://flygdynamikern.blogspot.com/2009/02/programmer-man.html 45. http://blog.kfish.org/2009/03/random-code-pretty-printing-durations.html 46. http://ghcmutterings.wordpress.com/2009/03/03/new-paper-runtime-support-for-multicore-haskell/ 47. http://www.londonhug.net/2009/03/03/80/ 48. http://justtesting.org/post/83014052 49. http://feedproxy.google.com/~r/splonderzoek/~3/WqqB1QrNZ_4/template-haskell-23-or-cabal-12-emgm.html 50. http://tomschrijvers.blogspot.com/2009/03/complete-and-decidable-type-inferennce.html 51. http://www.galois.com/blog/2009/03/02/trustworthy-voting-systems/ 52. http://blog.well-typed.com/2009/03/the-industrial-haskell-group/ 53. http://feedproxy.google.com/~r/splonderzoek/~3/tj_MkKqIlkQ/incremental-fold-design-pattern.html 54. http://blog.darcs.net/2009/03/darcs-weekly-news-19.html 55. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=201 56. http://www.haskell.org/mailman/listinfo/haskell 57. http://sequence.complete.org/ 58. http://planet.haskell.org/ 59. http://sequence.complete.org/node/feed 60. http://haskell.org/ 61. http://haskell.org/haskellwiki/HWN 62. http://code.haskell.org/~byorgey/code/hwn/ From loup.vaillant at gmail.com Sat Mar 7 18:32:48 2009 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Sat Mar 7 18:21:15 2009 Subject: [Haskell-cafe] I want to write a compiler Message-ID: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> This is a homework question. I am mainly looking for guidance or pointers. Source code, even. (Not GHC's, though, it is too complicated for me right now. The AST of STG is fine, but the rest kinda scares me.) Ideally, I would very much like to compile to C. The requirements are easily stated. My language must -> be lazy by default, -> support algebraic data types and case expressions (unless I can get away with encoding them as functions), -> have some kind of FFI with C (I suppose it imply some support for unboxed values). There is also the first class functions thing, but lambda lifting is okay. I don't care about any kind of execution efficiency. I just want my compiler to be As Simple As Possible. Eventually, I intend to bootstrap. Then, I will start dreaming about doing better than the Mighty Simons. (I can dream, right?) I figured I would start by the back-end. I began to write 15 pathetic lines of code to start an STG machine. Needles to say, I am stuck. I don't know where to start. I am already familiar with some papers. In particular, [1] (on template instantiation), [2] and [3]. I once wrote a simple graph reducer using template instantiation (about 20 lines at most). I have chosen the STG machine because I thought i would be easier to get an FFI and case exprs out of it. Maybe I am wrong, and template instantiation is really easier. There is also the BRISK machine, and GRIN. But the paper I read were less readable to me than the three mentioned. So, If any of you can give me some pointer or guidance or advice about where to start, I would be very grateful. Loup [1] http://www.cs.otago.ac.nz/cosc459/books/pjlester.pdf [2] http://research.microsoft.com/~simonpj/Papers/spineless-tagless-gmachine.ps.gz [3] http://research.microsoft.com/~simonpj/Papers/eval-apply/index.htm From rick.richardson at gmail.com Sat Mar 7 18:45:04 2009 From: rick.richardson at gmail.com (Rick R) Date: Sat Mar 7 18:33:31 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> Message-ID: <9810b81b0903071545j7e5331aat4732b1a1a9a57f9b@mail.gmail.com> http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours Not sure if this is exactly what you want, but you could certainly fufill all of your requirements using this as a baseline. Instead of evaluating the actual statements in your eval function, you could simply render them to C. As far as FFI, if you are statically compiling to C, you can leave your variables unboxed. This would allow you to call C functions directly. Hope that helps. On Sat, Mar 7, 2009 at 6:32 PM, Loup Vaillant wrote: > This is a homework question. I am mainly looking for guidance or > pointers. Source code, even. (Not GHC's, though, it is too complicated > for me right now. The AST of STG is fine, but the rest kinda scares > me.) > > Ideally, I would very much like to compile to C. > > The requirements are easily stated. My language must > -> be lazy by default, > -> support algebraic data types and case expressions (unless I can get > away with encoding them as functions), > -> have some kind of FFI with C (I suppose it imply some support for > unboxed values). > > There is also the first class functions thing, but lambda lifting is okay. > > I don't care about any kind of execution efficiency. I just want my > compiler to be As Simple As Possible. Eventually, I intend to > bootstrap. Then, I will start dreaming about doing better than the > Mighty Simons. (I can dream, right?) > > I figured I would start by the back-end. I began to write 15 pathetic > lines of code to start an STG machine. Needles to say, I am stuck. I > don't know where to start. > > I am already familiar with some papers. In particular, [1] (on > template instantiation), [2] and [3]. I once wrote a simple graph > reducer using template instantiation (about 20 lines at most). > > I have chosen the STG machine because I thought i would be easier to > get an FFI and case exprs out of it. Maybe I am wrong, and template > instantiation is really easier. There is also the BRISK machine, and > GRIN. But the paper I read were less readable to me than the three > mentioned. > > So, If any of you can give me some pointer or guidance or advice about > where to start, I would be very grateful. > > Loup > > > [1] http://www.cs.otago.ac.nz/cosc459/books/pjlester.pdf > [2] > http://research.microsoft.com/~simonpj/Papers/spineless-tagless-gmachine.ps.gz > [3] http://research.microsoft.com/~simonpj/Papers/eval-apply/index.htm > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- We can't solve problems by using the same kind of thinking we used when we created them. - A. Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090307/e18026ee/attachment.htm From barsoap at web.de Sat Mar 7 18:58:31 2009 From: barsoap at web.de (Achim Schneider) Date: Sat Mar 7 18:47:15 2009 Subject: [Haskell-cafe] Re: I want to write a compiler References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> <9810b81b0903071545j7e5331aat4732b1a1a9a57f9b@mail.gmail.com> Message-ID: <20090308005831.1c95cb50@solaris> Rick R wrote: > http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours > Or go for the Real Thing: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-35.html#%_sec_5.5 (although starting to read the Wizard book with the last section might not be the most easiest thing in the world) -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From jeremy at n-heptane.com Sat Mar 7 20:04:20 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sat Mar 7 19:52:48 2009 Subject: [Haskell-cafe] Purely Functional Data Structures In-Reply-To: <49B2FF8A.50501@fedoms.com> References: <20090307225945.GM19807@whirlpool.galois.com> <49B2FF8A.50501@fedoms.com> Message-ID: <87hc24u8oa.wl%jeremy@n-heptane.com> At Sun, 08 Mar 2009 00:13:14 +0100, G?uenther Schmidt wrote: > In SQL I would have the data indexed by several > different columns, if I use maps I'd only have one key, so if I need to > lookup data in the map by a value that is not the key the lookups will > become quite expensive. happstack-ixset offers a data-type similar to Map except that you can have multiple keys. You can even have keys that are calculated from the data but don't actually appear in the data itself. For, example, if your ixset just contains Strings, one of the keys could be the length of the String. happstack-ixset (and its dependencies) also offers compact serialization/deserialization of the ixset to disk, data migration options, and a smattering of other features that may or may not be useful to you. While happstack-ixset is built to work with happstack, it is does not depend on the happstack http server or persistent store layer, so it should be useful even if you are not being an application server. - jeremy From jeremy at n-heptane.com Sat Mar 7 20:20:54 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sat Mar 7 20:09:41 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> Message-ID: <87fxhou7wp.wl%jeremy@n-heptane.com> Hello, This book is pretty good IMO: http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ It does not cover STG, but it does cover a ton of useful stuff and is very well written. I can say from experience that the spineless-tagless-gmachine paper you referenced does contain all the information needed to implement an STG->C compiler. But, you should expect to spend a lot of time alternating between trying to implement the thing and rereading the paper. Also, you may find that it is easier to do STG->Assembly at first (via harpy or something). With assembly it is easier to express exactly what you want to happen. With C you have to try to figure out how to trick the C compiler into doing your bidding. Also, maybe it is more satisfying to output assembly, because then you really feel like you are writing a compiler ;) I am sure others will say that LLVM is a better option than C or assembly. I know almost nothing about LLVM, so they may be right. -- jeremy At Sun, 8 Mar 2009 01:32:48 +0200, Loup Vaillant wrote: > > This is a homework question. I am mainly looking for guidance or > pointers. Source code, even. (Not GHC's, though, it is too complicated > for me right now. The AST of STG is fine, but the rest kinda scares > me.) > > Ideally, I would very much like to compile to C. > > The requirements are easily stated. My language must > -> be lazy by default, > -> support algebraic data types and case expressions (unless I can get > away with encoding them as functions), > -> have some kind of FFI with C (I suppose it imply some support for > unboxed values). > > There is also the first class functions thing, but lambda lifting is okay. > > I don't care about any kind of execution efficiency. I just want my > compiler to be As Simple As Possible. Eventually, I intend to > bootstrap. Then, I will start dreaming about doing better than the > Mighty Simons. (I can dream, right?) > > I figured I would start by the back-end. I began to write 15 pathetic > lines of code to start an STG machine. Needles to say, I am stuck. I > don't know where to start. > > I am already familiar with some papers. In particular, [1] (on > template instantiation), [2] and [3]. I once wrote a simple graph > reducer using template instantiation (about 20 lines at most). > > I have chosen the STG machine because I thought i would be easier to > get an FFI and case exprs out of it. Maybe I am wrong, and template > instantiation is really easier. There is also the BRISK machine, and > GRIN. But the paper I read were less readable to me than the three > mentioned. > > So, If any of you can give me some pointer or guidance or advice about > where to start, I would be very grateful. > > Loup > > > [1] http://www.cs.otago.ac.nz/cosc459/books/pjlester.pdf > [2] http://research.microsoft.com/~simonpj/Papers/spineless-tagless-gmachine.ps.gz > [3] http://research.microsoft.com/~simonpj/Papers/eval-apply/index.htm > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From redcom at fedoms.com Sat Mar 7 20:28:43 2009 From: redcom at fedoms.com (=?windows-1252?Q?G=3Fuenther_Schmidt?=) Date: Sat Mar 7 20:17:11 2009 Subject: [Haskell-cafe] Purely Functional Data Structures In-Reply-To: <87hc24u8oa.wl%jeremy@n-heptane.com> References: <20090307225945.GM19807@whirlpool.galois.com> <49B2FF8A.50501@fedoms.com> <87hc24u8oa.wl%jeremy@n-heptane.com> Message-ID: <49B31F4B.3050105@fedoms.com> Hi Jeremy, I had used HAppS-IxSet before and was very happy with it, it offered pretty much everything I needed. I switched (back) to SQL once I had hit a bump in the road that I wasn't able to fix, a stack-overflow that occurred once I ran the code against the largest sample data I had. It occurred because I could not make the inserts into the set strict. However since then my haskell skills have improved somewhat and right now I'm giving it another go. At that time it seemed that not many people were using IxSet so no-one was really able to help me with it. I'm glad that even though the original project is discontinued someone else took up the torch. G?nther Jeremy Shaw schrieb: > At Sun, 08 Mar 2009 00:13:14 +0100, > G?uenther Schmidt wrote: > >> In SQL I would have the data indexed by several >> different columns, if I use maps I'd only have one key, so if I need to >> lookup data in the map by a value that is not the key the lookups will >> become quite expensive. >> > > happstack-ixset offers a data-type similar to Map except that you can > have multiple keys. You can even have keys that are calculated from > the data but don't actually appear in the data itself. For, example, > if your ixset just contains Strings, one of the keys could be the > length of the String. > > happstack-ixset (and its dependencies) also offers compact > serialization/deserialization of the ixset to disk, data migration > options, and a smattering of other features that may or may not be > useful to you. > > While happstack-ixset is built to work with happstack, it is does not > depend on the happstack http server or persistent store layer, so it > should be useful even if you are not being an application server. > > - jeremy > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090308/adfb10b8/attachment.htm From mad.one at gmail.com Sat Mar 7 20:45:06 2009 From: mad.one at gmail.com (Austin Seipp) Date: Sat Mar 7 20:33:34 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> Message-ID: <1236473265-sup-9021@existential.local> Hi, (Please note this is coming from my own experience working with the LHC haskell compiler, as well as a compiler I'm currently working on in SML. I'm not an authority, but as another greenhorn compiler hacker I thought I might give some advice.) Excerpts from Loup Vaillant's message of Sat Mar 07 17:32:48 -0600 2009: > Ideally, I would very much like to compile to C. > > The requirements are easily stated. My language must > -> be lazy by default, > -> support algebraic data types and case expressions (unless I can get > away with encoding them as functions), > -> have some kind of FFI with C (I suppose it imply some support for > unboxed values). > > There is also the first class functions thing, but lambda lifting is okay. Unfortunately, after working on LHC, I can verifiably say (like all the researchers who wrote the papers which I *didn't* read beforehand,) that for a lot of purposes, C is an unsuitable fit for a compilers' target language. It works pretty well if you can make the source language execution model fit well enough, but if you can't, you've a price to pay (both in sanity and/or performance.) (On that note, I am currently of the opinion that most of LHC's major deficiencies, aside from a few parser bugs or some needed optimizations, comes from the fact that compiling to C is currently our only option; because of it, we have no exception handling or proper garbage collection at all. As well, the runtime system is a little needlessly 'clever' (if small and understandable) so it can deal with that.) However, since your goal is *not* efficiency, you will be happy to know that the issues with compiling to C (like garbage collection and exception handling) can be worked around viably. For garbage collection, please see. "Accurate Garbage Collection in an Uncooperative Environment" - http://citeseer.ist.psu.edu/538613.html This strategy is currently used in Mercury as well as Ben L.'s DDC language; on that note, I think if you spent some time looking through the runtime/generated code of DDC, you can see exactly what the paper is talking about, because it's actually a very simple strategy for holding onto GC roots: http://code.haskell.org/ddc/ddc-head/runtime/ However, it's reasons like this (C is really hard to compile to effectively) that Simon & co. have spent so much time on the C-- project. C-- is one of the backend languages used in GHC, and it is designed to be a 'uniform assembly language' for high level languages to compile to. You can find a lot of info on C-- here; I recommend the paper at the bottom to start off: http://research.microsoft.com/en-us/um/people/simonpj/papers/c--/ These papers should further illustrate the issues with compiling to C; for a pedagogical excursion, these issues can all be (simply) worked around for the most part like Henderson's paper illustrates, but they're worth keeping in mind, too. Hopefully those papers should help you concerning your compilation model and the route you would like to take. I can't say much about laziness, other than read Simon Peyton-Jones' actual full book (it's an amazing read): http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ That should help you concerning laziness/compilation etc.. As for the FFI, I don't really have any papers on 'how to implement an FFI', but Matthias Blume's paper might be of interest: "No-Longer-Foreign: Teaching an ML compiler to speak c "natively"" http://ttic.uchicago.edu/~blume/papers/nlffi-entcs.pdf libffi may also be worth investigating: http://sourceware.org/libffi/ > I have chosen the STG machine because I thought i would be easier to > get an FFI and case exprs out of it. Maybe I am wrong, and template > instantiation is really easier. There is also the BRISK machine, and > GRIN. But the paper I read were less readable to me than the three > mentioned. How far into GRIN have you looked? It is one of the intermediate languages for lhc/jhc, and for a low-level intermediate representation it works quite well I think; it is a strict, monadic intermediate language - being strict, we must still be able to model closures ('suspendeded applications' or thunks,) so we model closures/partial applications in a sort of 'defunctionalized' way (making grin a sort of 'defunctionalized intermediate language' really,) by turning them into something along the lines of an algebraic data type in GRIN. A good benefit of this is that you actually /don't/ have to write eval/apply yourself, because the compiler is supposed to generate it *for* you. In fact, this is a core part of GRIN - the generation of eval by the compiler is critical for many important optimizations to take place. It also makes the runtime a bit simpler. This comes at the price that GRIN is by design a whole-program intermediate form; in order to pull off any of these sophisticated transformations everything must be in memory at once. But as we have seen with LHC/JHC, it can make a *huge* difference (apps that are 10x smaller *and* 10x faster than ones created by GHC.) Having dealt with GRIN as I work on LHC (when time now permits...) I can say that it's a reasonable strategy and in practice it turns out pretty well, but if you're not into optimizing the code, then STG might be a better fit. I can't really give you that much advice on this area so much as you'll just have to choose. But GRIN does have at least two excellent references: Code Optimisation Techniques for Lazy Functional Languages - U. Boquist, http://www.cs.chalmers.se/~boquist/phd/index.html The GRIN Project: A Highly Optimising Back End For Lazy Functional Languages, U. Boquist, http://www.cs.chalmers.se/~boquist/ifl96-abstract.html Then again you said you're not interested in optimization, so perhaps I'm just preaching to the totally wrong choir... :) Austin From kyagrd at gmail.com Sat Mar 7 20:51:56 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Sat Mar 7 20:40:41 2009 Subject: [Haskell-cafe] cabal-install 0.6.2 does not bootstrap with ghc-6.10.1 debian distribution Message-ID: Dear Haskellers and especially who are working on cabal-install and debian packaging, I sometimes clean up .ghc and .cabal in my home directory to start from scratch because of dependency loopholes (cabal-install does not have remove option yet, so it's hard to fix when such loophole happens). Today, I had some time in the airport and decided to start from scratch again because of the dependency loophole with process 1.0.1.1 and haddock. I downloaded the most recent version of cabal-install the version 0.6.2, and found out that the ./bootstrap.sh does not work. So, I had to bootstrap from version 0.6.2 and do "cabal update" and "cabal upgrade cabal-install" to upgrade to 0.6.2. I am not sure whether this is a cabal-install problem or debian dstribution ghc-6.10.1 packaging probelm, since I have not tried to test this with any other ghc-6.10.1 distribution. If anyone who are not using debian distribution ghc-6.10.1 (e.g., general linux binary ghc-6.10.1 or source compiled one) can try bootstrapping cabal-install 0.6.2 from scratch also finds the same problem, I think someone should make a ticket for cabal-install. Thanks, Ahn, Ki Yung From kyagrd at gmail.com Sat Mar 7 20:59:51 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Sat Mar 7 20:48:36 2009 Subject: [Haskell-cafe] Re: cabal-install 0.6.2 does not bootstrap with ghc-6.10.1 debian distribution In-Reply-To: References: Message-ID: Ahn, Ki Yung ? ?: > Dear Haskellers and especially who are working on cabal-install > and debian packaging, > > I sometimes clean up .ghc and .cabal in my home directory to start from > scratch because of dependency loopholes (cabal-install does not have > remove option yet, so it's hard to fix when such loophole happens). > > Today, I had some time in the airport and decided to start from scratch > again because of the dependency loophole with process 1.0.1.1 and > haddock. I downloaded the most recent version of cabal-install the > version 0.6.2, and found out that the ./bootstrap.sh does not work. So, > I had to bootstrap from version 0.6.2 and do "cabal update" and "cabal > upgrade cabal-install" to upgrade to 0.6.2. Sorry for my typo. What I meant was: I was able to bootstrapped from version 0.6.0 and then upgrade to 0.6.2. > I am not sure whether this is a cabal-install problem or debian > dstribution ghc-6.10.1 packaging probelm, since I have not tried to test > this with any other ghc-6.10.1 distribution. > > If anyone who are not using debian distribution ghc-6.10.1 (e.g., > general linux binary ghc-6.10.1 or source compiled one) can try > bootstrapping cabal-install 0.6.2 from scratch also finds the same > problem, I think someone should make a ticket for cabal-install. > > Thanks, > > Ahn, Ki Yung From jeremy at n-heptane.com Sat Mar 7 21:41:45 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sat Mar 7 21:30:12 2009 Subject: [Haskell-cafe] Purely Functional Data Structures In-Reply-To: <49B31F4B.3050105@fedoms.com> References: <20090307225945.GM19807@whirlpool.galois.com> <49B2FF8A.50501@fedoms.com> <87hc24u8oa.wl%jeremy@n-heptane.com> <49B31F4B.3050105@fedoms.com> Message-ID: <87eix8u45y.wl%jeremy@n-heptane.com> At Sun, 08 Mar 2009 02:28:43 +0100, G?uenther Schmidt wrote: > > [1 ] > Hi Jeremy, > > I had used HAppS-IxSet before and was very happy with it, it offered > pretty much everything I needed. I switched (back) to SQL once I had hit > a bump in the road that I wasn't able to fix, a stack-overflow that > occurred once I ran the code against the largest sample data I had. It > occurred because I could not make the inserts into the set strict. > > However since then my haskell skills have improved somewhat and right > now I'm giving it another go. If you still run into the issue, and it can be best solved by adding a strict version of insert (or something similar), definitely submit a patch. Now that the project is alive again, the patch should be accepted and applied in a matter of hours. -- jeremy From wren at freegeek.org Sat Mar 7 23:07:24 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Mar 7 22:55:51 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> Message-ID: <49B3447C.2050408@freegeek.org> Loup Vaillant wrote: > -> support algebraic data types and case expressions (unless I can get > away with encoding them as functions), Which you always can, data Foo = A a1...an | B b1...bn |... == type Foo :: forall r. (a1->...->an -> r) -> (b1->...->bn -> r) ->... -> r A a1...an = \fa _... -> fa a1...an B b1...bn = \_ fb... -> fb b1...bn ... The only trick is that you need to have closures (in order to build the Foos) and you need to have first-class functions (in order to pass the destructors in). If you're familiar with the STG machine, this is what they do under the covers anyways. At the core level, all you need is some primitive to force evaluation. (Church Encoding)++ -- Live well, ~wren From alexander.dunlap at gmail.com Sun Mar 8 01:23:01 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Mar 8 01:11:27 2009 Subject: [Haskell-cafe] bytestring vs. uvector Message-ID: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> Hi all, For a while now, we have had Data.ByteString[.Lazy][.Char8] for our fast strings. Now we also have Data.Text, which does the same for Unicode. These seem to be the standard for dealing with lists of bytes and characters. Now we also have the storablevector, uvector, and vector packages. These seem to be also useful for unpacked data, *including* Char and Word8 values. What is the difference between bytestring and these new "fast array" libraries? Are the latter just generalizations of the former? Thanks for any insight anyone can give on this. Alex From bos at serpentine.com Sun Mar 8 01:45:03 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Sun Mar 8 01:33:29 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> Message-ID: On Sat, Mar 7, 2009 at 10:23 PM, Alexander Dunlap < alexander.dunlap@gmail.com> wrote: > Hi all, > > For a while now, we have had Data.ByteString[.Lazy][.Char8] for our > fast strings. Now we also have Data.Text, which does the same for > Unicode. These seem to be the standard for dealing with lists of bytes > and characters. > > Now we also have the storablevector, uvector, and vector packages. > These seem to be also useful for unpacked data, *including* Char and > Word8 values. > > What is the difference between bytestring and these new "fast array" > libraries? Are the latter just generalizations of the former? There are quite a few overlaps and differences among them. bytestring is mature and useful for low-level byte buffer manipulations, and also for efficient I/O. This is in part because it uses pinned pointers that can interoperate easily with foreign code. It used to have an early fusion rewriting framework, but that was abandoned. So it will not fuse multiple ByteString traversals into single loops. This library is widely used, and also somewhat abused for text I/O. storablevector is not mature (I'm not even sure if it's actually used) and is a derivative of an old version of the bytestring library, and so has similar characteristics for interacting with foreign code. It contains some old fusion code that is sketchy in nature and somewhat likely to be broken. I'm not sure I would recommend using this library. uvector is, if my memory serves me correctly, a fork of the vector library. It uses modern stream fusion, but is under active development and is a little scary. I'm a little unclear on the exact difference between uvector and vector. Both use arrays that are not pinned, so they can't be readily used with foreign code. If you want to use either library, understand that you're embarking on a bracing adventure. text is not mature, and is based on the same modern fusion framework as uvector and vector. It uses unpinned arrays, but provides functions for dealing with foreign code. It uses a denser encoding than uvector for text, and provides text-oriented functions like splitting on word and line boundaries. Although it's intended for use with Unicode text, it does not yet provide proper Unicode-aware functions for things like case conversion. It interacts with bytestring to perform conversion to and from standard representations like UTF-8, and (via the text-icu package) ICU for others (SJIS, KOI-8, etc). If you want to use this library, understand that you're embarking on a bracing adventure. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090307/ddc1e677/attachment.htm From mad.one at gmail.com Sun Mar 8 03:20:09 2009 From: mad.one at gmail.com (Austin Seipp) Date: Sun Mar 8 03:08:41 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> Message-ID: <1236493528-sup-3575@existential.local> Excerpts from Alexander Dunlap's message of Sun Mar 08 00:23:01 -0600 2009: > For a while now, we have had Data.ByteString[.Lazy][.Char8] for our > fast strings. Now we also have Data.Text, which does the same for > Unicode. These seem to be the standard for dealing with lists of bytes > and characters. > > Now we also have the storablevector, uvector, and vector packages. > These seem to be also useful for unpacked data, *including* Char and > Word8 values. > > What is the difference between bytestring and these new "fast array" > libraries? Are the latter just generalizations of the former? > > Thanks for any insight anyone can give on this. > > Alex Data.Text provides functions for unicode over bytestrings, with several encoding/decoding methods. So, I think that bytestring+text now solves the general problem with the slow String type - we get various international encodings, and fast, efficient packed strings. (It's also worth mentioning utf8-string, which gives you utf8 over bytestrings. text gives you more encodings and is probably still quite efficient, however.) But this is pretty much a separate effort to that of packages like uvector/vector etc. etc.. To clarify, uvector and vector are likely to be merged in the future I think - vector is based on the idea of 'recycling arrays' so that array operations are still very efficient, while uvector only has the tested stream fusion technique behind it. Actually, I think the inevitable plan is to merge the technology behind both vector and uvector into the Data Parallel Haskell project. Array recylcing and stream fusion goes into creating extremely efficient sequential code, while the vectorisation pass turns that into efficient multicore code at the same time. In any case, I suppose that hypothetically if someone wanted to use a package like uvector to create an efficient string type, they could, but if they want that, why not just use bytestring? It's already optimized, battle tested and in extremely wide use. I think some library proliferation is good; in this case, the libraries mentioned here are really for some different purposes, and that's great, because they all lead to some nice, fast code with low conceptual overhead when put together (hopefully...) But I'm not even going to begin examining/comparing the different array interfaces or anything, because that's been done many times here, so you best check the archives if you want the 'in-depth' on the matter. Austin From mad.one at gmail.com Sun Mar 8 03:27:23 2009 From: mad.one at gmail.com (Austin Seipp) Date: Sun Mar 8 03:15:51 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> Message-ID: <1236496965-sup-5525@existential.local> Excerpts from Bryan O'Sullivan's message of Sun Mar 08 00:45:03 -0600 2009: > uvector is, if my memory serves me correctly, a fork of the vector library. > It uses modern stream fusion, but is under active development and is a > little scary. I'm a little unclear on the exact difference between uvector > and vector. Both use arrays that are not pinned, so they can't be readily > used with foreign code. If you want to use either library, understand that > you're embarking on a bracing adventure. vector and uvector are roughly based on the same technology; uvector is - as far as I remember - a fork of some of the old DPH code which uses stream fusion which Don cleaned up and worked on (and it's proven pretty useful, and people are still hacking on it.) vector however, has the notion of 'recycling arrays' when it does array operations. The technique is in fact quite similar to stream fusion. Roman L. built this from scratch I think, so it's quite a bit more unused and less stable than even uvector is maybe, but I suppose you could say it's kind of a superset of uvector. Hopefully though it should mature a little, and the plans are to have the technology from both of these folded into the Data Parallel Haskell project so we get fast array operations+automatic parallelisation. For info, see Roman's paper, 'Recycle your arrays!' http://www.cse.unsw.edu.au/~rl/publications/recycling.html Austin From dons at galois.com Sun Mar 8 03:33:02 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 8 03:22:17 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> Message-ID: <20090308073302.GA22022@whirlpool.galois.com> bos: > On Sat, Mar 7, 2009 at 10:23 PM, Alexander Dunlap > wrote: > > Hi all, > > For a while now, we have had Data.ByteString[.Lazy][.Char8] for our > fast strings. Now we also have Data.Text, which does the same for > Unicode. These seem to be the standard for dealing with lists of bytes > and characters. > > Now we also have the storablevector, uvector, and vector packages. > These seem to be also useful for unpacked data, *including* Char and > Word8 values. > > What is the difference between bytestring and these new "fast array" > libraries? Are the latter just generalizations of the former? > > > There are quite a few overlaps and differences among them. > > bytestring is mature and useful for low-level byte buffer manipulations, and > also for efficient I/O. This is in part because it uses pinned pointers that > can interoperate easily with foreign code. It used to have an early fusion > rewriting framework, but that was abandoned. So it will not fuse multiple > ByteString traversals into single loops. This library is widely used, and also > somewhat abused for text I/O. > > storablevector is not mature (I'm not even sure if it's actually used) and is a > derivative of an old version of the bytestring library, and so has similar > characteristics for interacting with foreign code. It contains some old fusion > code that is sketchy in nature and somewhat likely to be broken. I'm not sure I > would recommend using this library. > > uvector is, if my memory serves me correctly, a fork of the vector library. It > uses modern stream fusion, but is under active development and is a little > scary. I'm a little unclear on the exact difference between uvector and vector. > Both use arrays that are not pinned, so they can't be readily used with foreign > code. If you want to use either library, understand that you're embarking on a > bracing adventure. > > text is not mature, and is based on the same modern fusion framework as uvector > and vector. It uses unpinned arrays, but provides functions for dealing with > foreign code. It uses a denser encoding than uvector for text, and provides > text-oriented functions like splitting on word and line boundaries. Although > it's intended for use with Unicode text, it does not yet provide proper > Unicode-aware functions for things like case conversion. It interacts with > bytestring to perform conversion to and from standard representations like > UTF-8, and (via the text-icu package) ICU for others (SJIS, KOI-8, etc). If you > want to use this library, understand that you're embarking on a bracing > adventure. I endorse this message. From ryani.spam at gmail.com Sun Mar 8 04:03:35 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun Mar 8 03:52:01 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <87fxhou7wp.wl%jeremy@n-heptane.com> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> <87fxhou7wp.wl%jeremy@n-heptane.com> Message-ID: <2f9b2d30903080003q10812a89sce4c091e37382023@mail.gmail.com> I really like this book: http://research.microsoft.com/en-us/um/people/simonpj/papers/pj-lester-book/ It walks you through building a compiler to a reasonable intermediate language, which you can then start with; it's is a much easier problem to convert that intermediate langauge to assembly, C, or LLVM. -- ryan On Sat, Mar 7, 2009 at 5:20 PM, Jeremy Shaw wrote: > Hello, > > This book is pretty good IMO: > > http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ > > It does not cover STG, but it does cover a ton of useful stuff and is > very well written. > > I can say from experience that the spineless-tagless-gmachine paper > you referenced does contain all the information needed to implement an > STG->C compiler. But, you should expect to spend a lot of time > alternating between trying to implement the thing and rereading the > paper. > > Also, you may find that it is easier to do STG->Assembly at first (via > harpy or something). With assembly it is easier to express exactly > what you want to happen. With C you have to try to figure out how to > trick the C compiler into doing your bidding. > > Also, maybe it is more satisfying to output assembly, because then you > really feel like you are writing a compiler ;) > > I am sure others will say that LLVM is a better option than C or > assembly. I know almost nothing about LLVM, so they may be right. > > -- jeremy > > At Sun, 8 Mar 2009 01:32:48 +0200, > Loup Vaillant wrote: >> >> This is a homework question. I am mainly looking for guidance or >> pointers. Source code, even. (Not GHC's, though, it is too complicated >> for me right now. The AST of STG is fine, but the rest kinda scares >> me.) >> >> Ideally, I would very much like to compile to C. >> >> The requirements are easily stated. My language must >> -> be lazy by default, >> -> support algebraic data types and case expressions (unless I can get >> away with encoding them as functions), >> -> have some kind of FFI with C (I suppose it imply some support for >> unboxed values). >> >> There is also the first class functions thing, but lambda lifting is okay. >> >> I don't care about any kind of execution efficiency. I just want my >> compiler to be As Simple As Possible. Eventually, I intend to >> bootstrap. Then, I will start dreaming about doing better than the >> Mighty Simons. (I can dream, right?) >> >> I figured I would start by the back-end. I began to write 15 pathetic >> lines of code to start an STG machine. Needles to say, I am stuck. I >> don't know where to start. >> >> I am already familiar with some papers. In particular, [1] (on >> template instantiation), [2] and [3]. I once wrote a simple graph >> reducer using template instantiation (about 20 lines at most). >> >> I have chosen the STG machine because I thought i would be easier to >> get an FFI and case exprs out of it. Maybe I am wrong, and template >> instantiation is really easier. There is also the BRISK machine, and >> GRIN. But the paper I read were less readable to me than the three >> mentioned. >> >> So, If any of you can give me some pointer or guidance or advice about >> where to start, I would be very grateful. >> >> Loup >> >> >> [1] http://www.cs.otago.ac.nz/cosc459/books/pjlester.pdf >> [2] http://research.microsoft.com/~simonpj/Papers/spineless-tagless-gmachine.ps.gz >> [3] http://research.microsoft.com/~simonpj/Papers/eval-apply/index.htm >> _______________________________________________ >> 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 jno at di.uminho.pt Sun Mar 8 04:16:56 2009 From: jno at di.uminho.pt (J.N. Oliveira) Date: Sun Mar 8 04:05:05 2009 Subject: [Haskell-cafe] Naturality condition for inits In-Reply-To: References: Message-ID: <49B37EF8.5010409@di.uminho.pt> R J wrote: > Here's another Bird problem that's stymied me: > > The function "inits" computes the list of initial segments of a list; > its type is inits :: [a] -> [[a]]. What is the appropriate naturality > condition for "inits"? Just use the free theorem associated to type [a] -> [[a]] in Janis Voigtlaender?s free theorem generator http://linux.tcs.inf.tu-dresden.de/~voigt/ft and see the outcome when all permissible relation variables are functions (at the bottom of the screen). jno From Ben.Lippmeier at anu.edu.au Sun Mar 8 05:19:31 2009 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Sun Mar 8 05:08:01 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <1236473265-sup-9021@existential.local> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> <1236473265-sup-9021@existential.local> Message-ID: On 08/03/2009, at 12:45 PM, Austin Seipp wrote: > > For garbage collection, please see. > > "Accurate Garbage Collection in an Uncooperative Environment" - > http://citeseer.ist.psu.edu/538613.html > > This strategy is currently used in Mercury as well as Ben L.'s DDC > language; on that note, I think if you spent some time looking through > the runtime/generated code of DDC, you can see exactly what the paper > is talking about, because it's actually a very simple strategy for > holding onto GC roots: > > http://code.haskell.org/ddc/ddc-head/runtime/ That paper explains the basic idea, but neither DDC or Mercury quite follow it (I asked Zoltan). The system in the paper keeps the GC roots in structs on the C stack, and chains the structs together as a linked list. The problem is that if you take a pointer to data on the C stack then GCC freaks out and disables a host of optimisations. I imagine it's worried about pointers going bad after the stack frame is popped and the space for the struct gets lost. DDC keeps a shadow stack of GC roots in malloced memory. It's only a small difference, but lets the C compiler produce better code. Ben. From bugfact at gmail.com Sun Mar 8 07:00:23 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Mar 8 06:48:51 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics In-Reply-To: <20090307174925.GA8835@flit> References: <20090306213958.GA6963@flit> <20090307174925.GA8835@flit> Message-ID: On Sat, Mar 7, 2009 at 6:49 PM, Roman Cheplyaka wrote: > * Peter Verswyvelen [2009-03-07 18:34:10+0100] > > On Fri, Mar 6, 2009 at 10:39 PM, Roman Cheplyaka > wrote: > > > > Is it a performance issue? > > Yes. As Roman Leshchinskiy explained it's because parallel arrays are > not fused properly yet. > But it's quite trivial to modify Hpysics to use ordinary lists or > arrays, and I think it'll give reasonable performance. > Personally I would not mind too much about performance initially; I'm very confident that lots of optimizations can be done afterwards - maybe even letting the GPU handle certain tasks. > > > > > Integrating hpysics with Grapefruit might be a good topic for the > > > Hackaton, > > > > trying to make a simple game (e.g. Pong or Breakout) without using > > > recursive > > > > signal functions, but with correct collision response and > > > better-than-Euler > > > > integration, all handled by the physics engine. Other FRP engines > could > > > be > > > > tried, but Grapefruit hacking is already a topic on the Hackaton, so > it > > > > would combine efforts. > > > > > > Yes, I'm actively pondering Hpysics+Grapefruit (it's the primary reason > > > of my interest in Grapefruit). But first of all we need to get graphics > > > support into Grapefruit. > > > > > > Does your proposal re Hackathon indicate that you'd like to join? > > > > > > > Yes, Thomas 'Bob' Davie and I already joined the Hackaton, but the wiki > is > > not yet updated.I see you've joined too, cool > > Great! I'll have more free time after March 15, and we can arrange an > IRC meeting to discuss this. Sounds like a good idea! > > > -- > Roman I. Cheplyaka :: http://ro-che.info/ > "Don't let school get in the way of your education." - Mark Twain > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090308/065041a2/attachment.htm From manlio_perillo at libero.it Sun Mar 8 07:13:28 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 8 07:02:02 2009 Subject: [Haskell-cafe] Cabal and package changelog Message-ID: <49B3A858.8040503@libero.it> Hi. The Cabal package description includes a property `license-file`. This property may be used by Hackage to provide a link to the license file. However I would like to have a `changelog-file`, too. So that from Hackage I can quickly check what's changed with the new version of a package. Is this feasible? Thanks Manlio Perillo From roma at ro-che.info Sun Mar 8 07:14:00 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun Mar 8 07:02:56 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics In-Reply-To: References: <20090306213958.GA6963@flit> <20090307174925.GA8835@flit> Message-ID: <20090308111359.GA3137@flit> * Peter Verswyvelen [2009-03-08 12:00:23+0100] > On Sat, Mar 7, 2009 at 6:49 PM, Roman Cheplyaka wrote: > > > * Peter Verswyvelen [2009-03-07 18:34:10+0100] > > > On Fri, Mar 6, 2009 at 10:39 PM, Roman Cheplyaka > > wrote: > > > > > > Is it a performance issue? > > > > Yes. As Roman Leshchinskiy explained it's because parallel arrays are > > not fused properly yet. > > But it's quite trivial to modify Hpysics to use ordinary lists or > > arrays, and I think it'll give reasonable performance. > > > > Personally I would not mind too much about performance initially; I'm very > confident that lots of optimizations can be done afterwards - maybe even > letting the GPU handle certain tasks. I wouldn't mind too if it was just 'inefficient'; however, it's practically unusable. <> http://physics-dph.blogspot.com/2008/08/status-report-week-11-12.html -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From duncan.coutts at worc.ox.ac.uk Sun Mar 8 07:18:03 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 8 07:06:44 2009 Subject: [Haskell-cafe] cabal-install 0.6.2 does not bootstrap with ghc-6.10.1 debian distribution In-Reply-To: References: Message-ID: <1236511083.22402.286.camel@localhost> On Sat, 2009-03-07 at 17:51 -0800, Ahn, Ki Yung wrote: > Dear Haskellers and especially who are working on cabal-install > and debian packaging, > > I sometimes clean up .ghc and .cabal in my home directory to start from > scratch because of dependency loopholes (cabal-install does not have > remove option yet, so it's hard to fix when such loophole happens). > > Today, I had some time in the airport and decided to start from scratch > again because of the dependency loophole with process 1.0.1.1 and > haddock. I downloaded the most recent version of cabal-install the > version 0.6.2, and found out that the ./bootstrap.sh does not work. If you could provide any details on how it does not work that would be much appreciated. Eg a log of the output from running the bootstrap. Duncan From csaba.hruska at gmail.com Sun Mar 8 07:27:48 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Sun Mar 8 07:16:15 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics In-Reply-To: <20090308111359.GA3137@flit> References: <20090306213958.GA6963@flit> <20090307174925.GA8835@flit> <20090308111359.GA3137@flit> Message-ID: <8914b92d0903080427j5e9405a1pb8ddce185362d6a7@mail.gmail.com> Hi! This should be a bit offtopic, but now I'd like to announce that I'm working on a 3D rendering rengine in Haskell. I take ogre3d (www.ogre3d.org) as a base. My code can import import a subset of ogre model files (currently xml version) and material scripts (http://www.ogre3d.org/docs/manual/manual_14.html#SEC23). You can easily import an existing 3d content or create new one because there are ogre exporter plugins for every major modeler programs. Currently I have some working code. I hope I'll be ready to release it in a month. It should act as graphical backend for FRP libraries. I use yampa in the example program but it's just an option, only example program depends on it. Cheers, Csaba Hruska -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090308/0b7e8b48/attachment.htm From duncan.coutts at worc.ox.ac.uk Sun Mar 8 07:32:18 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 8 07:20:47 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> Message-ID: <1236511938.22402.297.camel@localhost> On Sat, 2009-03-07 at 17:30 +0000, Colin Paul Adams wrote: > >>>>> "Svein" == Svein Ove Aas writes: > > >> Preprocessing library game-tree-1.0.0.0... Building > >> game-tree-1.0.0.0... > >> > >> Data/Tree/Game/Negascout.hs:31:0: Unrecognised pragma [1 of 2] > >> Compiling Data.Tree.Game.Tree ( Data/Tree/Game/Tree.hs, > >> dist/build/Data/Tree/Game/Tree.o ) > >> > >> Data/Tree/Game/Tree.hs:1:0: Failed to load interface for > >> `Prelude': it is a member of package base-3.0.3.0, which > >> is hidden > >> > Svein> What does your .cabal file look like? Don, mkcabal is generating .cabal files that are confusing people. It should generate new-style .cabal files with library or executable sections. The ghc-options and build-depends etc need to be in the lib or exe section. The files it generates are not actually broken but it leaves new users to do the conversion from old style to new and unsurprisingly many get that wrong. Cabal is also at fault here for not providing good diagnostics but it would help if mkcabal used the current recommended style. Note also that the list of licenses mkcabal offers is wrong. You can get the list from the Cabal lib itself so there is no need to maintain the list manually. I still think mkcabal should be integrated into cabal-install, like: $ cabal init or something. We could also more easily keep it up to date that way. Duncan From bugfact at gmail.com Sun Mar 8 07:37:05 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Mar 8 07:25:30 2009 Subject: 3D Rendering Engine in Haskell (Re: [Haskell-cafe] FRP + physics / status of hpysics) Message-ID: Awesome! When you say you took Ogre as a base, do you mean your engine will be able to load the meshes and material files, or are you also wrapping the C++ code base? Did you also consider Collada? 2009/3/8 Csaba Hruska > Hi! > > This should be a bit offtopic, but now I'd like to announce that I'm > working on a 3D rendering rengine in Haskell. > I take ogre3d (www.ogre3d.org) as a base. My code can import import a > subset of ogre model files (currently xml version) and material scripts > (http://www.ogre3d.org/docs/manual/manual_14.html#SEC23). > You can easily import an existing 3d content or create new one because > there are ogre exporter plugins for every major modeler programs. > Currently I have some working code. I hope I'll be ready to release it in a > month. It should act as graphical backend for FRP libraries. > I use yampa in the example program but it's just an option, only example > program depends on it. > > Cheers, > Csaba Hruska > > _______________________________________________ > 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/20090308/a5ab1413/attachment.htm From csaba.hruska at gmail.com Sun Mar 8 07:40:42 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Sun Mar 8 07:29:08 2009 Subject: 3D Rendering Engine in Haskell (Re: [Haskell-cafe] FRP + physics / status of hpysics) In-Reply-To: References: Message-ID: <8914b92d0903080440rd582248v4ba68aa11a016008@mail.gmail.com> Of course I write everything in haskell! I mean about Ogre that i use only it's model and material formats and none of its code. Thats all. Yes, later I'd like to write a collada importer. :) 2009/3/8 Peter Verswyvelen > Awesome! > When you say you took Ogre as a base, do you mean your engine will be able > to load the meshes and material files, or are you also wrapping the C++ code > base? > > Did you also consider Collada? > > 2009/3/8 Csaba Hruska > >> Hi! >> >> This should be a bit offtopic, but now I'd like to announce that I'm >> working on a 3D rendering rengine in Haskell. >> I take ogre3d (www.ogre3d.org) as a base. My code can import import a >> subset of ogre model files (currently xml version) and material scripts >> (http://www.ogre3d.org/docs/manual/manual_14.html#SEC23). >> You can easily import an existing 3d content or create new one because >> there are ogre exporter plugins for every major modeler programs. >> Currently I have some working code. I hope I'll be ready to release it in >> a month. It should act as graphical backend for FRP libraries. >> I use yampa in the example program but it's just an option, only example >> program depends on it. >> >> Cheers, >> Csaba Hruska >> >> _______________________________________________ >> 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/20090308/3d9386a4/attachment.htm From jochem at functor.nl Sun Mar 8 07:46:22 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Sun Mar 8 07:34:51 2009 Subject: [Haskell-cafe] cabal-install 0.6.2 does not bootstrap with ghc-6.10.1 debian distribution In-Reply-To: References: Message-ID: <49B3B00E.4070206@functor.nl> Ahn, Ki Yung wrote: > If anyone who are not using debian distribution ghc-6.10.1 (e.g., > general linux binary ghc-6.10.1 or source compiled one) can try > bootstrapping cabal-install 0.6.2 from scratch also finds the same > problem, I think someone should make a ticket for cabal-install. I remember having to install zlib1g-dev using the package manager, aptitude install zlib1g-dev should suffice. If this was not the problem, please post the exact error message so we can figure out what's going wrong. Regards, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From bugfact at gmail.com Sun Mar 8 07:50:21 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Mar 8 07:38:49 2009 Subject: 3D Rendering Engine in Haskell (Re: [Haskell-cafe] FRP + physics / status of hpysics) In-Reply-To: <8914b92d0903080440rd582248v4ba68aa11a016008@mail.gmail.com> References: <8914b92d0903080440rd582248v4ba68aa11a016008@mail.gmail.com> Message-ID: > > Of course I write everything in haskell! I mean about Ogre that i use only > it's model and material formats and none of its code. Thats all. That's a big relief :-) Will it all be in the IO monad, or do you aim for a pure interface? > > Yes, later I'd like to write a collada importer. :) Super. If I find the time I could help with both projects since I've done a lot of OGRE hacking and wrote a small collada importer, albeit in C# > > > 2009/3/8 Peter Verswyvelen > > Awesome! >> When you say you took Ogre as a base, do you mean your engine will be able >> to load the meshes and material files, or are you also wrapping the C++ code >> base? >> >> Did you also consider Collada? >> >> 2009/3/8 Csaba Hruska >> >>> Hi! >>> >>> This should be a bit offtopic, but now I'd like to announce that I'm >>> working on a 3D rendering rengine in Haskell. >>> I take ogre3d (www.ogre3d.org) as a base. My code can import import a >>> subset of ogre model files (currently xml version) and material scripts >>> (http://www.ogre3d.org/docs/manual/manual_14.html#SEC23). >>> You can easily import an existing 3d content or create new one because >>> there are ogre exporter plugins for every major modeler programs. >>> Currently I have some working code. I hope I'll be ready to release it in >>> a month. It should act as graphical backend for FRP libraries. >>> I use yampa in the example program but it's just an option, only example >>> program depends on it. >>> >>> Cheers, >>> Csaba Hruska >>> >>> _______________________________________________ >>> 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/20090308/3a854360/attachment.htm From tomi at nomi.cz Sun Mar 8 07:50:20 2009 From: tomi at nomi.cz (=?iso-8859-2?Q?Tom=E1=B9_Janou=B9ek?=) Date: Sun Mar 8 07:41:49 2009 Subject: [Haskell-cafe] Re: cabal-install 0.6.2 does not bootstrap with ghc-6.10.1 debian distribution In-Reply-To: References: Message-ID: <20090308115020.GA20295@nomi.cz> Hello, On Sat, Mar 07, 2009 at 05:51:56PM -0800, Ahn, Ki Yung wrote: > I sometimes clean up .ghc and .cabal in my home directory to start from > scratch because of dependency loopholes (cabal-install does not have > remove option yet, so it's hard to fix when such loophole happens). You may use ghc-pkg hide or ghc-pkg unregister to solve these problems. -- Tom?? Janou?ek, a.k.a. Liskni_si, http://work.lisk.in/ From csaba.hruska at gmail.com Sun Mar 8 08:11:47 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Sun Mar 8 08:00:14 2009 Subject: 3D Rendering Engine in Haskell (Re: [Haskell-cafe] FRP + physics / status of hpysics) In-Reply-To: References: <8914b92d0903080440rd582248v4ba68aa11a016008@mail.gmail.com> Message-ID: <8914b92d0903080511m13cc0cd9paf6bd96b8732b31@mail.gmail.com> 2009/3/8 Peter Verswyvelen > Of course I write everything in haskell! I mean about Ogre that i use only >> it's model and material formats and none of its code. Thats all. > > > That's a big relief :-) Will it all be in the IO monad, or do you aim for a > pure interface? > I prefer pure interface. > >> Yes, later I'd like to write a collada importer. :) > > > Super. If I find the time I could help with both projects since I've done a > lot of OGRE hacking and wrote a small collada importer, albeit in C# > Cooperation would be great! > > > >> >> >> 2009/3/8 Peter Verswyvelen >> >> Awesome! >>> When you say you took Ogre as a base, do you mean your engine will be >>> able to load the meshes and material files, or are you also wrapping the C++ >>> code base? >>> >>> Did you also consider Collada? >>> >>> 2009/3/8 Csaba Hruska >>> >>>> Hi! >>>> >>>> This should be a bit offtopic, but now I'd like to announce that I'm >>>> working on a 3D rendering rengine in Haskell. >>>> I take ogre3d (www.ogre3d.org) as a base. My code can import import a >>>> subset of ogre model files (currently xml version) and material scripts >>>> (http://www.ogre3d.org/docs/manual/manual_14.html#SEC23). >>>> You can easily import an existing 3d content or create new one because >>>> there are ogre exporter plugins for every major modeler programs. >>>> Currently I have some working code. I hope I'll be ready to release it >>>> in a month. It should act as graphical backend for FRP libraries. >>>> I use yampa in the example program but it's just an option, only example >>>> program depends on it. >>>> >>>> Cheers, >>>> Csaba Hruska >>>> >>>> _______________________________________________ >>>> 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/20090308/c78e4102/attachment-0001.htm From svein.ove at aas.no Sun Mar 8 08:13:33 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sun Mar 8 08:01:58 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: <1236511938.22402.297.camel@localhost> References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> <1236511938.22402.297.camel@localhost> Message-ID: <221b53ab0903080513n5d46cbdejaa33a655d8eda3a3@mail.gmail.com> On Sun, Mar 8, 2009 at 12:32 PM, Duncan Coutts wrote: > Note also that the list of licenses mkcabal offers is wrong. You can get > the list from the Cabal lib itself so there is no need to maintain the > list manually. > It would also be nice to expand that list somewhat, to at least cover the most used licences - GPL2, GPL3, AGPL, etc. -- Svein Ove Aas From loup.vaillant at gmail.com Sun Mar 8 08:30:43 2009 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Sun Mar 8 08:19:10 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> <1236473265-sup-9021@existential.local> Message-ID: <6f9f8f4a0903080530q5c0f96c3s25016de0b0a862f9@mail.gmail.com> OK, thank you all for your responses. I'm impressed how fast you were. 2009/3/8 Rick R : > http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours I have it. However, Scheme is strict, which is the reason I didn't complete my reading. Maybe I am wrong. > Or go for the Real Thing: > http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-35.html#%_sec_5.5 I just opened the page. I'll see what I can take. Thank you. 2009/3/8 Jeremy Shaw : > I can say from experience that the spineless-tagless-gmachine paper > you referenced does contain all the information needed to implement an > STG->C compiler. But, you should expect to spend a lot of time > alternating between trying to implement the thing and rereading the > paper. So I just didn't tried hard enough. Time for a re-read, then! > Also, you may find that it is easier to do STG->Assembly at first (via > harpy or something). With assembly it is easier to express exactly > what you want to happen. With C you have to try to figure out how to > trick the C compiler into doing your bidding. Scary. I know only C. > Also, maybe it is more satisfying to output assembly, because then you > really feel like you are writing a compiler ;) Well, maybe later. > I am sure others will say that LLVM is a better option than C or > assembly. I know almost nothing about LLVM, so they may be right. Neither do I. But I definitely try this. One day. > -- jeremy 2009/3/8 Austin Seipp : > > Excerpts from Loup Vaillant's message of Sat Mar 07 17:32:48 -0600 2009: >> Ideally, I would very much like to compile to C. >> [...] >> -> have some kind of FFI with C (I suppose it imply some support for >> unboxed values). > > Unfortunately, after working on LHC, I can verifiably say (like all > the researchers who wrote the papers which I *didn't* read > beforehand,) that for a lot of purposes, C is an unsuitable fit for a > compilers' target language. It works pretty well if you can make the > source language execution model fit well enough, but if you can't, > you've a price to pay (both in sanity and/or performance.) Yep. > However, since your goal is *not* efficiency, you will be happy to > know that the issues with compiling to C (like garbage collection and > exception handling) can be worked around viably. I hope so. > For garbage collection, please see. > > "Accurate Garbage Collection in an Uncooperative Environment" - > http://citeseer.ist.psu.edu/538613.html > [...] > http://code.haskell.org/ddc/ddc-head/runtime/ Thank you, I'll look into that. > You can find a lot of info on C-- here; I recommend the paper at the > bottom to start off: > > http://research.microsoft.com/en-us/um/people/simonpj/papers/c--/ I'll look at that. But I am not sure it is the simplest path for me: I know C, and I don't know C-- ?yet. > http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ I have it. Maybe I should study it a bit more. > As for the FFI, I don't really have any papers on 'how to implement an > FFI', but Matthias Blume's paper might be of interest: > > "No-Longer-Foreign: Teaching an ML compiler to speak c "natively"" > http://ttic.uchicago.edu/~blume/papers/nlffi-entcs.pdf > > libffi may also be worth investigating: > http://sourceware.org/libffi/ I didn't know them, thank you. >> I have chosen the STG machine because I thought i would be easier to >> get an FFI and case exprs out of it. Maybe I am wrong, and template >> instantiation is really easier. There is also the BRISK machine, and >> GRIN. But the paper I read were less readable to me than the three >> mentioned. > > How far into GRIN have you looked? Not far enough, it seems. > It is one of the intermediate > languages for lhc/jhc, and for a low-level intermediate representation > it works quite well I think; it is a strict, monadic intermediate > language - being strict, we must still be able to model closures > ('suspendeded applications' or thunks,) so we model closures/partial > applications in a sort of 'defunctionalized' way (making grin a sort > of 'defunctionalized intermediate language' really,) by turning them > into something along the lines of an algebraic data type in GRIN. A > good benefit of this is that you actually /don't/ have to write > eval/apply yourself, because the compiler is supposed to generate it > *for* you. Here is my biggest problem with GRIN: it is not STG by far. I formatted my brain one way, so I find difficult to reformat it another way > In fact, this is a core part of GRIN - the generation of eval by the > compiler is critical for many important optimizations to take > place. It also makes the runtime a bit simpler. If I find GRIN is overall simpler, I am happy. > This comes at the price that GRIN is by design a whole-program > intermediate form; in order to pull off any of these sophisticated > transformations everything must be in memory at once. But as we have > seen with LHC/JHC, it can make a *huge* difference (apps that are 10x > smaller *and* 10x faster than ones created by GHC.) I intend my final language to be quite simple. That imply a relatively small standard library. So, maybe having all the program in memory will not be such a big deal. > Having dealt with GRIN as I work on LHC (when time now permits...) I > can say that it's a reasonable strategy and in practice it turns out > pretty well, but if you're not into optimizing the code, then STG > might be a better fit. OK, maybe I will choose STG for now, then. > I can't really give you that much advice on this area so much as > you'll just have to choose. But GRIN does have at least two excellent > references: > > Code Optimisation Techniques for Lazy Functional Languages - > U. Boquist, http://www.cs.chalmers.se/~boquist/phd/index.html > > The GRIN Project: A Highly Optimising Back End For Lazy Functional > Languages, U. Boquist, http://www.cs.chalmers.se/~boquist/ifl96-abstract.html Oh, I forgot about the second paper, thank you. I find it a bit clearer than the thesis. Having the GRIN BNF helps a lot. > Then again you said you're not interested in optimization, so perhaps > I'm just preaching to the totally wrong choir... :) No, you're not. A long (looong) term goal of mine is having crazy optimizations. I will definitely explore that path. > Austin 2009/3/8 wren ng thornton : > Loup Vaillant wrote: >> >> -> support algebraic data types and case expressions (unless I can get >> away with encoding them as functions), > > Which you always can, > [snip] > > The only trick is that you need to have closures (in order to build the > Foos) and you need to have first-class functions (in order to pass the > destructors in). If you're familiar with the STG machine, this is what they > do under the covers anyways. At the core level, all you need is some > primitive to force evaluation. Ah, that is what I was missing. I thought I had to implement seq on top of case, not the other way around. Maybe that can make Template instantiation viable > ~wren Anyway, thank you all very much. Time for some reading. Cheers, Loup From stefanschmidt42 at googlemail.com Sun Mar 8 09:47:25 2009 From: stefanschmidt42 at googlemail.com (Stefan Schmidt) Date: Sun Mar 8 09:41:59 2009 Subject: [Haskell-cafe] ANNOUNCE: Holumbus-MapReduce 0.0.1 Message-ID: <49B3CC6D.3080408@googlemail.com> The Holumbus framework is known for building specialized search-engines like the Hayoo! Haskell API search. Now, I'd like to announce the newest libraries of the Holumbus framework: Holumbus-MapReduce 0.0.1 Holumbus-Distribution 0.0.1 Holumbus-Storage 0.0.1 As part of my Master's Thesis at the University of Applied Sciences in Wedel, Germany, I have developed a library for building distributed MapReduce systems in Haskell. The existing Holumbus-Searchengine library already offers a MapReduce implementation, but it does not provide mechanisms for distributed computing. The newly developed Holumbus-MapReduce library contains of tools and modules for building individualized distributed MapReduce systems. Holumbus-MapReduce is based on two libraries: Holumbus-Distributed and Holumbus-Storage. Maybe they could be useful for building other distributed systems, not only a MapReduce system. Holumbus-Distribution consists of modules and tools for the implementation of distributed systems in general. Besides common data types and small helper functions, this library provides a mailbox-based data transfer mechanism. It offers an easy-to-use interface for inter- and intra-process communication like in Erlang or Mozart/Oz. Holumbus-Storage is designed to build a distributed storage system which can be linked into other programs. It is used by the MapReduce system for the data management. All three libraries are still under heavy development and should not be considered for creating applications in productive environments. But I think, it's time to give them to the community for suggestions on further development and features. Please email comments, bugs, etc. to sts@holumbus.org Stefan Schmidt Holumbus on Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Holumbus-MapReduce http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Holumbus-Distribution http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Holumbus-Storage link to my thesis: http://www.holumbus.org/redmine/attachments/37/thesis-mapreduce.pdf project homepage: http://www.holumbus.org/redmine/wiki/holumbus darcs repository (latest snapshots): http://holumbus.fh-wedel.de/holumbus/src From gwern0 at gmail.com Sun Mar 8 10:00:53 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Mar 8 09:49:18 2009 Subject: [Haskell-cafe] Cabal and package changelog In-Reply-To: <49B3A858.8040503@libero.it> References: <49B3A858.8040503@libero.it> Message-ID: On Sun, Mar 8, 2009 at 7:13 AM, Manlio Perillo wrote: > Hi. > > The Cabal package description includes a property `license-file`. > This property may be used by Hackage to provide a link to the license file. > > However I would like to have a `changelog-file`, too. > So that from Hackage I can quickly check what's changed with the new version > of a package. > > > Is this feasible? > > > Thanks ?Manlio Perillo http://hackage.haskell.org/trac/hackage/ticket/244 http://hackage.haskell.org/trac/hackage/ticket/299 -- gwern From bulat.ziganshin at gmail.com Sun Mar 8 10:14:29 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Mar 8 10:03:11 2009 Subject: [Haskell-cafe] ANNOUNCE: Holumbus-MapReduce 0.0.1 In-Reply-To: <49B3CC6D.3080408@googlemail.com> References: <49B3CC6D.3080408@googlemail.com> Message-ID: <1814937661.20090308171429@gmail.com> Hello Stefan, Sunday, March 8, 2009, 4:47:25 PM, you wrote: > Wedel, Germany, I have developed a library for building distributed > MapReduce systems in Haskell. > Holumbus-Distribution consists of modules and tools for the > implementation of distributed systems in general. > Holumbus-Storage is designed to build a distributed storage system which beautiful!!! i think these are sort of things where haskell will really shine and which now is covered by Erlang, Java and other languages hardly compared to Haskell -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From gue.schmidt at web.de Sun Mar 8 10:30:22 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Sun Mar 8 10:18:56 2009 Subject: [Haskell-cafe] derive & Drift - some help please Message-ID: Hi, I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped to use either derive or DrIFT to generate the instance declarations for it. I tried to understand the respective user manuals but it's still all Greek to me. Someone please help! G?nther From aslatter at gmail.com Sun Mar 8 13:25:21 2009 From: aslatter at gmail.com (Antoine Latter) Date: Sun Mar 8 13:13:48 2009 Subject: [Haskell-cafe] Help with c2hs, structs and typedefs? Message-ID: <694519c50903081025t861db79v7b3bff5df6c85cca@mail.gmail.com> Hey folks, I was trying to create some FFI bindings using c2hs and I ran into trouble: I can't use the 'sizeof' and 'set' hooks for structs that aren't defined inside a typedef. I don't know a whole lot about C - is there any declaration I can make to make something like my second struct work in c2hs? Because the second struct is what's provided in :-) In the following code, if you change all of the directives in the haskell code from my_iovec_2 to my_iovec, the "unknown indentifier" errors go away. Thanks, Antoine >>>>> -- Works! #c typedef struct { void * my_iov_base; int my_iov_len; } my_iovec; #endc -- Broken! I get lots of "unknown identifier" errors for -- the #sizeof and #set hooks - but the #pointer hook seems to work. #c struct my_iovec_2 { void * my_iov_base; int my_iov_len; }; #endc {#pointer *my_iovec_2 as IOVec newtype#} withIOVec :: [(Ptr a, CSize)] -> (Ptr IOVec -> Int -> IO b) -> IO b withIOVec [] f = f nullPtr 0 withIOVec bufers f = let len = length buffers in alocaBytes (length bufers * {#sizeof my_iovec_2#}) $ \ptr -> vecAry <- castPtr ptr foldM (go vecAry) 0 bufers f vecAry len where go vecAry off (ptr, size) = do vec <- vecAry `plusPtr` off * {#sizeof my_iovec_2#} {#set my_iovec_2->my_iov_base#} vec $ castPtr ptr {#set my_iovec_2->my_iov_len#} vec $ cIntConv size return $ off + 1 <<<<< From s.clover at gmail.com Sun Mar 8 13:36:43 2009 From: s.clover at gmail.com (Sterling Clover) Date: Sun Mar 8 13:25:08 2009 Subject: [Haskell-cafe] derive & Drift - some help please In-Reply-To: References: Message-ID: You shouldn't need any extra tools for this. A combination of the StandaloneDeriving and DeriveDataTypeable extensions in GHC should suffice. Cheers, S. On Sun, Mar 8, 2009 at 10:30 AM, G??nther Schmidt wrote: > Hi, > > I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped to use > either derive or DrIFT to generate the instance declarations for it. > > I tried to understand the respective user manuals but it's still all Greek > to me. > > Someone please help! > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090308/1e088992/attachment.htm From jmagnusj at gmail.com Sun Mar 8 13:47:39 2009 From: jmagnusj at gmail.com (Magnus Jonsson) Date: Sun Mar 8 13:36:03 2009 Subject: [Haskell-cafe] Help with c2hs, structs and typedefs? In-Reply-To: <694519c50903081025t861db79v7b3bff5df6c85cca@mail.gmail.com> References: <694519c50903081025t861db79v7b3bff5df6c85cca@mail.gmail.com> Message-ID: <402c8fb80903081047t49bd560cm48db5f41fe7cbbf0@mail.gmail.com> In C, if you don't typedef the struct, the name of the struct is "struct my_iovec_2", not "my_iovec_2". I don't know much about the haskell FFI, but maybe this is the problem? (by the way, why does "reply" default to replying to the sender, not the mailing list?) On Sun, Mar 8, 2009 at 1:25 PM, Antoine Latter wrote: > Hey folks, I was trying to create some FFI bindings using c2hs and I > ran into trouble: I can't use the 'sizeof' and 'set' hooks for structs > that aren't defined inside a typedef. > > I don't know a whole lot about C - is there any declaration I can make > to make something like my second struct work in c2hs? ?Because the > second struct is what's provided in :-) > > In the following code, if you change all of the directives in the > haskell code from my_iovec_2 to my_iovec, the "unknown indentifier" > errors go away. > > Thanks, > Antoine > >>>>>> > > -- Works! > #c > typedef struct { > ?void * my_iov_base; > ?int ? ?my_iov_len; > } my_iovec; > > #endc > > -- Broken! ?I get lots of "unknown identifier" errors for > -- the #sizeof and #set hooks - but the #pointer hook seems to work. > #c > struct my_iovec_2 { > ?void * my_iov_base; > ?int ? ?my_iov_len; > }; > #endc > > {#pointer *my_iovec_2 as IOVec newtype#} > > withIOVec :: [(Ptr a, CSize)] -> (Ptr IOVec -> Int -> IO b) -> IO b > withIOVec [] f = f nullPtr 0 > withIOVec bufers f > ? ?= let len = length buffers in > ? ? ?alocaBytes (length bufers * {#sizeof my_iovec_2#}) $ \ptr -> > ? ? ?vecAry <- castPtr ptr > ? ? ?foldM (go vecAry) 0 bufers > ? ? ?f vecAry len > > ?where go vecAry off (ptr, size) = do > ? ? ? ? vec <- vecAry `plusPtr` off * {#sizeof my_iovec_2#} > ? ? ? ? {#set my_iovec_2->my_iov_base#} vec $ castPtr ptr > ? ? ? ? {#set my_iovec_2->my_iov_len#} ?vec $ cIntConv size > ? ? ? ? return $ off + 1 > <<<<< > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From aslatter at gmail.com Sun Mar 8 13:54:55 2009 From: aslatter at gmail.com (Antoine Latter) Date: Sun Mar 8 13:43:21 2009 Subject: [Haskell-cafe] Help with c2hs, structs and typedefs? In-Reply-To: <402c8fb80903081047t49bd560cm48db5f41fe7cbbf0@mail.gmail.com> References: <694519c50903081025t861db79v7b3bff5df6c85cca@mail.gmail.com> <402c8fb80903081047t49bd560cm48db5f41fe7cbbf0@mail.gmail.com> Message-ID: <694519c50903081054n7157acbdv1638244f8b3629b9@mail.gmail.com> On Sun, Mar 8, 2009 at 12:47 PM, Magnus Jonsson wrote: > In C, if you don't typedef the struct, the name of the struct is > "struct my_iovec_2", not "my_iovec_2". I don't know much about the > haskell FFI, but maybe this is the problem? > > (by the way, why does "reply" default to replying to the sender, not > the mailing list?) > Ah! It seems that adding: #c typedef struct my_iovec_2 my_iovec_3; #endc gives me something I can work with. Thanks. Antoine From duncan.coutts at worc.ox.ac.uk Sun Mar 8 14:01:26 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 8 13:49:55 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: <221b53ab0903080513n5d46cbdejaa33a655d8eda3a3@mail.gmail.com> References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> <1236511938.22402.297.camel@localhost> <221b53ab0903080513n5d46cbdejaa33a655d8eda3a3@mail.gmail.com> Message-ID: <1236535286.22402.300.camel@localhost> On Sun, 2009-03-08 at 13:13 +0100, Svein Ove Aas wrote: > On Sun, Mar 8, 2009 at 12:32 PM, Duncan Coutts > wrote: > > Note also that the list of licenses mkcabal offers is wrong. You can get > > the list from the Cabal lib itself so there is no need to maintain the > > list manually. > > > It would also be nice to expand that list somewhat, to at least cover > the most used licences - GPL2, GPL3, AGPL, etc. Cabal HEAD adds MIT and versioned GPL and LGPL. We could not change it much earlier because old Cabal versions (ie 1.2 and earlier) would have barfed on parsing names it did not recognise. Duncan From duncan.coutts at worc.ox.ac.uk Sun Mar 8 14:11:57 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 8 14:00:25 2009 Subject: [Haskell-cafe] Cabal and package changelog In-Reply-To: References: <49B3A858.8040503@libero.it> Message-ID: <1236535917.22402.306.camel@localhost> On Sun, 2009-03-08 at 10:00 -0400, Gwern Branwen wrote: > On Sun, Mar 8, 2009 at 7:13 AM, Manlio Perillo wrote: > > Hi. > > > > The Cabal package description includes a property `license-file`. > > This property may be used by Hackage to provide a link to the license file. > > > > However I would like to have a `changelog-file`, too. > > So that from Hackage I can quickly check what's changed with the new version > > of a package. > > > > > > Is this feasible? > > > > > > Thanks Manlio Perillo > > http://hackage.haskell.org/trac/hackage/ticket/244 > http://hackage.haskell.org/trac/hackage/ticket/299 Thanks Gwern. Yes, we're looking for a volunteer to work on implementing this. One question is what the changelog format should be? Or should it just be uninterpreted text? One suggestion was for Hackage and the RSS feed to display the diff between the current and previous version of the changelog. Or perhaps we can do both, diff it and parse the result as haddock markup or something. So suggestions and volunteers welcome. Duncan From manlio_perillo at libero.it Sun Mar 8 14:37:00 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Mar 8 14:25:30 2009 Subject: [Haskell-cafe] Cabal and package changelog In-Reply-To: <1236535917.22402.306.camel@localhost> References: <49B3A858.8040503@libero.it> <1236535917.22402.306.camel@localhost> Message-ID: <49B4104C.10401@libero.it> Duncan Coutts ha scritto: > On Sun, 2009-03-08 at 10:00 -0400, Gwern Branwen wrote: >> On Sun, Mar 8, 2009 at 7:13 AM, Manlio Perillo wrote: >>> Hi. >>> >>> The Cabal package description includes a property `license-file`. >>> This property may be used by Hackage to provide a link to the license file. >>> >>> However I would like to have a `changelog-file`, too. >>> So that from Hackage I can quickly check what's changed with the new version >>> of a package. >>> >>> >>> Is this feasible? >>> >>> >>> Thanks Manlio Perillo >> http://hackage.haskell.org/trac/hackage/ticket/244 >> http://hackage.haskell.org/trac/hackage/ticket/299 > > Thanks Gwern. Yes, we're looking for a volunteer to work on implementing > this. > > One question is what the changelog format should be? Or should it just > be uninterpreted text? One suggestion was for Hackage and the RSS feed > to display the diff between the current and previous version of the > changelog. Or perhaps we can do both, diff it and parse the result as > haddock markup or something. > Personally, I find a format like: http://divmod.org/trac/browser/trunk/Nevow/NEWS.txt simple, compact and flexible. GNU Changelog format is probably an overkill, since nowadays we have good revision control systems. However GNU Changelog format *may* be supported (perhaps the changelog format can be specified in a Cabal property). > So suggestions and volunteers welcome. > > Duncan > Manlio From relapse.dev at gmx.com Sun Mar 8 14:49:52 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Sun Mar 8 14:36:29 2009 Subject: [Haskell-cafe] Re: 3D Rendering Engine in Haskell (Re: FRP + physics / status of hpysics) In-Reply-To: <8914b92d0903080440rd582248v4ba68aa11a016008@mail.gmail.com> References: <8914b92d0903080440rd582248v4ba68aa11a016008@mail.gmail.com> Message-ID: Csaba Hruska wrote: > Of course I write everything in haskell! I mean about Ogre that i use > only it's model and material formats and none of its code. Thats all. > Yes, later I'd like to write a collada importer. :) > > 2009/3/8 Peter Verswyvelen > > > Awesome! > > When you say you took Ogre as a base, do you mean your engine will > be able to load the meshes and material files, or are you also > wrapping the C++ code base? > > Did you also consider Collada? > > 2009/3/8 Csaba Hruska > > > Hi! > > This should be a bit offtopic, but now I'd like to announce that > I'm working on a 3D rendering rengine in Haskell. > I take ogre3d (www.ogre3d.org ) as a > base. My code can import import a subset of ogre model files > (currently xml version) and material scripts > (http://www.ogre3d.org/docs/manual/manual_14.html#SEC23). > You can easily import an existing 3d content or create new one > because there are ogre exporter plugins for every major modeler > programs. > Currently I have some working code. I hope I'll be ready to > release it in a month. It should act as graphical backend for > FRP libraries. > I use yampa in the example program but it's just an option, only > example program depends on it. > > Cheers, > Csaba Hruska > > _______________________________________________ > 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 Would be nice if the ogre resource loading stuff were a seperate library. Anyway, it seems like theres quite a few people working on game/openGL related stuff for Haskell now. Would be nice to get a group of people working on something. Personally, I've been working on a 2d isometric game for the past several months. From dons at galois.com Sun Mar 8 14:56:40 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 8 14:46:17 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: <1236511938.22402.297.camel@localhost> References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> <1236511938.22402.297.camel@localhost> Message-ID: <20090308185640.GA24228@whirlpool.galois.com> duncan.coutts: > On Sat, 2009-03-07 at 17:30 +0000, Colin Paul Adams wrote: > > >>>>> "Svein" == Svein Ove Aas writes: > > > > >> Preprocessing library game-tree-1.0.0.0... Building > > >> game-tree-1.0.0.0... > > >> > > >> Data/Tree/Game/Negascout.hs:31:0: Unrecognised pragma [1 of 2] > > >> Compiling Data.Tree.Game.Tree ( Data/Tree/Game/Tree.hs, > > >> dist/build/Data/Tree/Game/Tree.o ) > > >> > > >> Data/Tree/Game/Tree.hs:1:0: Failed to load interface for > > >> `Prelude': it is a member of package base-3.0.3.0, which > > >> is hidden > > >> > > Svein> What does your .cabal file look like? > > Don, mkcabal is generating .cabal files that are confusing people. > > It should generate new-style .cabal files with library or executable > sections. The ghc-options and build-depends etc need to be in the lib or > exe section. > > The files it generates are not actually broken but it leaves new users > to do the conversion from old style to new and unsurprisingly many get > that wrong. Cabal is also at fault here for not providing good > diagnostics but it would help if mkcabal used the current recommended > style. > > Note also that the list of licenses mkcabal offers is wrong. You can get > the list from the Cabal lib itself so there is no need to maintain the > list manually. > > I still think mkcabal should be integrated into cabal-install, like: > $ cabal init > or something. We could also more easily keep it up to date that way. mkcabal is unmaintained. -- Don From redcom at fedoms.com Sun Mar 8 14:58:56 2009 From: redcom at fedoms.com (=?windows-1252?Q?G=3Fuenther_Schmidt?=) Date: Sun Mar 8 14:47:24 2009 Subject: [Haskell-cafe] Re: derive & Drift - some help please In-Reply-To: References: Message-ID: <49B41570.9030202@fedoms.com> Hi Sterling, sry, but I can't get it to work. G?nther Sterling Clover schrieb: > You shouldn't need any extra tools for this. A combination of the > StandaloneDeriving and DeriveDataTypeable extensions in GHC should suffice. > > Cheers, > S. > > On Sun, Mar 8, 2009 at 10:30 AM, G??nther Schmidt > wrote: > > Hi, > > I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped > to use either derive or DrIFT to generate the instance declarations > for it. > > I tried to understand the respective user manuals but it's still all > Greek to me. > > Someone please help! > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From alexander.dunlap at gmail.com Sun Mar 8 15:31:51 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Mar 8 15:20:16 2009 Subject: [Haskell-cafe] Re: derive & Drift - some help please In-Reply-To: <49B41570.9030202@fedoms.com> References: <49B41570.9030202@fedoms.com> Message-ID: <57526e770903081231x5078a63u5802d0c1828df279@mail.gmail.com> What problems are you encountering? Alex On Sun, Mar 8, 2009 at 11:58 AM, G?uenther Schmidt wrote: > Hi Sterling, > > sry, but I can't get it to work. > > G?nther > > Sterling Clover schrieb: >> >> You shouldn't need any extra tools for this. A combination of the >> StandaloneDeriving and DeriveDataTypeable extensions in GHC should suffice. >> >> Cheers, >> S. >> >> On Sun, Mar 8, 2009 at 10:30 AM, G??nther Schmidt > > wrote: >> >> ? ?Hi, >> >> ? ?I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped >> ? ?to use either derive or DrIFT to generate the instance declarations >> ? ?for it. >> >> ? ?I tried to understand the respective user manuals but it's still all >> ? ?Greek to me. >> >> ? ?Someone please help! >> >> ? ?G?nther >> >> ? ?_______________________________________________ >> ? ?Haskell-Cafe mailing list >> ? ?Haskell-Cafe@haskell.org >> ? ?http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From gue.schmidt at web.de Sun Mar 8 15:40:10 2009 From: gue.schmidt at web.de (=?windows-1252?Q?G=FC=3Fnther_Schmidt?=) Date: Sun Mar 8 15:28:46 2009 Subject: [Haskell-cafe] Re: derive & Drift - some help please In-Reply-To: <57526e770903081231x5078a63u5802d0c1828df279@mail.gmail.com> References: <49B41570.9030202@fedoms.com> <57526e770903081231x5078a63u5802d0c1828df279@mail.gmail.com> Message-ID: <49B41F1A.7090400@web.de> Hi Alexander, well I have this: newtype AdmissionDate = AdmDt LocalTime deriving (Data,Typeable ..) at least that's where I wonna get. I don't know how to create the proper instance declarations though for LocalTime. AdmissionDate is an element of a larger data structure, this data structure for instance also has a newtype DischargeDate = DchrgDt LocalTime deriving (Data,Typeable ...) With my haskell work so far I was blessedly free of the need for deriving. Until now ... G?nther Alexander Dunlap schrieb: > What problems are you encountering? > > Alex > > On Sun, Mar 8, 2009 at 11:58 AM, G?uenther Schmidt wrote: >> Hi Sterling, >> >> sry, but I can't get it to work. >> >> G?nther >> >> Sterling Clover schrieb: >>> You shouldn't need any extra tools for this. A combination of the >>> StandaloneDeriving and DeriveDataTypeable extensions in GHC should suffice. >>> >>> Cheers, >>> S. >>> >>> On Sun, Mar 8, 2009 at 10:30 AM, G??nther Schmidt >> > wrote: >>> >>> Hi, >>> >>> I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped >>> to use either derive or DrIFT to generate the instance declarations >>> for it. >>> >>> I tried to understand the respective user manuals but it's still all >>> Greek to me. >>> >>> Someone please help! >>> >>> G?nther >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From alexander.dunlap at gmail.com Sun Mar 8 15:42:57 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Mar 8 15:31:22 2009 Subject: [Haskell-cafe] Re: derive & Drift - some help please In-Reply-To: <49B41F1A.7090400@web.de> References: <49B41570.9030202@fedoms.com> <57526e770903081231x5078a63u5802d0c1828df279@mail.gmail.com> <49B41F1A.7090400@web.de> Message-ID: <57526e770903081242k41ebbce2y9282f77a47123cbf@mail.gmail.com> Well you can do > deriving instance Typeable LocalType etc. if you enable the DeriveDataTypeable and StandaloneDeriving extensions. You will get other error messages for missing instances; just keep adding > deriving instance Typeable Day etc. Eventually, you will need to implement an instance by hand for Pico, because Pico's data constructors are not exported from Data.Fixed. I'm not very familiar with Data and Typeable so I can't help you there, but you can probably look at some existing instances for help. Hope that's useful for you. Alex On Sun, Mar 8, 2009 at 12:40 PM, G??nther Schmidt wrote: > Hi Alexander, > > > well I have this: > > newtype AdmissionDate = AdmDt LocalTime > ? ? ? ?deriving (Data,Typeable ..) > > at least that's where I wonna get. > > I don't know how to create the proper instance declarations though for > LocalTime. > > AdmissionDate is an element of a larger data structure, this data structure > for instance also has a > > newtype DischargeDate = DchrgDt LocalTime > ? ? ? ?deriving (Data,Typeable ...) > > With my haskell work so far I was blessedly free of the need for deriving. > Until now ... > > G?nther > > > Alexander Dunlap schrieb: >> >> What problems are you encountering? >> >> Alex >> >> On Sun, Mar 8, 2009 at 11:58 AM, G?uenther Schmidt >> wrote: >>> >>> Hi Sterling, >>> >>> sry, but I can't get it to work. >>> >>> G?nther >>> >>> Sterling Clover schrieb: >>>> >>>> You shouldn't need any extra tools for this. A combination of the >>>> StandaloneDeriving and DeriveDataTypeable extensions in GHC should >>>> suffice. >>>> >>>> Cheers, >>>> S. >>>> >>>> On Sun, Mar 8, 2009 at 10:30 AM, G??nther Schmidt >>> > wrote: >>>> >>>> ? Hi, >>>> >>>> ? I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped >>>> ? to use either derive or DrIFT to generate the instance declarations >>>> ? for it. >>>> >>>> ? I tried to understand the respective user manuals but it's still all >>>> ? Greek to me. >>>> >>>> ? Someone please help! >>>> >>>> ? G?nther >>>> >>>> ? _______________________________________________ >>>> ? Haskell-Cafe mailing list >>>> ? Haskell-Cafe@haskell.org >>>> ? http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>>> >>>> >>>> ------------------------------------------------------------------------ >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> > > > From gue.schmidt at web.de Sun Mar 8 16:18:36 2009 From: gue.schmidt at web.de (=?windows-1252?Q?G=FC=3Fnther_Schmidt?=) Date: Sun Mar 8 16:07:17 2009 Subject: [Haskell-cafe] Re: derive & Drift - some help please In-Reply-To: <57526e770903081242k41ebbce2y9282f77a47123cbf@mail.gmail.com> References: <49B41570.9030202@fedoms.com> <57526e770903081231x5078a63u5802d0c1828df279@mail.gmail.com> <49B41F1A.7090400@web.de> <57526e770903081242k41ebbce2y9282f77a47123cbf@mail.gmail.com> Message-ID: Hi Alexander, this does the trick! G?nther Alexander Dunlap schrieb: > Well you can do > >> deriving instance Typeable LocalType > > etc. if you enable the DeriveDataTypeable and StandaloneDeriving > extensions. You will get other error messages for missing instances; > just keep adding > >> deriving instance Typeable Day > > etc. Eventually, you will need to implement an instance by hand for > Pico, because Pico's data constructors are not exported from > Data.Fixed. I'm not very familiar with Data and Typeable so I can't > help you there, but you can probably look at some existing instances > for help. > > Hope that's useful for you. > > Alex > > On Sun, Mar 8, 2009 at 12:40 PM, G??nther Schmidt wrote: >> Hi Alexander, >> >> >> well I have this: >> >> newtype AdmissionDate = AdmDt LocalTime >> deriving (Data,Typeable ..) >> >> at least that's where I wonna get. >> >> I don't know how to create the proper instance declarations though for >> LocalTime. >> >> AdmissionDate is an element of a larger data structure, this data structure >> for instance also has a >> >> newtype DischargeDate = DchrgDt LocalTime >> deriving (Data,Typeable ...) >> >> With my haskell work so far I was blessedly free of the need for deriving.. >> Until now ... >> >> G?nther >> >> >> Alexander Dunlap schrieb: >>> What problems are you encountering? >>> >>> Alex >>> >>> On Sun, Mar 8, 2009 at 11:58 AM, G?uenther Schmidt >>> wrote: >>>> Hi Sterling, >>>> >>>> sry, but I can't get it to work. >>>> >>>> G?nther >>>> >>>> Sterling Clover schrieb: >>>>> You shouldn't need any extra tools for this. A combination of the >>>>> StandaloneDeriving and DeriveDataTypeable extensions in GHC should >>>>> suffice. >>>>> >>>>> Cheers, >>>>> S. >>>>> >>>>> On Sun, Mar 8, 2009 at 10:30 AM, G??nther Schmidt >>>> > wrote: >>>>> >>>>> Hi, >>>>> >>>>> I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped >>>>> to use either derive or DrIFT to generate the instance declarations >>>>> for it. >>>>> >>>>> I tried to understand the respective user manuals but it's still all >>>>> Greek to me. >>>>> >>>>> Someone please help! >>>>> >>>>> G?nther >>>>> >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------ >>>>> >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >> >> From dons at galois.com Sun Mar 8 16:36:01 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 8 16:25:14 2009 Subject: [Haskell-cafe] Arch Linux: New package updates for Mar 8, 2008 Message-ID: <20090308203601.GF24228@whirlpool.galois.com> New Haskell packages for the week ending Mar 8. http://archhaskell.wordpress.com/2009/03/08/arch-haskell-news-mar-8-2009/ Arch now has 962 Haskell packages in AUR. That?s 17 new packages this week, and lots of updates as well. Notable releases this week * htar-0.3: Command-line tar archive utility * haskell-llvm-0.6.5.0: Bindings to the LLVM compiler toolkit * haskell-harpy-0.4.1: Runtime code generation for x86 machine code * haskell-future-1.0.0: Supposed to mimics and enhance proposed C++ ?future? features * haskell-holumbus-mapreduce-0.0.1: a distributed MapReduce framework * haskell-holumbus-storage-0.0.1: a distributed storage system * haskell-holumbus-distribution-0.0.1: intra- and inter-program communication * hevolisa-dph-0.0.1: Genetic Mona Lisa problem in Haskell - using Data Parallel Haskell * doctest-0.0.0: Test interactive Haskell examples * haskell-happstack-0.2.1: The haskell application server stack + code generation See the full list of new Haskell packages this week on the blog, broken down by category, http://archhaskell.wordpress.com/2009/03/08/arch-haskell-news-mar-8-2009/ From roma at ro-che.info Sun Mar 8 17:07:46 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun Mar 8 16:56:41 2009 Subject: [Haskell-cafe] Re: 3D Rendering Engine in Haskell (Re: FRP + physics / status of hpysics) In-Reply-To: References: <8914b92d0903080440rd582248v4ba68aa11a016008@mail.gmail.com> Message-ID: <20090308210746.GA12354@flit> * Neal Alexander [2009-03-08 10:49:52-0800] > Anyway, it seems like theres quite a few people working on game/openGL > related stuff for Haskell now. Would be nice to get a group of people > working on something. Please go ahead! > Personally, I've been working on a 2d isometric game for the past several > months. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From lemming at henning-thielemann.de Sun Mar 8 18:11:23 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Mar 8 18:00:34 2009 Subject: [Haskell-cafe] Re: a newbies confusion with repositories - darcs or git In-Reply-To: <30r618x6kc.fsf@Clio.twb.ath.cx> References: <20090301104046.GB32441@Macintosh.local> <20090307193201.GC12985@Macintosh.local> <30r618x6kc.fsf@Clio.twb.ath.cx> Message-ID: On Sun, 8 Mar 2009, Trent W. Buck wrote: > Eric Kow writes: > >> One of the darcs team members, Thorkil Naur, felt that in my enthusiasm I >> was not being sufficiently forthright about darcs's shortcomings. > > As for me, I tend to start any review with a list of all the problems I > have with , on the basis that it's a lot harder to find > informed criticism of a technology than it is to find praise (informed > or otherwise). So I would write an article "Why you shouldn't choose > Darcs", and let readers decide whether the arguments are inadequate. In general, I also find it more difficult to retrieve well-founded criticism than to find praise. I like to cite Edsger Dijkstra on this topic: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD09xx/EWD956.html "Address to my students" http://www.cs.utexas.edu/users/EWD/transcriptions/EWD04xx/EWD498.html "How do we tell truths that might hurt?" From kyagrd at gmail.com Sun Mar 8 18:33:18 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Sun Mar 8 18:28:27 2009 Subject: [Haskell-cafe] cabal-install 0.6.2 does not bootstrap with ghc-6.10.1 debian distribution In-Reply-To: <1236511083.22402.286.camel@localhost> References: <1236511083.22402.286.camel@localhost> Message-ID: <49B447AE.4070305@gmail.com> Duncan Coutts ? ?: > On Sat, 2009-03-07 at 17:51 -0800, Ahn, Ki Yung wrote: >> Dear Haskellers and especially who are working on cabal-install >> and debian packaging, >> >> I sometimes clean up .ghc and .cabal in my home directory to start from >> scratch because of dependency loopholes (cabal-install does not have >> remove option yet, so it's hard to fix when such loophole happens). >> >> Today, I had some time in the airport and decided to start from scratch >> again because of the dependency loophole with process 1.0.1.1 and >> haddock. I downloaded the most recent version of cabal-install the >> version 0.6.2, and found out that the ./bootstrap.sh does not work. > > If you could provide any details on how it does not work that would be > much appreciated. Eg a log of the output from running the bootstrap. > > Duncan > I am using Debian unstable. The version of GHC debian package is 6.10.1+dfsg1-13, and installed Haskell libraries (debian packages) are: kyagrd@kyavaio:~$ ghc-pkg list /usr/lib/ghc-6.10.1/./package.conf: Cabal-1.6.0.1, Diff-0.1.2, HGL-3.2.0.0, HUnit-1.2.0.3, QuickCheck-2.1.0.1, Stream-0.2.2, X11-1.4.5, array-0.2.0.0, arrows-0.4.1, base-3.0.3.0, base-4.0.0.0, binary-0.5, bytestring-0.9.1.4, cairo-0.10.0, cgi-3001.1.7.1, containers-0.2.0.0, directory-1.0.0.2, editline-0.2.1.0, fgl-5.4.2.2, filepath-1.1.0.1, gconf-0.10.0, (ghc-6.10.1), ghc-prim-0.1.0.0, gio-0.10.0, glade-0.10.0, glib-0.10.0, gnomevfs-0.10.0, gstreamer-0.10.0, gtk-0.10.0, gtkglext-0.10.0, gtksourceview2-0.10.0, haskell98-1.0.1.0, hpc-0.5.0.2, html-1.0.1.2, integer-0.1.0.0, irc-0.4.3, mtl-1.1.0.2, network-2.2.0.1, old-locale-1.0.0.1, old-time-1.0.0.1, packedstring-0.1.0.1, parallel-1.1.0.0, parsec-3.0.0, pretty-1.0.1.0, process-1.0.1.0, random-1.0.0.1, rts-1.0, stm-2.1.1.2, svgcairo-0.10.0, syb-0.1.0.0, syb-with-class-0.5.1, tagsoup-0.6, template-haskell-2.3.0.0, time-1.1.2.3, unix-2.3.1.0, utf8-string-0.3.4, xhtml-3000.2.0.1 Bootstrap fails like this: kyagrd@kyavaio:~/tmp/cabal-install-0.6.2$ sh bootstrap.sh Checking installed packages for ghc-6.10.1... The Haskell package 'parsec' is required but it is not installed. If you are using a ghc package provided by your operating system then install the corresponding packages for 'parsec' and 'network'. If you built ghc from source with only the core libraries then you should install these extra packages. You can get them from hackage. Error during cabal-install bootstrap: The Haskell package 'parsec' is required but it is not installed. P.S. Note, parsec and network are installed in the system using debian distribution packages. -- Ahn, Ki Yung From loup.vaillant at gmail.com Sun Mar 8 18:41:19 2009 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Sun Mar 8 18:29:43 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> <1236473265-sup-9021@existential.local> Message-ID: <6f9f8f4a0903081541hf17aa69h8ea41058d9afda26@mail.gmail.com> Thanks to the courage you all gave me, I found the strength to go on. Template instantiation seems to be the easiest path, so I decided to follow it. I think I solved the problem about primitives and FFI I though it had. Namely, how the hell do I compile primitive calls with an arbitrary number of arguments. Starting from the Tutorial of Peyton Jones and Lester, I added a new node type to help guide the order of evaluation. Basically, this "Seq" node takes the address of two other nodes. It pushes them both on the stack, like an application node would. (That is because I don't want a dump, but I could as well create a new stack and and push the previous one on the dump.) Note the nodes which are evaluated this way must not have a functional head normal form (primitive or supercombinator). That would leak past the beginning of the stack. When the node is finally evaluated (e.g. points to a HNF, like a boxed integer), the topmost and second topmost pointers on the stack are swapped. (or the topmost pointer of the stack and the topmost pointer of the topmost stack on the dump are swapped). With a suitable compilation scheme, that should guarantee that primitives have their arguments already evaluated. (And avoid infinite loops). Now, I just have to implement it. :-) Cheers, Loup. From gue.schmidt at web.de Sun Mar 8 19:02:12 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Sun Mar 8 18:50:47 2009 Subject: [Haskell-cafe] Looking for literature Message-ID: Hi all, I'm trying to catch up with all the wonderful Haskell Types, classes, Abstract Data Types, Algebraic Data Types, Types that give peoples headaches and all the other, deeper stuff I have been happily putting off. Now to look smart I have a bookshelf full of books for smart people and TaPL is amoung them. Should I try that or will RWH teach me enough to get by? G?nther From lemming at henning-thielemann.de Sun Mar 8 19:12:32 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Mar 8 19:00:57 2009 Subject: [Haskell-cafe] Re: [Haskell] string type class In-Reply-To: <1236385792.22402.273.camel@localhost> References: <200903061233.36400.matthew.pocock@ncl.ac.uk> <49B17691.9010402@list.mightyreason.com> <1236385792.22402.273.camel@localhost> Message-ID: On Sat, 7 Mar 2009, Duncan Coutts wrote: > On Fri, 2009-03-06 at 19:16 +0000, Chris Kuklewicz wrote: >> >> Not likely. >> >> I did define my own (private) class for regular expressions, to abstract over >> String, the ByteStrings, and Seq Char. But it is used in one place and is a >> wart that should be removed. >> >> The simple task of looping over the contents of a String (once, forward) is >> quite different from a Strict ByteString (using an index and a lookup). >> >> This means for decent efficiency I need two copies of my code, hand specialized >> to each case. >> >> "tail" or "(x:xs)" : very efficient for String (no allocation) >> "tail" or "uncons" : not efficient for ByteString (allocation, might as well >> convert to [Char] > > head/tail/uncons on a strict or lazy ByteString is perfectly ok. I would > recommend it over using length+index. If you are using tail in a tail > recursion then ghc can almost always optimise it to unbox the various > ByteString components and so there is no allocation of fresh BS > constructors, just adjusting offsets and lengths held in registers. Recently I also used 'ByteString.uncons' in a parser, because I thought that it is cheap. Actually the parsing became slower than with String. I then used wrappers to strict and lazy ByteStrings, which maintain the index of the current reader position. Although they duplicate the 'start' index of the internal ByteString records, these wrappers are faster, probably because no ByteString record must be allocated in each step. http://code.haskell.org/~thielema/tagchup/src/Text/HTML/Tagchup/Parser/Stream.hs From lemming at henning-thielemann.de Sun Mar 8 19:14:54 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Mar 8 19:03:18 2009 Subject: [Haskell-cafe] Looking for a co-founder for a startup using Haskell In-Reply-To: <86f16dc10903061535y2cce6fdeja811f4f7d4f7380c@mail.gmail.com> References: <86f16dc10903061535y2cce6fdeja811f4f7d4f7380c@mail.gmail.com> Message-ID: On Fri, 6 Mar 2009, Ed McCaffrey wrote: > Hello, > > I'm turning a project involving music into a startup, and I will be using Haskell for most > and possibly all of it.? I had an angel investor interested until the market collapse forced > him to turn his focus away from new investments.? Other investors I have spoken with want me > to contact them again when it is further developed; basically, I think that I am optimistic > at the prospect of funding with the right team. You may also want to contact: Haskell Art Mailing list From jfredett at gmail.com Sun Mar 8 19:16:06 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Sun Mar 8 19:04:32 2009 Subject: [Haskell-cafe] Looking for literature In-Reply-To: References: Message-ID: <49B451B6.8060502@gmail.com> TaPL, iirc, is more about compilers and typesystems, and not specifically about haskell. RWH will give you a cover of the basic stuff and common data types. The Typeclassopedia will cover all the major typeclasses (google search ought to reveal it's super-secret location). Otherwise, the wikibook, the wiki, and the haskell docs are a good place to look to get a handle on the myriad library datatypes provided. /Joe G??nther Schmidt wrote: > Hi all, > > I'm trying to catch up with all the wonderful Haskell Types, classes, > Abstract Data Types, Algebraic Data Types, Types that give peoples > headaches and all the other, deeper stuff I have been happily putting > off. > > Now to look smart I have a bookshelf full of books for smart people > and TaPL is amoung them. > > Should I try that or will RWH teach me enough to get by? > > G?nther > > _______________________________________________ > 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: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090308/1fee7f78/jfredett.vcf From rick.richardson at gmail.com Sun Mar 8 19:16:46 2009 From: rick.richardson at gmail.com (Rick R) Date: Sun Mar 8 19:05:10 2009 Subject: [Haskell-cafe] STG's? [was: I want to write a compiler] Message-ID: <9810b81b0903081616g1f15335fsb6acd9f2946cccb@mail.gmail.com> Where can I find more information on STGs? Google search doesn't bring up anything too enlightening. My curiosity was piqued by http://www.cs.chalmers.se/~gedell/ssc/index.html. Of course it doesn't indicate how these should be built or the format. On Sun, Mar 8, 2009 at 6:41 PM, Loup Vaillant wrote: > Thanks to the courage you all gave me, I found the strength to go on. > > Template instantiation seems to be the easiest path, so I decided to > follow it. I think I solved the problem about primitives and FFI I > though it had. Namely, how the hell do I compile primitive calls with > an arbitrary number of arguments. > > Starting from the Tutorial of Peyton Jones and Lester, I added a new > node type to help guide the order of evaluation. Basically, this "Seq" > node takes the address of two other nodes. It pushes them both on the > stack, like an application node would. (That is because I don't want a > dump, but I could as well create a new stack and and push the previous > one on the dump.) > > Note the nodes which are evaluated this way must not have a functional > head normal form (primitive or supercombinator). That would leak past > the beginning of the stack. > > When the node is finally evaluated (e.g. points to a HNF, like a boxed > integer), the topmost and second topmost pointers on the stack are > swapped. (or the topmost pointer of the stack and the topmost pointer > of the topmost stack on the dump are swapped). > > With a suitable compilation scheme, that should guarantee that > primitives have their arguments already evaluated. (And avoid infinite > loops). > > Now, I just have to implement it. :-) > > Cheers, > Loup. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- We can't solve problems by using the same kind of thinking we used when we created them. - A. Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090308/6f743b55/attachment.htm From ashley at semantic.org Sun Mar 8 19:19:43 2009 From: ashley at semantic.org (Ashley Yakeley) Date: Sun Mar 8 19:08:07 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: References: Message-ID: <49B4528F.4060306@semantic.org> Eelco Lempsink wrote: > The list with options can be found here (for now): > http://community.haskell.org/~eelco/poll.html Notice that some (very) > similar logos are grouped as one option (thanks to Ian Lynagh) All > submissions compete, so that still makes more than a 100 options! > > The voting system we'll use is the Condorcet Internet Voting System > (http://www.cs.cornell.edu/andru/civs.html). So ranking all 100+ items on the Condorcet ballot is a bit of a daunting task. However, if we get a rough idea of the favourites, we can each cut down a bit on the work. For instance, suppose 82 and 93 are very popular. You might not like either of them, but it's worth ranking them on your ballot (after the ones you do like) if you have a preference between them. But there's less need to rank the ones no-one likes. I'm currently liking 30 (specifically, 30.7) 58 61 (specifically, the second image) 62 -- Ashley Yakeley From jfredett at gmail.com Sun Mar 8 19:33:46 2009 From: jfredett at gmail.com (Joseph Fredette) Date: Sun Mar 8 19:22:12 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <49B4528F.4060306@semantic.org> References: <49B4528F.4060306@semantic.org> Message-ID: <49B455DA.6030907@gmail.com> Another alternative, perhaps we rank the first n we care about, and regard the rest as ranked as low as possible? Since Condorcet allows ties, it should work -- I don't know if it _technically_ allows for skipping ranks, though, but I imagine it would still work... Ashley Yakeley wrote: > Eelco Lempsink wrote: > >> The list with options can be found here (for now): >> http://community.haskell.org/~eelco/poll.html Notice that some >> (very) similar logos are grouped as one option (thanks to Ian Lynagh) >> All submissions compete, so that still makes more than a 100 options! >> >> The voting system we'll use is the Condorcet Internet Voting System >> (http://www.cs.cornell.edu/andru/civs.html). > > So ranking all 100+ items on the Condorcet ballot is a bit of a > daunting task. However, if we get a rough idea of the favourites, we > can each cut down a bit on the work. > > For instance, suppose 82 and 93 are very popular. You might not like > either of them, but it's worth ranking them on your ballot (after the > ones you do like) if you have a preference between them. But there's > less need to rank the ones no-one likes. > > I'm currently liking > > 30 (specifically, 30.7) > 58 > 61 (specifically, the second image) > 62 > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090308/e50856d1/jfredett.vcf From redcom at fedoms.com Sun Mar 8 19:46:32 2009 From: redcom at fedoms.com (=?ISO-8859-15?Q?G=3Fuenther_Schmidt?=) Date: Sun Mar 8 19:34:58 2009 Subject: [Haskell-cafe] Looking for literature In-Reply-To: <49B451B6.8060502@gmail.com> References: <49B451B6.8060502@gmail.com> Message-ID: <49B458D8.4040502@fedoms.com> Hah! I always knew it! I'm not the only getting a headache from this. Thanks Joseph Joseph Fredette schrieb: > TaPL, iirc, is more about compilers and typesystems, and not > specifically about haskell. RWH will give you a cover of the basic > stuff and common data types. The Typeclassopedia will cover all the > major typeclasses (google search ought to reveal it's super-secret > location). Otherwise, the wikibook, the wiki, and the haskell docs are > a good place to look to get a handle on the myriad library datatypes > provided. > > /Joe > > G??nther Schmidt wrote: >> Hi all, >> >> I'm trying to catch up with all the wonderful Haskell Types, classes, >> Abstract Data Types, Algebraic Data Types, Types that give peoples >> headaches and all the other, deeper stuff I have been happily putting >> off. >> >> Now to look smart I have a bookshelf full of books for smart people >> and TaPL is amoung them. >> >> Should I try that or will RWH teach me enough to get by? >> >> G?nther >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From bjorn.buckwalter at gmail.com Sun Mar 8 20:34:29 2009 From: bjorn.buckwalter at gmail.com (Bjorn Buckwalter) Date: Sun Mar 8 20:22:57 2009 Subject: [Haskell-cafe] Parsing floating point numbers Message-ID: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> Hi all, What is your preferred method of parsing floating point numbers (from String to Float/Double)? Parsec it seems only does positive floats out of the box and PolyParse requires the float to be on scientific form (exponential). While I've worked around these shortcomings in the past I feel that I am reinventing the wheel as surely I am not the only to run into these limitations. How do you parse your floats? Can you recommend a parsing library that handles them solidly? (For my current needs the formats accepted by "read" are sufficient, but I want reasonable error handling (Maybe or Either) instead of an exception on bad inputs.) Thanks, Bjorn Buckwalter From jonathanccast at fastmail.fm Sun Mar 8 20:39:15 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Mar 8 20:27:39 2009 Subject: [Haskell-cafe] Parsing floating point numbers In-Reply-To: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> References: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> Message-ID: <1236559155.6249.0.camel@jonathans-macbook> On Sun, 2009-03-08 at 19:34 -0500, Bjorn Buckwalter wrote: > Hi all, > > What is your preferred method of parsing floating point numbers (from > String to Float/Double)? Parsec it seems only does positive floats out > of the box and PolyParse requires the float to be on scientific form > (exponential). While I've worked around these shortcomings in the past > I feel that I am reinventing the wheel as surely I am not the only to > run into these limitations. How do you parse your floats? Can you > recommend a parsing library that handles them solidly? > > (For my current needs the formats accepted by "read" are sufficient, > but I want reasonable error handling (Maybe or Either) instead of an > exception on bad inputs.) fmap fst . listToMaybe . reads jcc From claus.reinke at talk21.com Sun Mar 8 20:47:54 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sun Mar 8 20:36:23 2009 Subject: [Haskell-cafe] bytestring vs. uvector References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> Message-ID: <7728C45CDA54457FA0579612FFDD77B0@cr3lt> >> uvector is, if my memory serves me correctly, a fork of the vector library. >> It uses modern stream fusion, but is under active development and is a >> little scary. I'm a little unclear on the exact difference between uvector >> and vector. Both use arrays that are not pinned, so they can't be readily >> used with foreign code. If you want to use either library, understand that >> you're embarking on a bracing adventure. > > vector and uvector are roughly based on the same technology; uvector > is - as far as I remember - a fork of some of the old DPH code which > uses stream fusion which Don cleaned up and worked on (and it's proven > pretty useful, and people are still hacking on it.) > > vector however, has the notion of 'recycling arrays' when it does > array operations. The technique is in fact quite similar to stream > fusion. Roman L. built this from scratch I think, so it's quite a bit > more unused and less stable than even uvector is maybe, but I suppose > you could say it's kind of a superset of uvector. Hopefully though > it should mature a little, and the plans are to have the technology > from both of these folded into the Data Parallel Haskell project so we > get fast array operations+automatic parallelisation. > > For info, see Roman's paper, 'Recycle your arrays!' > > http://www.cse.unsw.edu.au/~rl/publications/recycling.html Given the close relationship between uvector and vector, it would be very helpful if both package descriptions on hackage could point to a common haskell wiki page, starting out with the text and link above, plus a link to the stream fusion paper (I hadn't been aware that vector incorporates the recycling work, and had often wondered about the precise relationship between those two packages). Apart from saving others from similar confusion, that would also provide a place to record experience with those two alternatives. Btw, have any of the Haskell array optimization researchers considered fixpoints yet? Both fusion and recycling are based on rewrite rules of the kind "in . out --> id". Now, given a loop like this: loop a = if c a then loop (out (action (in a))) else a loop a these rules don't apply. Unrolling the loop a fixed number of times would enable some rule applications, but still some would remain in the loop body. But with a little rewriting loop a = if c a then loop (out (action (in a))) else out (id (in a)) loop a loop a = if c a then loop (out (action (in a))) else out (id (in a)) (if c a then loop (out (action (in a))) else out (id (in a))) we can now push the out into the next iteration of the loop or, if there is no next iteration, into the loop epilogue loop a = if c (out a) then loop (action (in (out a))) else id (in (out a)) out (if c a then loop (action (in a)) else a) making the rewrite rule applicable loop a = if c (out a) then loop (action a) else id a out (if c a then loop (action (in a)) else a) leading (modulo bugs, omissions, and oversights;-) to a fused/ recycled loop body, with potentially substantial benefit. Claus From felipe.lessa at gmail.com Sun Mar 8 20:50:18 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Mar 8 20:38:40 2009 Subject: [Haskell-cafe] Parsing floating point numbers In-Reply-To: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> References: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> Message-ID: On Sun, Mar 8, 2009 at 9:34 PM, Bjorn Buckwalter wrote: > (For my current needs the formats accepted by "read" are sufficient, > but I want reasonable error handling (Maybe or Either) instead of an > exception on bad inputs.) Why not readM :: (Monad m, Read a) => String -> m a readM str = case [x | (x,"") <- readsPrec 0 str] of [x] -> return x _ -> fail "readM: failed" Also, I remember seeing this function exported by some module, but I don't remember where. HTH, -- Felipe. From duncan.coutts at worc.ox.ac.uk Sun Mar 8 20:57:47 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 8 20:46:16 2009 Subject: [Haskell-cafe] cabal-install 0.6.2 does not bootstrap with ghc-6.10.1 debian distribution In-Reply-To: <49B447AE.4070305@gmail.com> References: <1236511083.22402.286.camel@localhost> <49B447AE.4070305@gmail.com> Message-ID: <1236560267.22402.314.camel@localhost> On Sun, 2009-03-08 at 15:33 -0700, Ahn, Ki Yung wrote: > I am using Debian unstable. > > The version of GHC debian package is 6.10.1+dfsg1-13, > and installed Haskell libraries (debian packages) are: > > kyagrd@kyavaio:~$ ghc-pkg list > /usr/lib/ghc-6.10.1/./package.conf: > packedstring-0.1.0.1, parallel-1.1.0.0, parsec-3.0.0, > Bootstrap fails like this: > > kyagrd@kyavaio:~/tmp/cabal-install-0.6.2$ sh bootstrap.sh > Checking installed packages for ghc-6.10.1... > > The Haskell package 'parsec' is required but it is not installed. > If you are using a ghc package provided by your operating system > then install the corresponding packages for 'parsec' and 'network'. > If you built ghc from source with only the core libraries then you > should install these extra packages. You can get them from hackage. > > Error during cabal-install bootstrap: > The Haskell package 'parsec' is required but it is not installed. What it doesn't say is that it's looking for parsec version 2. > P.S. Note, parsec and network are installed in the system using debian > distribution packages. For some reason the debian package maintainers decided to build everything against parsec 3 rather than parsec 2 which everyone else is using. Personally I think this was not a wise decision. Indeed it may be a problem when it comes to supporting the Haskell platform because the first version will use parsec 2. Any major parsec version transition in the Haskell platform will be made by a community decision process. What I've done is dropped the check for parsec in the bootstrap.sh. The only reason we're looking for parsec is because it's needed by network which we also need. So it's not strictly necessary that we check for it. Duncan From claus.reinke at talk21.com Sun Mar 8 21:10:44 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sun Mar 8 20:59:13 2009 Subject: [Haskell-cafe] Looking for literature References: Message-ID: <9B12739D04074C1F930230910A18F57B@cr3lt> >I'm trying to catch up with all the wonderful Haskell Types, classes, >Abstract Data Types, Algebraic Data Types, Types that give peoples >headaches and all the other, deeper stuff I have been happily putting off. Hmm, do we need more pragmas?-) {-# LANGUAGE TypesThatGivePeopleHeadaches #-} {-# LANGUAGE DeeperStuffIHaveBeenHappilyPuttingOff #-} Anyway, a good source of headaches are the research paper links collected at haskell.org: http://www.haskell.org/haskellwiki/Research_papers Given your interests, in particular: http://www.haskell.org/haskellwiki/Research_papers/Type_systems http://www.haskell.org/haskellwiki/Research_papers/Data_structures Claus From dons at galois.com Sun Mar 8 21:26:16 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 8 21:15:32 2009 Subject: [Haskell-cafe] Looking for literature In-Reply-To: <9B12739D04074C1F930230910A18F57B@cr3lt> References: <9B12739D04074C1F930230910A18F57B@cr3lt> Message-ID: <20090309012616.GA24930@whirlpool.galois.com> claus.reinke: >> I'm trying to catch up with all the wonderful Haskell Types, classes, >> Abstract Data Types, Algebraic Data Types, Types that give peoples >> headaches and all the other, deeper stuff I have been happily putting >> off. > > Hmm, do we need more pragmas?-) > > {-# LANGUAGE TypesThatGivePeopleHeadaches #-} > {-# LANGUAGE DeeperStuffIHaveBeenHappilyPuttingOff #-} > > Anyway, a good source of headaches are the research paper > links collected at haskell.org: > > http://www.haskell.org/haskellwiki/Research_papers > > Given your interests, in particular: > > http://www.haskell.org/haskellwiki/Research_papers/Type_systems > http://www.haskell.org/haskellwiki/Research_papers/Data_structures Also, given the ICFP deadline was this week, I encourage authors to link to their preprints in the appropriate categories, and help share the knowledge. -- Don From pumpkingod at gmail.com Sun Mar 8 22:05:53 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Sun Mar 8 21:54:16 2009 Subject: [Haskell-cafe] Parsing floating point numbers In-Reply-To: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> References: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> Message-ID: If you're working with ByteStrings, http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-lexing might help. Cheers, Dan On Sun, Mar 8, 2009 at 8:34 PM, Bjorn Buckwalter wrote: > Hi all, > > What is your preferred method of parsing floating point numbers (from > String to Float/Double)? Parsec it seems only does positive floats out > of the box and PolyParse requires the float to be on scientific form > (exponential). While I've worked around these shortcomings in the past > I feel that I am reinventing the wheel as surely I am not the only to > run into these limitations. How do you parse your floats? Can you > recommend a parsing library that handles them solidly? > > (For my current needs the formats accepted by "read" are sufficient, > but I want reasonable error handling (Maybe or Either) instead of an > exception on bad inputs.) > > Thanks, > Bjorn Buckwalter > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ok at cs.otago.ac.nz Sun Mar 8 22:07:17 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Mar 8 21:55:59 2009 Subject: [Haskell-cafe] Purely Functional Data Structures In-Reply-To: <49B2FF8A.50501@fedoms.com> References: <20090307225945.GM19807@whirlpool.galois.com> <49B2FF8A.50501@fedoms.com> Message-ID: On 8 Mar 2009, at 12:13 pm, G?uenther Schmidt wrote: > Hi Don, > > damn, that was quick! > > And thx, I'll look into that. The reading it in wasn't much of a > problem, I had been able to use MS-ODBC for that, there's a driver > for ODBC files. The problem is more the type of data structure I'd > be reading it into. In SQL I would have the data indexed by several > different columns, if I use maps I'd only have one key, so if I need > to lookup data in the map by a value that is not the key the lookups > will become quite expensive. > > Any suggestions, what do you do in these cases? Who said you could only have one map? You can have as many as you want: primary :: Map Key1 (Maybe Whole_Record) secondary :: Map Key2 [Whole_Record] ... Adding the same record to both maps won't copy the record. From wagner.andrew at gmail.com Sun Mar 8 22:11:12 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Sun Mar 8 21:59:35 2009 Subject: [Haskell-cafe] Purely Functional Data Structures In-Reply-To: <87hc24u8oa.wl%jeremy@n-heptane.com> References: <20090307225945.GM19807@whirlpool.galois.com> <49B2FF8A.50501@fedoms.com> <87hc24u8oa.wl%jeremy@n-heptane.com> Message-ID: So...is there some reason this is in the hApps package? On Sat, Mar 7, 2009 at 9:04 PM, Jeremy Shaw wrote: > At Sun, 08 Mar 2009 00:13:14 +0100, > G?uenther Schmidt wrote: > > In SQL I would have the data indexed by several > > different columns, if I use maps I'd only have one key, so if I need to > > lookup data in the map by a value that is not the key the lookups will > > become quite expensive. > > happstack-ixset offers a data-type similar to Map except that you can > have multiple keys. You can even have keys that are calculated from > the data but don't actually appear in the data itself. For, example, > if your ixset just contains Strings, one of the keys could be the > length of the String. > > happstack-ixset (and its dependencies) also offers compact > serialization/deserialization of the ixset to disk, data migration > options, and a smattering of other features that may or may not be > useful to you. > > While happstack-ixset is built to work with happstack, it is does not > depend on the happstack http server or persistent store layer, so it > should be useful even if you are not being an application server. > > - jeremy > _______________________________________________ > 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/20090308/bf55782a/attachment.htm From mithrandi at mithrandi.net Sun Mar 8 22:12:41 2009 From: mithrandi at mithrandi.net (mithrandi@mithrandi.net) Date: Sun Mar 8 22:01:30 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <49B455DA.6030907@gmail.com> Message-ID: 2009/3/9 Joseph Fredette > > Another alternative, perhaps we rank the first n we care about, and regard the rest as ranked as low as possible? > > Since Condorcet allows ties, it should work -- I don't know if it _technically_ allows for skipping ranks, though, but I imagine it would still work... Only the relative ranking of the options in your ballot should matter; so there's really no such thing as "skipping" a rank. However, I am not familiar with the CIVS implementation specifically, so don't take my assertion as authoritative. -- mithrandi, i Ainil en-Balandor, a faer Ambar -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 270 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/8da17751/signature.bin From wren at freegeek.org Sun Mar 8 22:22:04 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Mar 8 22:10:28 2009 Subject: [Haskell-cafe] Cabal and package changelog In-Reply-To: <49B4104C.10401@libero.it> References: <49B3A858.8040503@libero.it> <1236535917.22402.306.camel@localhost> <49B4104C.10401@libero.it> Message-ID: <49B47D4C.5040504@freegeek.org> Manlio Perillo wrote: > Duncan Coutts ha scritto: > > On Sun, 2009-03-08 at 10:00 -0400, Gwern Branwen wrote: > > > http://hackage.haskell.org/trac/hackage/ticket/244 > > > http://hackage.haskell.org/trac/hackage/ticket/299 > > > > Thanks Gwern. Yes, we're looking for a volunteer to work on implementing > > this. > > One question is what the changelog format should be? Or should it just > > be uninterpreted text? One suggestion was for Hackage and the RSS feed > > to display the diff between the current and previous version of the > > changelog. Or perhaps we can do both, diff it and parse the result as > > haddock markup or something. > > Personally, I find a format like: > http://divmod.org/trac/browser/trunk/Nevow/NEWS.txt > simple, compact and flexible. Nice, simple, and to the point. It reminds me a lot of (a stripped down version of) YAML. If we invent a new format, using YAML as the syntax would make it easy to manipulate since there are already tools and libraries out there for that. > GNU Changelog format is probably an overkill, since nowadays we have > good revision control systems. > > However GNU Changelog format *may* be supported (perhaps the changelog > format can be specified in a Cabal property). Like YAML, GNU Changelog has enough history to have a large suite of tools for manipulating the format. It's a bit heavy-handed in this day and age, but many VCSes can generate it automatically. As a developer, one of my criteria would be to keep it as lightweight as possible (though more formal than raw text). The more work changelogs take, the less likely they are to be maintained/accurate. As a UI issue, I would amend the proposal in ticket #244. Because of the way Darcs works around tag boundaries, I've often been lax about tagging more frequently than major versions. It'd be nicer to open up the pending changelog amendment in $EDITOR so people can adjust it before publishing the sdist. (Perhaps with a flag to enable/disable this behavior for people who want more automated setups.) Also helpful would be a command to inject things into the changelog from outside the VCS, at times other than when publishing. This is helpful for when you realize a version control message omitted details about changes, but you can't change the patch, and you don't want to forget the details between now and when publishing the new sdist to Hackage. Essentially this means the tools should have a pending file for the changelog which can be freely modified outside of the system (with some in-system tracking so that importing the VCS log and editing it does the right thing when trying to import the VCS log again later). Actually, just having a tool to amend the pending file could be enough. Most VCSes have hooks for being able to run things before or after committing a patch. Thus, just have a tutorial on setting up the common VCSes to commit the same message to the changelog as to the version control. -- Live well, ~wren From wchogg at gmail.com Sun Mar 8 22:34:33 2009 From: wchogg at gmail.com (Creighton Hogg) Date: Sun Mar 8 22:22:55 2009 Subject: [Haskell-cafe] ANN : happs-tutorial 0.8 Message-ID: <814617240903081934q7187df57p3ef5163e4bec4a24@mail.gmail.com> Hello, I'd like to announce the release of the happstack-0.2 compatible release of happs-tutorial on hackage and available for perusing on tutorial.happstack.com. A number of changes occurred in this release: * General cleanup of code for readability * Migration to the new Happstack.Server.SimpleHTTP api * Addition of a chapter on multimaster, the Spread Toolkit based system for syncing your applications across multiple Happstack instances. * Revised chapters on introducing Happstack.Server and Happstack.State, with an emphasis on simple, well-commented examples showing the orthogonality of these separate libraries. * Minor bug fixes Cheers, Creighton From wren at freegeek.org Sun Mar 8 22:51:09 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Mar 8 22:39:33 2009 Subject: [Haskell-cafe] STG's? [was: I want to write a compiler] In-Reply-To: <9810b81b0903081616g1f15335fsb6acd9f2946cccb@mail.gmail.com> References: <9810b81b0903081616g1f15335fsb6acd9f2946cccb@mail.gmail.com> Message-ID: <49B4841D.7050204@freegeek.org> Rick R wrote: > Where can I find more information on STGs? Google search doesn't bring up > anything too enlightening. > > My curiosity was piqued by http://www.cs.chalmers.se/~gedell/ssc/index.html. > Of course it doesn't indicate how these should be built or the format. Perhaps http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.18.5865 -- Live well, ~wren From wirtwolff at gmail.com Sun Mar 8 23:38:01 2009 From: wirtwolff at gmail.com (Wirt Wolff) Date: Sun Mar 8 23:26:32 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <49B4528F.4060306@semantic.org> References: <49B4528F.4060306@semantic.org> Message-ID: <1236568944-sup-3137@chigamba> Excerpts from Ashley Yakeley's message of Sun Mar 08 17:19:43 -0600 2009: > Eelco Lempsink wrote: > > > The list with options can be found here (for now): > > http://community.haskell.org/~eelco/poll.html Notice that some (very) > > similar logos are grouped as one option (thanks to Ian Lynagh) All > > submissions compete, so that still makes more than a 100 options! > > > > The voting system we'll use is the Condorcet Internet Voting System > > (http://www.cs.cornell.edu/andru/civs.html). > > I'm currently liking > > .... > 61 (specifically, the second image) Forgive my asking for even more options here, (plenty of paint to cover the shed as it is), but regarding 61, a couple of those are in my top few, while the rest rank considerably lower. Would it be possible to distinguish them like the ones in 30? No worries if not, seems there may need to be some refinement process after this round anyway. -- wmw From deliverable at gmail.com Sun Mar 8 23:44:13 2009 From: deliverable at gmail.com (Alexy Khrabrov) Date: Sun Mar 8 23:32:35 2009 Subject: [Haskell-cafe] where does ghc specify ar options Message-ID: <7c737f300903082044x6e5b881at7af3a274fc17f256@mail.gmail.com> When bootstrapping cabal-install 0.6.2 on Mac OSX Leopard (Intel), I get a problem when linking: Linking dist/build/cabal/cabal ... ld: in /private/var/folders/mw/mwJSf7ErEa4w8nWyKyyqD++++TY/-Tmp-/zlib-0.5.0.0/dist/build/libHSzlib-0.5.0.0.a, archive has no table of contents This had happened with other ar'chives on my Mac before where it hadn't for some others. In all cases the fix was to make sure ranlib is run on the archive in question, or s is passed to ar during the creation. I have the latest XCode 312m gcc build 5490, and ghc 6.10.1 from MacPorts. In order to ensure ar cr becomes ar crs, I need to find out where in the ghc build process is it known how to create .a files? Where can an "ar cr" be changed to "ar crs" on a system-wide ghc build basis? Cheers, Alexy From magicloud.magiclouds at gmail.com Sun Mar 8 23:45:06 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Sun Mar 8 23:33:29 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: <200903051442.54603.alexey.skladnoy@gmail.com> References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> <3bd412d40903042206xf635b00ocb2ab0f222e40159@mail.gmail.com> <3bd412d40903042245rc971e77gd668e5f292743550@mail.gmail.com> <200903051442.54603.alexey.skladnoy@gmail.com> Message-ID: <3bd412d40903082045w39fa9a67hc9443b83cb5c808c@mail.gmail.com> Here is my window, seems right... but cannot get a gap.... WM_HINTS(WM_HINTS): Client accepts input or input focus: True Initial state is Normal State. window id # of group leader: 0x1800001 _NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 25165829 _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DOCK _NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1800004 WM_CLIENT_LEADER(WINDOW): window id # 0x1800001 _NET_WM_PID(CARDINAL) = 16671 WM_LOCALE_NAME(STRING) = "zh_CN.UTF-8" WM_CLIENT_MACHINE(STRING) = "shidaw.desktop.amazon.com" WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified minimum size: 162 by 54 window gravity: NorthWest WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST WM_CLASS(STRING) = "sideBar.rb", "SideBar.rb" WM_ICON_NAME(STRING) = "sideBar.rb" _NET_WM_ICON_NAME(UTF8_STRING) = 0x73, 0x69, 0x64, 0x65, 0x42, 0x61, 0x72, 0x2e, 0x72, 0x62 WM_NAME(STRING) = "sideBar.rb" _NET_WM_NAME(UTF8_STRING) = 0x73, 0x69, 0x64, 0x65, 0x42, 0x61, 0x72, 0x2e, 0x72, 0x62 On Thu, Mar 5, 2009 at 7:42 PM, Khudyakov Alexey wrote: > On Thursday 05 March 2009 09:45:51 Magicloud Magiclouds wrote: >> I am confused. Code like this works in other WM, except xmonad. > > You code does not set _NET_WM_STRUT property. And because of that xmonad > doesn't treat it specifically. You can inspect you window properties using > `xprop' utility. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- ??????? ??????? From rl at cse.unsw.edu.au Mon Mar 9 00:37:02 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Mon Mar 9 00:25:31 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <7728C45CDA54457FA0579612FFDD77B0@cr3lt> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> Message-ID: On 09/03/2009, at 11:47, Claus Reinke wrote: > Btw, have any of the Haskell array optimization researchers > considered fixpoints yet? This, for instance, is a very nice paper: http://www.pllab.riec.tohoku.ac.jp/~ohori/research/OhoriSasanoPOPL07.pdf However, in the context of high-performance array programming explicit recursion is bad because it is very hard if not impossible to parallelise automatically except in fairly trivial cases. And if your array program is not parallelisable then you don't really care about performance all that much :-) Roman From DekuDekuplex at Yahoo.com Mon Mar 9 02:13:53 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Mar 9 02:02:24 2009 Subject: [Haskell-cafe] Re: Logo Preferences References: <49B4528F.4060306@semantic.org> Message-ID: <0dc9r4daiu6l3desr6br2qa2l6n2sgmgti@4ax.com> On Sun, 08 Mar 2009 16:19:43 -0700, Ashley Yakeley wrote: >[...] > >I'm currently liking > >30 (specifically, 30.7) >58 >61 (specifically, the second image) >62 It would be nice to be able to specify a specific member image of a group of images; for example, the second image in group 61. Currently, none of the member images in group 61 is individually numbered; will we be able to choose a specific image from this kind of group? Also, it might be nice to have some more variations for group 61, specifically; for example, it may be nice to be able to select the text for the second image, combined with the snowflake symbol for the lower-right corner logo of the leftmost rectangle of images: Although the font for the two is identical, the spacing is subtly wider in the former. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From allbery at ece.cmu.edu Mon Mar 9 02:29:53 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Mar 9 02:18:19 2009 Subject: [Haskell-cafe] How to make a dock window for xmonad using gtk2hs? In-Reply-To: <3bd412d40903082045w39fa9a67hc9443b83cb5c808c@mail.gmail.com> References: <3bd412d40903041840y2b909082obcaa9fb0fa8ad379@mail.gmail.com> <3bd412d40903042206xf635b00ocb2ab0f222e40159@mail.gmail.com> <3bd412d40903042245rc971e77gd668e5f292743550@mail.gmail.com> <200903051442.54603.alexey.skladnoy@gmail.com> <3bd412d40903082045w39fa9a67hc9443b83cb5c808c@mail.gmail.com> Message-ID: <024F4945-668D-4F70-88A0-B06B11FC2E51@ece.cmu.edu> On 2009 Mar 8, at 23:45, Magicloud Magiclouds wrote: > Here is my window, seems right... but cannot get a gap.... Once again: where's the _NET_WM_STRUT? I've looked through your properties, but none of them is _NET_WM_STRUT. Non-tiling window managers may dock the window in a default fashion because of _NET_WM_WINDOW_TYPE, but xmonad needs to know how much space to reserve for it. > WM_HINTS(WM_HINTS): > Client accepts input or input focus: True > Initial state is Normal State. > window id # of group leader: 0x1800001 > _NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 25165829 > _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DOCK > _NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1800004 > WM_CLIENT_LEADER(WINDOW): window id # 0x1800001 > _NET_WM_PID(CARDINAL) = 16671 > WM_LOCALE_NAME(STRING) = "zh_CN.UTF-8" > WM_CLIENT_MACHINE(STRING) = "shidaw.desktop.amazon.com" > WM_NORMAL_HINTS(WM_SIZE_HINTS): > program specified minimum size: 162 by 54 > window gravity: NorthWest > WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, > _NET_WM_PING, _NET_WM_SYNC_REQUEST > WM_CLASS(STRING) = "sideBar.rb", "SideBar.rb" > WM_ICON_NAME(STRING) = "sideBar.rb" > _NET_WM_ICON_NAME(UTF8_STRING) = 0x73, 0x69, 0x64, 0x65, 0x42, 0x61, > 0x72, 0x2e, 0x72, 0x62 > WM_NAME(STRING) = "sideBar.rb" > _NET_WM_NAME(UTF8_STRING) = 0x73, 0x69, 0x64, 0x65, 0x42, 0x61, 0x72, > 0x2e, 0x72, 0x62 -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/a0ea5f91/PGP.bin From johan.tibell at gmail.com Mon Mar 9 04:40:33 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon Mar 9 04:28:58 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <49B4528F.4060306@semantic.org> References: <49B4528F.4060306@semantic.org> Message-ID: <90889fe70903090140ge55d46h992386235d4d7cd2@mail.gmail.com> On Mon, Mar 9, 2009 at 12:19 AM, Ashley Yakeley wrote: > Eelco Lempsink wrote: > >> The list with options can be found here (for now): >> http://community.haskell.org/~eelco/poll.html ?Notice that some (very) >> similar logos are grouped as one option (thanks to Ian Lynagh) All >> submissions compete, so that still makes more than a 100 options! Lots of nice submissions! Here are some thing that are worth keeping in mind when voting. How does the logo work: * on different backgrounds (in particular: white), * at small sizes (on file system icons, 16x16 pixels browser favicon, etc), and * in different cultures (i.e. does it contain e.g. a pun that many people won't understand). Cheers, Johan From lemming at henning-thielemann.de Mon Mar 9 05:44:39 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 9 05:33:05 2009 Subject: [Haskell-cafe] Parsing floating point numbers In-Reply-To: References: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> Message-ID: On Sun, 8 Mar 2009, Felipe Lessa wrote: > On Sun, Mar 8, 2009 at 9:34 PM, Bjorn Buckwalter > wrote: >> (For my current needs the formats accepted by "read" are sufficient, >> but I want reasonable error handling (Maybe or Either) instead of an >> exception on bad inputs.) > > Why not > > readM :: (Monad m, Read a) => String -> m a > readM str = case [x | (x,"") <- readsPrec 0 str] of > [x] -> return x > _ -> fail "readM: failed" > > Also, I remember seeing this function exported by some module, but I > don't remember where. http://www.haskell.org/pipermail/libraries/2008-February/009202.html http://www.haskell.org/pipermail/haskell-cafe/2008-June/044590.html Although maybeRead was proposed, I cannot find it: http://hackage.haskell.org/packages/archive/base/4.0.0.0/doc/html/Text-Read.html (Btw. I find it really great, that now the 'base' package documentation can be found on Hackage!) From lemming at henning-thielemann.de Mon Mar 9 05:53:23 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 9 05:41:45 2009 Subject: [Haskell-cafe] Purely Functional Data Structures In-Reply-To: References: Message-ID: On Sat, 7 Mar 2009, G??nther Schmidt wrote: > is the above mentioned book still *the* authority on the subject? > > I bought the book, read about 10 pages and then put it back on the shelf. Um. > In my app I have to deal with 4 csv files, each between 5 - 10 mb, and some > static data. > > I had put all that data into an Sqlite3 database and used SQL on it. But, as > the requirements keep changing the SQL becomes a bit messy. I guess we've all > had that experience. > > So I'm wondering if I will find clues in this book how to do my querying and > handling of moderately large data in a more haskellish way and be able to > drop the SQL. If this CSV processing is of pipe style, you may want to try a lazy CSV parser and formatter: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/spreadsheet-0.1 From lemming at henning-thielemann.de Mon Mar 9 06:07:20 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 9 05:55:46 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> Message-ID: On Sat, 7 Mar 2009, Bryan O'Sullivan wrote: > On Sat, Mar 7, 2009 at 10:23 PM, Alexander Dunlap wrote: > > Hi all, > > For a while now, we have had Data.ByteString[.Lazy][.Char8] for our > fast strings. Now we also have Data.Text, which does the same for > Unicode. These seem to be the standard for dealing with lists of bytes > and characters. > > Now we also have the storablevector, uvector, and vector packages. > These seem to be also useful for unpacked data, *including* Char and > Word8 values. > > What is the difference between bytestring and these new "fast array" > libraries? Are the latter just generalizations of the former? > > storablevector is not mature (I'm not even sure if it's actually used) and is a derivative of > an old version of the bytestring library, and so has similar characteristics for interacting > with foreign code. It contains some old fusion code that is sketchy in nature and somewhat > likely to be broken. I'm not sure I would recommend using this library. As maintainer of storablevector I can tell that I use it for realtime audio signal processing. Indeed, I expected more of the fusion mechanism than it can do. It is hard to get correct fusion on lazy storablevectors at all, because of non-matching chunk sizes. Thus I didn't follow that path anymore. For audio signal processing I use a list type, like that of the Streams approach. When you convert those streams into storable vectors you get efficient inner loops without any fusion. It would certainly be worth to fuse with those Stream lists, but I haven't tried that so far. From sebastian.sylvan at gmail.com Mon Mar 9 06:08:50 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Mar 9 05:57:12 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <49B4528F.4060306@semantic.org> References: <49B4528F.4060306@semantic.org> Message-ID: <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> On Sun, Mar 8, 2009 at 11:19 PM, Ashley Yakeley wrote: > Eelco Lempsink wrote: > > The list with options can be found here (for now): >> http://community.haskell.org/~eelco/poll.html Notice that some (very) >> similar logos are grouped as one option (thanks to Ian Lynagh) All >> submissions compete, so that still makes more than a 100 options! >> >> The voting system we'll use is the Condorcet Internet Voting System ( >> http://www.cs.cornell.edu/andru/civs.html). >> > > So ranking all 100+ items on the Condorcet ballot is a bit of a daunting > task. However, if we get a rough idea of the favourites, we can each cut > down a bit on the work. > > For instance, suppose 82 and 93 are very popular. You might not like either > of them, but it's worth ranking them on your ballot (after the ones you do > like) if you have a preference between them. But there's less need to rank > the ones no-one likes. I'm pretty sure this is precisely how the system works. You bring the ones you care about to the top and rank them, and everything else shares a rank at the bottom (or you could pick a few of those that you really dislike and put them even lower than the default rank). But the point is that you shouldn't need to rank every single logo, just the ones you care about and then you leave the rest at the default rank. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/db536411/attachment.htm From lemming at henning-thielemann.de Mon Mar 9 06:12:29 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 9 06:00:52 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <7728C45CDA54457FA0579612FFDD77B0@cr3lt> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> Message-ID: On Mon, 9 Mar 2009, Claus Reinke wrote: > Given the close relationship between uvector and vector, it would > be very helpful if both package descriptions on hackage could point to a > common haskell wiki page, starting out with the text > and link above, plus a link to the stream fusion paper (I hadn't been aware > that vector incorporates the recycling work, and had often wondered about the > precise relationship between those > two packages). Apart from saving others from similar confusion, > that would also provide a place to record experience with those two > alternatives. I have at least started a page which mentions the existing alternatives: http://www.haskell.org/haskellwiki/Storable_Vector From bulat.ziganshin at gmail.com Mon Mar 9 06:30:16 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 9 06:19:03 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> Message-ID: <427713624.20090309133016@gmail.com> Hello Sebastian, Monday, March 9, 2009, 1:08:50 PM, you wrote: i think we should make 2-stage voting, like in F1 after 1st stage we will know which logos are most popular and therefore are real candidates, so we can select among them > On Sun, Mar 8, 2009 at 11:19 PM, Ashley Yakeley wrote: > > Eelco Lempsink wrote: > > The list with options can be found here (for now): > http://community.haskell.org/~eelco/poll.html ?Notice that some > (very) similar logos are grouped as one option (thanks to Ian > Lynagh) All submissions compete, so that still makes more than a 100 options! > > The voting system we'll use is the Condorcet Internet Voting System > (http://www.cs.cornell.edu/andru/civs.html). > So ranking all 100+ items on the Condorcet ballot is a bit of a > daunting task. However, if we get a rough idea of the favourites, we > can each cut down a bit on the work. > > For instance, suppose 82 and 93 are very popular. You might not > like either of them, but it's worth ranking them on your ballot > (after the ones you do like) if you have a preference between them. > But there's less need to rank the ones no-one likes. > > ? > > I'm pretty sure this is precisely how the system works. You bring > the ones you care about to the top and rank them, and everything > else shares a rank at the bottom (or you could pick a few of those > that you really dislike and put them even lower than the default > rank).?But the point is that you shouldn't need to rank every single > logo, just the ones you care about and then you leave the rest at the default rank. > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lemming at henning-thielemann.de Mon Mar 9 06:41:47 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 9 06:30:57 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <427713624.20090309133016@gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> <427713624.20090309133016@gmail.com> Message-ID: On Mon, 9 Mar 2009, Bulat Ziganshin wrote: > Hello Sebastian, > > Monday, March 9, 2009, 1:08:50 PM, you wrote: > > i think we should make 2-stage voting, like in F1 > > after 1st stage we will know which logos are most popular and > therefore are real candidates, so we can select among them Sounds reasonable, although I thought that those advanced voting systems are also intended for avoiding multiple elections. Then again, if both elections lead to the same ranking at the top, and especially yield the same top candidate, then this proves the soundness of the method. On the other hand, a dictatorship would also satisfy this property. Yes, I know, there was a Nobel Prize about that ... From Malcolm.Wallace at cs.york.ac.uk Mon Mar 9 06:45:01 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Mar 9 06:36:34 2009 Subject: [Haskell-cafe] Parsing floating point numbers In-Reply-To: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> References: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> Message-ID: <20090309104501.24f646c9.Malcolm.Wallace@cs.york.ac.uk> Bjorn Buckwalter wrote: > What is your preferred method of parsing floating point numbers (from > String to Float/Double)? Parsec it seems only does positive floats out > of the box and PolyParse requires the float to be on scientific form > (exponential). Thanks for the bug report. Polyparse is now fixed. New version (polyparse-1.3) available on Hackage. And my apologies. This was purely an oversight - the real-world use-case at the time I wrote the code for Text.Parse.parseFloat was entirely dependent on scientific notation, and I neglected the more usual case. For those looking for a template to implement textual float-parsing that is faster (or has better error messages) than the H'98 Read class, feel free to translate this code into your own parser combinator library of choice: http://www.cs.york.ac.uk/fp/polyparse/haddock/src/Text/Parse.html#parseFloat (Note that the actual instances of the Parse class for Float and Double use "parseSigned parseFloat" to deal with non-positive numbers.) Regards, Malcolm From sebastian.sylvan at gmail.com Mon Mar 9 06:52:27 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Mar 9 06:40:50 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <427713624.20090309133016@gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> <427713624.20090309133016@gmail.com> Message-ID: <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> On Mon, Mar 9, 2009 at 10:30 AM, Bulat Ziganshin wrote: > Hello Sebastian, > > Monday, March 9, 2009, 1:08:50 PM, you wrote: > > i think we should make 2-stage voting, like in F1 > > after 1st stage we will know which logos are most popular and > therefore are real candidates, so we can select among them > > One of the reasons condorcet voting is good is that this isn't needed. If everyone is consistent in which logos they prefer the results from second voting stage will be identical to just picking the condorcet voting from the first stage. The interface to the condorcet voting site is actually pretty good (try out one of the samples), so it's pretty easy to just "move to top" the ones you prefer and move the ones you dislike to the bottom. Then you can ignore the vast majority of "don't care" logos in the middle, and just fine tune your ranking at the top and bottom. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/227d3679/attachment.htm From sebastian.sylvan at gmail.com Mon Mar 9 06:53:38 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Mar 9 06:42:03 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> <427713624.20090309133016@gmail.com> <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> Message-ID: <3d96ac180903090353t110636cewbafc76a18979f590@mail.gmail.com> On Mon, Mar 9, 2009 at 10:52 AM, Sebastian Sylvan < sebastian.sylvan@gmail.com> wrote: > > > On Mon, Mar 9, 2009 at 10:30 AM, Bulat Ziganshin < > bulat.ziganshin@gmail.com> wrote: > >> Hello Sebastian, >> >> Monday, March 9, 2009, 1:08:50 PM, you wrote: >> >> i think we should make 2-stage voting, like in F1 >> >> after 1st stage we will know which logos are most popular and >> therefore are real candidates, so we can select among them >> >> > > One of the reasons condorcet voting is good is that this isn't needed. If > everyone is consistent in which logos they prefer the results from second > voting stage will be identical to just picking the condorcet voting from the > first stage. > "picking the condorcet winner" -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/d62731c8/attachment.htm From sebastian.sylvan at gmail.com Mon Mar 9 07:13:40 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Mar 9 07:02:02 2009 Subject: [Haskell-cafe] Re: Logo Preferences In-Reply-To: <0dc9r4daiu6l3desr6br2qa2l6n2sgmgti@4ax.com> References: <49B4528F.4060306@semantic.org> <0dc9r4daiu6l3desr6br2qa2l6n2sgmgti@4ax.com> Message-ID: <3d96ac180903090413l4b1c1a61kbba0c7cb3b13119c@mail.gmail.com> On Mon, Mar 9, 2009 at 6:13 AM, Benjamin L. Russell wrote: > On Sun, 08 Mar 2009 16:19:43 -0700, Ashley Yakeley > wrote: > > >[...] > > > >I'm currently liking > > > >30 (specifically, 30.7) > >58 > >61 (specifically, the second image) > >62 > > It would be nice to be able to specify a specific member image of a > group of images; for example, the second image in group 61. Currently, > none of the member images in group 61 is individually numbered; will > we be able to choose a specific image from this kind of group? Another reason condorcet voting is nice is that there is no need to group "similar" items together. Condorcet voting eliminates the "spoiler candidate" effect, so having N almost identical entries won't adversely affect that "group" (by spreading out the votes for that "group" among more "sub-entries" than for "groups" with only one entry in it). So actually I don't understand whey the logos are grouped at all, they could all just be listed individually, and then people can put them all at the same rank ("make tie" in the interface) if they don't care which one of the group they want, or they can differentiate between them if they like. You could possibly name them "60 a", "60 b" etc. to indicate that they are similar, but there's no reason not to allow people to differentiate between them if tehy so choose. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/26f8defd/attachment.htm From leather at cs.uu.nl Mon Mar 9 07:40:43 2009 From: leather at cs.uu.nl (Sean Leather) Date: Mon Mar 9 07:29:06 2009 Subject: [Haskell-cafe] Re: Logo Preferences In-Reply-To: <3d96ac180903090413l4b1c1a61kbba0c7cb3b13119c@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <0dc9r4daiu6l3desr6br2qa2l6n2sgmgti@4ax.com> <3d96ac180903090413l4b1c1a61kbba0c7cb3b13119c@mail.gmail.com> Message-ID: <3c6288ab0903090440v4e99b1aekf702f983051a3387@mail.gmail.com> > Another reason condorcet voting is nice is that there is no need to group > "similar" items together. Condorcet voting eliminates the "spoiler > candidate" effect, so having N almost identical entries won't adversely > affect that "group" (by spreading out the votes for that "group" among more > "sub-entries" than for "groups" with only one entry in it). > > So actually I don't understand whey the logos are grouped at all, they > could all just be listed individually, and then people can put them all at > the same rank ("make tie" in the interface) if they don't care which one of > the group they want, or they can differentiate between them if they like. > You could possibly name them "60 a", "60 b" etc. to indicate that they are > similar, but there's no reason not to allow people to differentiate between > them if tehy so choose. > I agree with this. There are some groupings that seem arbitrary. For example, a number of entries are grouped together, because they use the same graphic with different colors. I think color is an important part of a logo. (Many companies have a recognizable color scheme that covers more than just their logo. See sun.com, microsoft.com, etc.) It will be a major factor in my vote. I don't want to vote for a design that may have more than one possible outcome. As for what Johan said, it's definitely helpful to see logos on black and white and in different sizes. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/d0029c51/attachment.htm From igloo at earth.li Mon Mar 9 07:50:51 2009 From: igloo at earth.li (Ian Lynagh) Date: Mon Mar 9 07:39:13 2009 Subject: [Haskell-cafe] Re: Logo Preferences In-Reply-To: <3d96ac180903090413l4b1c1a61kbba0c7cb3b13119c@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <0dc9r4daiu6l3desr6br2qa2l6n2sgmgti@4ax.com> <3d96ac180903090413l4b1c1a61kbba0c7cb3b13119c@mail.gmail.com> Message-ID: <20090309115051.GA4250@matrix.chaos.earth.li> On Mon, Mar 09, 2009 at 11:13:40AM +0000, Sebastian Sylvan wrote: > > Another reason condorcet voting is nice is that there is no need to group > "similar" items together. I think the plan is that once a logo "class" is chosen, we'll have another vote for the actual colour scheme etc to be used, if applicable. Yes, we could have done this in a single vote, but then people would need to spend time creating 30 variants of each logo, and we'd be ranking 3000, rather than 100, options. Thanks Ian From john at repetae.net Mon Mar 9 08:28:25 2009 From: john at repetae.net (John Meacham) Date: Mon Mar 9 08:16:48 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <1236473265-sup-9021@existential.local> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> <1236473265-sup-9021@existential.local> Message-ID: <20090309122825.GB8842@sliver.repetae.net> On Sat, Mar 07, 2009 at 07:45:06PM -0600, Austin Seipp wrote: > (On that note, I am currently of the opinion that most of LHC's major > deficiencies, aside from a few parser bugs or some needed > optimizations, comes from the fact that compiling to C is currently > our only option; because of it, we have no exception handling or > proper garbage collection at all. As well, the runtime system is a > little needlessly 'clever' (if small and understandable) so it can > deal with that.) It would be interesting if you could revive the ghc back end I wrote for jhc in lhc. the code is still in the repository but was disabled a while ago, and I was just fretting over whether I should just delete it from the codebase as an interesting experiment. I mainly used it as a debugging aid once upon a time, but it was difficult to keep up to date with the C back end. I know it is sort of a silly back end, but it might be interesting. > Having dealt with GRIN as I work on LHC (when time now permits...) I > can say that it's a reasonable strategy and in practice it turns out > pretty well, but if you're not into optimizing the code, then STG > might be a better fit. I think a big deciding factor here would be the answer to one question "do you want to deal with unboxed values in your compiler internally?" As in, you plan on a lazy language, so, do you ever want to open up those thunks and deal with unboxed values in your compiler guts or do you want to treat them as abstract boxes to be evaluated by the runtime? if you do want to think about unboxed values, for optimization or other purposes, bite the bullet and go for something like GRIN as the back end and support unboxed values all the way through to the front end from the get go. If you really only want to support lazy thunks, go with one of the quasi virtual machine style implementations like STG. John -- John Meacham - ?repetae.net?john? From mad.one at gmail.com Mon Mar 9 10:25:58 2009 From: mad.one at gmail.com (Austin Seipp) Date: Mon Mar 9 10:14:21 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <20090309122825.GB8842@sliver.repetae.net> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> <1236473265-sup-9021@existential.local> <20090309122825.GB8842@sliver.repetae.net> Message-ID: <1236607231-sup-9517@existential.local> Excerpts from John Meacham's message of Mon Mar 09 07:28:25 -0500 2009: > On Sat, Mar 07, 2009 at 07:45:06PM -0600, Austin Seipp wrote: > > (On that note, I am currently of the opinion that most of LHC's major > > deficiencies, aside from a few parser bugs or some needed > > optimizations, comes from the fact that compiling to C is currently > > our only option; because of it, we have no exception handling or > > proper garbage collection at all. As well, the runtime system is a > > little needlessly 'clever' (if small and understandable) so it can > > deal with that.) > > It would be interesting if you could revive the ghc back end I wrote for > jhc in lhc. the code is still in the repository but was disabled a while > ago, and I was just fretting over whether I should just delete it from > the codebase as an interesting experiment. I mainly used it as a > debugging aid once upon a time, but it was difficult to keep up to date > with the C back end. I know it is sort of a silly back end, but it might > be interesting. Indeed, I stumbled upon it whilst looking at how unsafeCoerce worked (to find out it is super-duper-special and implemented as part of E.) I think it's actually pretty clever, and who knows, maybe it could be useful as at least a debugging aid. :) > I think a big deciding factor here would be the answer to one question > "do you want to deal with unboxed values in your compiler internally?" > As in, you plan on a lazy language, so, do you ever want to open up > those thunks and deal with unboxed values in your compiler guts or do > you want to treat them as abstract boxes to be evaluated by the runtime? > if you do want to think about unboxed values, for optimization or other > purposes, bite the bullet and go for something like GRIN as the back end > and support unboxed values all the way through to the front end from the > get go. If you really only want to support lazy thunks, go with one of > the quasi virtual machine style implementations like STG. > > John > This is a very good point I hadn't even thought about! Indeed, since GRIN represents thunks in a defunctionalized way - encoded as nodes - dealing with boxed/unboxed values becomes more of the compiler's job, since the nature of unboxed values etc. becomes more transparent. Since you bring this up, I figure this decision also had some influence on E in lhc/jhc, considering its type system is rich enough to distinguish values in whnf/boxed/unboxed etc.? Austin From anotheraddress at gmx.de Mon Mar 9 11:16:59 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Mon Mar 9 11:05:23 2009 Subject: [Haskell-cafe] Parsing floating point numbers In-Reply-To: References: <8b2a1a960903081734pfdd20b1wbcb724a9376e940e@mail.gmail.com> Message-ID: <200903091617.00274.anotheraddress@gmx.de> > Although maybeRead was proposed, I cannot find it: here's a replacement... http://hackage.haskell.org/packages/archive/safe/0.2/doc/html/Safe.html#v%3AreadMay Greetings, Daniel From bugfact at gmail.com Mon Mar 9 12:30:10 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Mar 9 12:18:44 2009 Subject: [Haskell-cafe] Partial pattern matching Message-ID: In Haskell, a data constructor can be used partially applied: data Pair a b = P a b f = P 1 however, I cannot do "partial pattern matching", e.g firstCoord (P x) = x does not work. I guess a very important reason must exist why this is the case? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/de9ca7f6/attachment.htm From wagner.andrew at gmail.com Mon Mar 9 12:33:06 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Mar 9 12:21:28 2009 Subject: [Haskell-cafe] Partial pattern matching In-Reply-To: References: Message-ID: The question is, is there some very important reason you can't do this? firstCoord (P x _) = x 2009/3/9 Peter Verswyvelen > In Haskell, a data constructor can be used partially applied: > data Pair a b = P a b > > f = P 1 > > however, I cannot do "partial pattern matching", e.g > > firstCoord (P x) = x > > does not work. > > I guess a very important reason must exist why this is the case? > > > > > > > _______________________________________________ > 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/20090309/2c51d0cd/attachment.htm From ekirpichov at gmail.com Mon Mar 9 12:33:39 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Mar 9 12:22:00 2009 Subject: [Haskell-cafe] Partial pattern matching In-Reply-To: References: Message-ID: <5e0214850903090933x3c1c5894x2ebf02273796736@mail.gmail.com> P x is indistinguishable neither in compile-time nor in run-time from the value \y -> P x y. And pattern matching and equality on functions is, of course, undecidable. 2009/3/9 Peter Verswyvelen : > In Haskell, a data constructor can be used partially applied: > data Pair a b = P a b > f = P 1 > however, I cannot do "partial pattern matching", e.g > firstCoord (P x) = x > does not work. > I guess a very important reason must exist why this is the case? > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From jochem at functor.nl Mon Mar 9 12:33:45 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Mon Mar 9 12:22:12 2009 Subject: [Haskell-cafe] Partial pattern matching In-Reply-To: References: Message-ID: <49B544E9.8090802@functor.nl> Peter Verswyvelen wrote: > In Haskell, a data constructor can be used partially applied: > data Pair a b = P a b > > f = P 1 > > however, I cannot do "partial pattern matching", e.g > > firstCoord (P x) = x > > does not work. > > I guess a very important reason must exist why this is the case? > What would be the type of firstCoord? Typically, you'd use data Pair a b = P { firstCoord :: a , secondCoord :: b } or firstCoord (P x _) = x secondCoord (P _ y) = y Regards, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From ekirpichov at gmail.com Mon Mar 9 12:37:17 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Mar 9 12:25:39 2009 Subject: [Haskell-cafe] Partial pattern matching In-Reply-To: <5e0214850903090933x3c1c5894x2ebf02273796736@mail.gmail.com> References: <5e0214850903090933x3c1c5894x2ebf02273796736@mail.gmail.com> Message-ID: <5e0214850903090937l14672396tb5bfe524ce58bc8b@mail.gmail.com> I mean, there is no way to write a firstCoord function so that it would work, for example, on '\y -> P 42 y' and yield 42. Except for this one: firstCoord proj = case (proj undefined) of P x y -> x However, this requires proj to be non-strict in its remaining argument. But this will actually work if you pass "P x" to it for some x, because it *is* non-strict in the remaining argument. 2009/3/9 Eugene Kirpichov : > P x is indistinguishable neither in compile-time nor in run-time from > the value \y -> P x y. > > And pattern matching and equality on functions is, of course, undecidable. > > 2009/3/9 Peter Verswyvelen : >> In Haskell, a data constructor can be used partially applied: >> data Pair a b = P a b >> f = P 1 >> however, I cannot do "partial pattern matching", e.g >> firstCoord (P x) = x >> does not work. >> I guess a very important reason must exist why this is the case? >> >> >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > -- Eugene Kirpichov Web IR developer, market.yandex.ru From daniel.is.fischer at web.de Mon Mar 9 12:43:24 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Mar 9 12:31:46 2009 Subject: [Haskell-cafe] Partial pattern matching In-Reply-To: References: Message-ID: <200903091743.24533.daniel.is.fischer@web.de> Am Montag, 9. M?rz 2009 17:30 schrieb Peter Verswyvelen: > In Haskell, a data constructor can be used partially applied: > data Pair a b = P a b > > f = P 1 > > however, I cannot do "partial pattern matching", e.g > > firstCoord (P x) = x > > does not work. > > I guess a very important reason must exist why this is the case? For one, the type. If x :: a, then P x :: b -> Pair a b, so we'd have firstCoord :: (b -> Pair a b) -> a But you can pattern-match only on constructors of the appropriate type. P is not a constructor of (b -> Pair a b) (function types don't have constructors), so you can't match on a partially applied constructor. From bugfact at gmail.com Mon Mar 9 12:57:04 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Mar 9 12:45:25 2009 Subject: [Haskell-cafe] Partial pattern matching In-Reply-To: <200903091743.24533.daniel.is.fischer@web.de> References: <200903091743.24533.daniel.is.fischer@web.de> Message-ID: Yes of course, P x is a function, and you can't pattern match against functions, I knew that. How silly of me, I could have guessed that myself. On Mon, Mar 9, 2009 at 5:43 PM, Daniel Fischer wrote: > Am Montag, 9. M?rz 2009 17:30 schrieb Peter Verswyvelen: > > In Haskell, a data constructor can be used partially applied: > > data Pair a b = P a b > > > > f = P 1 > > > > however, I cannot do "partial pattern matching", e.g > > > > firstCoord (P x) = x > > > > does not work. > > > > I guess a very important reason must exist why this is the case? > > For one, the type. If x :: a, then P x :: b -> Pair a b, so we'd have > > firstCoord :: (b -> Pair a b) -> a > > But you can pattern-match only on constructors of the appropriate type. P > is > not a constructor of (b -> Pair a b) (function types don't have > constructors), so you can't match on a partially applied constructor. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/470d48eb/attachment.htm From lrpalmer at gmail.com Mon Mar 9 13:26:20 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Mar 9 13:14:41 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> <427713624.20090309133016@gmail.com> <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> Message-ID: <7ca3f0160903091026j5bdc8a58o861c271d6638e6e0@mail.gmail.com> 2009/3/9 Sebastian Sylvan > > > On Mon, Mar 9, 2009 at 10:30 AM, Bulat Ziganshin < > bulat.ziganshin@gmail.com> wrote: > >> Hello Sebastian, >> >> Monday, March 9, 2009, 1:08:50 PM, you wrote: >> >> i think we should make 2-stage voting, like in F1 >> >> after 1st stage we will know which logos are most popular and >> therefore are real candidates, so we can select among them >> >> > > One of the reasons condorcet voting is good is that this isn't needed. If > everyone is consistent in which logos they prefer the results from second > voting stage will be identical to just picking the condorcet voting from the > first stage. > > The interface to the condorcet voting site is actually pretty good (try out > one of the samples), so it's pretty easy to just "move to top" the ones you > prefer and move the ones you dislike to the bottom. Then you can ignore the > vast majority of "don't care" logos in the middle, and just fine tune your > ranking at the top and bottom. > With so many candidates, I think a two-stage process would be helpful. For example, what if a variant of a logo I liked ended up being popular, but I missed that one and didn't rank it (not unreasonable, there are a hundred logos). After the top candidates have been selected, I will surely notice it up there. Of course, introducing multi-stage voting breaks some of the properties we'd like a voting system to have. But, alas, you (provably) can't have it all :-) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/24474353/attachment.htm From lrpalmer at gmail.com Mon Mar 9 13:31:40 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Mar 9 13:20:00 2009 Subject: [Haskell-cafe] Partial pattern matching In-Reply-To: <5e0214850903090937l14672396tb5bfe524ce58bc8b@mail.gmail.com> References: <5e0214850903090933x3c1c5894x2ebf02273796736@mail.gmail.com> <5e0214850903090937l14672396tb5bfe524ce58bc8b@mail.gmail.com> Message-ID: <7ca3f0160903091031v6b7071eg6bccc253bebaae29@mail.gmail.com> On Mon, Mar 9, 2009 at 10:37 AM, Eugene Kirpichov wrote: > I mean, there is no way to write a firstCoord function so that it > would work, for example, on '\y -> P 42 y' and yield 42. > > Except for this one: > > firstCoord proj = case (proj undefined) of P x y -> x > > However, this requires proj to be non-strict in its remaining argument. > But this will actually work if you pass "P x" to it for some x, > because it *is* non-strict in the remaining argument. That's brilliant. Any function which behaves like "P x" but is strict in the second argument is in fact a different function. So this trick is a semidecidable pattern for this function. Bring in the unamb, so we can do interesting things with semidecidable predicates :-) (I still don't like the proof obligation of unamb, and would like to see it picked up to a higher level of abstraction where the usage is always correct) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/cbd994bb/attachment-0001.htm From ashley at semantic.org Mon Mar 9 13:48:14 2009 From: ashley at semantic.org (Ashley Yakeley) Date: Mon Mar 9 13:36:36 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> Message-ID: <1236620894.6541.2.camel@sherbourne> On Mon, 2009-03-09 at 10:08 +0000, Sebastian Sylvan wrote: > But the point is that you shouldn't need to rank every single logo, > just the ones you care about and then you leave the rest at the > default rank. You'll also want to rank the popular ones even if you don't like them. -- Ashley Yakeley From vanenkj at gmail.com Mon Mar 9 13:54:20 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Mar 9 13:42:40 2009 Subject: [Haskell-cafe] Partial pattern matching In-Reply-To: References: Message-ID: You can use the record syntax to get around some of this: data P { first :: Int, second :: Int } firstCoord (P {first = f}) = f 2009/3/9 Peter Verswyvelen > In Haskell, a data constructor can be used partially applied: > data Pair a b = P a b > > f = P 1 > > however, I cannot do "partial pattern matching", e.g > > firstCoord (P x) = x > > does not work. > > I guess a very important reason must exist why this is the case? > > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/f0529598/attachment.htm From lists at qseep.net Mon Mar 9 16:25:33 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Mon Mar 9 16:13:54 2009 Subject: [Haskell-cafe] Distributing Linux binaries Message-ID: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> Hi folks, I've got an application to release. I'm releasing the source, but I also wanted to release binary versions for people that don't have GHC. I developed on Windows, so making a Windows executable was simple. I also have access to an Ubuntu Linux box, on which I can easily build and test my app. But, I'm a bit confused about how to release binaries for Linux. It's not so simple as on Windows. Or, maybe it is but I don't know it. What do people recommend as a way of distributing Linux binaries? I tried to make a Debian package and couldn't figure it out, but maybe that's overkill. GHC itself has some kind of tarball for the binary distributions, one for Debian and one for Red Hat. How would I make such a package and what would go into it? There's only one executable, so it shouldn't be too complicated. I figure the main issue on Linux is that when you compile it, it's linked to specific shared libraries. Don't have a Mac myself but I'm happy to have Mac folks submit binaries. I'll worry about that later. - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/98e3b9af/attachment.htm From dons at galois.com Mon Mar 9 16:26:37 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 9 16:15:49 2009 Subject: [Haskell-cafe] Distributing Linux binaries In-Reply-To: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> References: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> Message-ID: <20090309202637.GD28269@whirlpool.galois.com> lists: > Hi folks, > > I've got an application to release. I'm releasing the source, but I also wanted > to release binary versions for people that don't have GHC. I developed on > Windows, so making a Windows executable was simple. I also have access to an > Ubuntu Linux box, on which I can easily build and test my app. > > But, I'm a bit confused about how to release binaries for Linux. It's not so > simple as on Windows. Or, maybe it is but I don't know it. What do people > recommend as a way of distributing Linux binaries? I tried to make a Debian > package and couldn't figure it out, but maybe that's overkill. GHC itself has > some kind of tarball for the binary distributions, one for Debian and one for > Red Hat. How would I make such a package and what would go into it? There's > only one executable, so it shouldn't be too complicated. You could make a .cabal package for it, and use that to construct a binary tar.gz bundle that's installable. Duncan, is there a cabal binary-dist? -- Don From colin at colina.demon.co.uk Mon Mar 9 16:44:16 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Mon Mar 9 16:32:37 2009 Subject: [Haskell-cafe] Minimum Int? Message-ID: Is there a function that yields the minimum value of Int on an implementation? -- Colin Adams Preston Lancashire From vanenkj at gmail.com Mon Mar 9 16:45:19 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Mar 9 16:33:41 2009 Subject: [Haskell-cafe] Minimum Int? In-Reply-To: References: Message-ID: Prelude> minBound :: Int -2147483648 /jve On Mon, Mar 9, 2009 at 4:44 PM, Colin Paul Adams wrote: > Is there a function that yields the minimum value of Int on an > implementation? > -- > Colin Adams > Preston Lancashire > _______________________________________________ > 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/20090309/06190e9d/attachment.htm From dons at galois.com Mon Mar 9 16:44:33 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 9 16:34:05 2009 Subject: [Haskell-cafe] Minimum Int? In-Reply-To: References: Message-ID: <20090309204433.GF28269@whirlpool.galois.com> colin: > Is there a function that yields the minimum value of Int on an implementation? Prelude> minBound :: Int -9223372036854775808 Prelude> maxBound :: Int 9223372036854775807 From haskell at list.mightyreason.com Mon Mar 9 16:54:06 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Mon Mar 9 16:42:44 2009 Subject: [Haskell-cafe] ANN: Future 1.1.0 concurrency library Message-ID: <49B581EE.7050706@list.mightyreason.com> Hello, As a side effect of the discussion of the new C++ future/promise features at http://lambda-the-ultimate.org/node/3221 I have implemented a Haskell package called "future" at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/future This ought to do what C++ standard futures/promises do, plus a bit more. The main operation is > forkPromise :: IO a -> IO (Promise a) This sets the "IO a" operation running in a fresh thread. The eventual result can be accessed in many ways (non-blocking, blocking, blocking with timeout). > let one :: Int; one = 1 > p <- forkPromise (return (one+one)) > x <- get > y <- wait x is an Int with value 2. y is an (Either SomeException Int) with value (Right 2). The useful thing about futures, as opposed to various IVar packages, is handling the case where the forked operation ends with an exception. The exception becomes the return value of the promise. The "get" operation rethrows it, the "wait" operation returns it as (Left ...). There is also an "abort" command to kill a promise. The dead promise may then have an exceptions as its value. The "plus a bit more" than C++ is the nonblocking "addTodo" feature. This takes a continuation function from the "Either SomeException a" to an IO operation. These continuation functions get queued and they are run immediately after the the forked operation completes. Once completed any new "addTodo" continuations run immediately. These continuations allow you to race a list of action and take the first one done, or to collect the answers as they complete into a Chan. Both of those options are demonstrated in Future.hs as racePromises and forkPromises. It should be safe to use "unsafePerformIO . get" or "unsafePeformIO . wait" to get lazy access to the result, which is itself immutable once set. Cheers, Chris From vanenkj at gmail.com Mon Mar 9 16:58:30 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Mar 9 16:46:51 2009 Subject: [Haskell-cafe] ANN: Future 1.1.0 concurrency library In-Reply-To: <49B581EE.7050706@list.mightyreason.com> References: <49B581EE.7050706@list.mightyreason.com> Message-ID: This is way cool! /jve On Mon, Mar 9, 2009 at 4:54 PM, ChrisK wrote: > Hello, > > As a side effect of the discussion of the new C++ future/promise features > at http://lambda-the-ultimate.org/node/3221 I have implemented a Haskell > package called "future" at > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/future > > This ought to do what C++ standard futures/promises do, plus a bit more. > The main operation is > > > forkPromise :: IO a -> IO (Promise a) > > This sets the "IO a" operation running in a fresh thread. The eventual > result can be accessed in many ways (non-blocking, blocking, blocking with > timeout). > > > let one :: Int; one = 1 > > p <- forkPromise (return (one+one)) > > x <- get > > y <- wait > > x is an Int with value 2. > y is an (Either SomeException Int) with value (Right 2). > > The useful thing about futures, as opposed to various IVar packages, is > handling the case where the forked operation ends with an exception. The > exception becomes the return value of the promise. The "get" operation > rethrows it, the "wait" operation returns it as (Left ...). > > There is also an "abort" command to kill a promise. The dead promise may > then have an exceptions as its value. > > The "plus a bit more" than C++ is the nonblocking "addTodo" feature. This > takes a continuation function from the "Either SomeException a" to an IO > operation. These continuation functions get queued and they are run > immediately after the the forked operation completes. Once completed any > new "addTodo" continuations run immediately. > > These continuations allow you to race a list of action and take the first > one done, or to collect the answers as they complete into a Chan. Both of > those options are demonstrated in Future.hs as racePromises and > forkPromises. > > It should be safe to use "unsafePerformIO . get" or "unsafePeformIO . wait" > to get lazy access to the result, which is itself immutable once set. > > Cheers, > Chris > > _______________________________________________ > 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/20090309/44201f85/attachment.htm From vanenkj at gmail.com Mon Mar 9 17:15:13 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Mar 9 17:03:34 2009 Subject: [Haskell-cafe] ANN: Future 1.1.0 concurrency library In-Reply-To: <49B581EE.7050706@list.mightyreason.com> References: <49B581EE.7050706@list.mightyreason.com> Message-ID: I'd also like to point out that Chris did this with 165 lines of code--including comments and whitespace! If you drop the whitespace and comments, it's only 91 lines! /jve On Mon, Mar 9, 2009 at 4:54 PM, ChrisK wrote: > Hello, > > As a side effect of the discussion of the new C++ future/promise features > at http://lambda-the-ultimate.org/node/3221 I have implemented a Haskell > package called "future" at > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/future > > This ought to do what C++ standard futures/promises do, plus a bit more. > The main operation is > > > forkPromise :: IO a -> IO (Promise a) > > This sets the "IO a" operation running in a fresh thread. The eventual > result can be accessed in many ways (non-blocking, blocking, blocking with > timeout). > > > let one :: Int; one = 1 > > p <- forkPromise (return (one+one)) > > x <- get > > y <- wait > > x is an Int with value 2. > y is an (Either SomeException Int) with value (Right 2). > > The useful thing about futures, as opposed to various IVar packages, is > handling the case where the forked operation ends with an exception. The > exception becomes the return value of the promise. The "get" operation > rethrows it, the "wait" operation returns it as (Left ...). > > There is also an "abort" command to kill a promise. The dead promise may > then have an exceptions as its value. > > The "plus a bit more" than C++ is the nonblocking "addTodo" feature. This > takes a continuation function from the "Either SomeException a" to an IO > operation. These continuation functions get queued and they are run > immediately after the the forked operation completes. Once completed any > new "addTodo" continuations run immediately. > > These continuations allow you to race a list of action and take the first > one done, or to collect the answers as they complete into a Chan. Both of > those options are demonstrated in Future.hs as racePromises and > forkPromises. > > It should be safe to use "unsafePerformIO . get" or "unsafePeformIO . wait" > to get lazy access to the result, which is itself immutable once set. > > Cheers, > Chris > > _______________________________________________ > 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/20090309/935162c0/attachment.htm From dons at galois.com Mon Mar 9 17:22:07 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 9 17:11:18 2009 Subject: [Haskell-cafe] ANN: Future 1.1.0 concurrency library In-Reply-To: References: <49B581EE.7050706@list.mightyreason.com> Message-ID: <20090309212207.GC29244@whirlpool.galois.com> Who needs to build futures into the language -- all you need is MVars, eh? -- Don vanenkj: > I'd also like to point out that Chris did this with 165 lines of > code--including comments and whitespace! If you drop the whitespace and > comments, it's only 91 lines! > From konrad at tylerc.org Mon Mar 9 17:57:54 2009 From: konrad at tylerc.org (Conrad Meyer) Date: Mon Mar 9 17:46:25 2009 Subject: [Haskell-cafe] Distributing Linux binaries In-Reply-To: <20090309202637.GD28269@whirlpool.galois.com> References: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> <20090309202637.GD28269@whirlpool.galois.com> Message-ID: <200903091457.54355.konrad@tylerc.org> On Monday 09 March 2009 01:26:37 pm Don Stewart wrote: > lists: > > Hi folks, > > > > I've got an application to release. I'm releasing the source, but I also > > wanted to release binary versions for people that don't have GHC. I > > developed on Windows, so making a Windows executable was simple. I also > > have access to an Ubuntu Linux box, on which I can easily build and test > > my app. > > > > But, I'm a bit confused about how to release binaries for Linux. It's not > > so simple as on Windows. Or, maybe it is but I don't know it. What do > > people recommend as a way of distributing Linux binaries? I tried to make > > a Debian package and couldn't figure it out, but maybe that's overkill. > > GHC itself has some kind of tarball for the binary distributions, one for > > Debian and one for Red Hat. How would I make such a package and what > > would go into it? There's only one executable, so it shouldn't be too > > complicated. > > You could make a .cabal package for it, and use that to construct a > binary tar.gz bundle that's installable. > > Duncan, is there a cabal binary-dist? This seems like the best way to release it to me. Individual distros can package cabalised source tarballs as they choose; any typical user can cabal install the package. Regards, -- Conrad Meyer From sebastian.sylvan at gmail.com Mon Mar 9 18:08:38 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Mar 9 17:57:00 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <7ca3f0160903091026j5bdc8a58o861c271d6638e6e0@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> <427713624.20090309133016@gmail.com> <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> <7ca3f0160903091026j5bdc8a58o861c271d6638e6e0@mail.gmail.com> Message-ID: <3d96ac180903091508o571b2015g400f8429753fa195@mail.gmail.com> On Mon, Mar 9, 2009 at 5:26 PM, Luke Palmer wrote: > 2009/3/9 Sebastian Sylvan > >> >> >> On Mon, Mar 9, 2009 at 10:30 AM, Bulat Ziganshin < >> bulat.ziganshin@gmail.com> wrote: >> >>> Hello Sebastian, >>> >>> Monday, March 9, 2009, 1:08:50 PM, you wrote: >>> >>> i think we should make 2-stage voting, like in F1 >>> >>> after 1st stage we will know which logos are most popular and >>> therefore are real candidates, so we can select among them >>> >>> >> >> One of the reasons condorcet voting is good is that this isn't needed. If >> everyone is consistent in which logos they prefer the results from second >> voting stage will be identical to just picking the condorcet voting from the >> first stage. >> >> The interface to the condorcet voting site is actually pretty good (try >> out one of the samples), so it's pretty easy to just "move to top" the ones >> you prefer and move the ones you dislike to the bottom. Then you can ignore >> the vast majority of "don't care" logos in the middle, and just fine tune >> your ranking at the top and bottom. >> > > With so many candidates, I think a two-stage process would be helpful. For > example, what if a variant of a logo I liked ended up being popular, but I > missed that one and didn't rank it (not unreasonable, there are a hundred > logos). After the top candidates have been selected, I will surely notice > it up there. > > Of course, introducing multi-stage voting breaks some of the properties > we'd like a voting system to have. But, alas, you (provably) can't have it > all :-) > It just seems like duplicated work to me. They're still few enough that I can scan through them and multi-select the ones I like and then click "move to top" in a pretty short amount of time (and then refine the ranking if I care). Having to vote twice just seems like a lot of extra effort for questionable added benefit. Maybe one vote requires people to be more careful about their rank (though you'd hope that any minor mistakes, such as the one you describe, would be random and therefore roughly cancel out over a few hundred votes), but at least it won't require them to vote twice. I say leave the plan the way it is. It's Good Enough (TM). The hassles of more delays while we go through an arduous processes isn't worth any theoretical minor gains. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/3535f810/attachment.htm From bulat.ziganshin at gmail.com Mon Mar 9 18:21:45 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Mar 9 18:10:26 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <3d96ac180903091508o571b2015g400f8429753fa195@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> <427713624.20090309133016@gmail.com> <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> <7ca3f0160903091026j5bdc8a58o861c271d6638e6e0@mail.gmail.com> <3d96ac180903091508o571b2015g400f8429753fa195@mail.gmail.com> Message-ID: <1832098251.20090310012145@gmail.com> Hello Sebastian, Tuesday, March 10, 2009, 1:08:38 AM, you wrote: > It just seems like duplicated work to me. They're still few enough > that I can scan through them and multi-select the ones I like and > then click "move to top" in a pretty short amount of time (and then refine the ranking if I care). and if none of them will be among 10 most popular - it is no difference for you which one will be finally selected? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From sebastian.sylvan at gmail.com Mon Mar 9 18:38:01 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Mar 9 18:26:23 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <1832098251.20090310012145@gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> <427713624.20090309133016@gmail.com> <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> <7ca3f0160903091026j5bdc8a58o861c271d6638e6e0@mail.gmail.com> <3d96ac180903091508o571b2015g400f8429753fa195@mail.gmail.com> <1832098251.20090310012145@gmail.com> Message-ID: <3d96ac180903091538i796d97a7u4cb709f63f8230e6@mail.gmail.com> On Mon, Mar 9, 2009 at 10:21 PM, Bulat Ziganshin wrote: > Hello Sebastian, > > Tuesday, March 10, 2009, 1:08:38 AM, you wrote: > > It just seems like duplicated work to me. They're still few enough > > that I can scan through them and multi-select the ones I like and > > then click "move to top" in a pretty short amount of time (and then > refine the ranking if I care). > > and if none of them will be among 10 most popular - it is no > difference for you which one will be finally selected? Clearly not, because if I did have a preference among them I would've ranked them - if I didn't then I must not care either way. I suspect 99% will have a few favourites, and then they will have a few that they object to, and for the rest they just don't care which ones win. Expressing that with the proposed system is easy. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/34c839ac/attachment.htm From sebastian.sylvan at gmail.com Mon Mar 9 18:41:44 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Mar 9 18:30:05 2009 Subject: [Haskell-cafe] Logo Preferences In-Reply-To: <3d96ac180903091538i796d97a7u4cb709f63f8230e6@mail.gmail.com> References: <49B4528F.4060306@semantic.org> <3d96ac180903090308r3cfcc714yb388ad3f6ba7f976@mail.gmail.com> <427713624.20090309133016@gmail.com> <3d96ac180903090352w77b33356g158cc50a3d85a410@mail.gmail.com> <7ca3f0160903091026j5bdc8a58o861c271d6638e6e0@mail.gmail.com> <3d96ac180903091508o571b2015g400f8429753fa195@mail.gmail.com> <1832098251.20090310012145@gmail.com> <3d96ac180903091538i796d97a7u4cb709f63f8230e6@mail.gmail.com> Message-ID: <3d96ac180903091541s1a4ca85fj16c57d14bbe25a0a@mail.gmail.com> On Mon, Mar 9, 2009 at 10:38 PM, Sebastian Sylvan < sebastian.sylvan@gmail.com> wrote: > > > On Mon, Mar 9, 2009 at 10:21 PM, Bulat Ziganshin < > bulat.ziganshin@gmail.com> wrote: > >> Hello Sebastian, >> >> Tuesday, March 10, 2009, 1:08:38 AM, you wrote: >> > It just seems like duplicated work to me. They're still few enough >> > that I can scan through them and multi-select the ones I like and >> > then click "move to top" in a pretty short amount of time (and then >> refine the ranking if I care). >> >> and if none of them will be among 10 most popular - it is no >> difference for you which one will be finally selected? > > > Clearly not, because if I did have a preference among them I would've > ranked them - if I didn't then I must not care either way. > I suspect 99% will have a few favourites, and then they will have a few > that they object to, and for the rest they just don't care which ones win. > Expressing that with the proposed system is easy. > Also, let's be realistic. We can all look at the list and figure out which logos are likely to be popular - so just make sure you rank those. Adding even more time and hassle for the people who are already donating their time to arrange this for free isn't going to improve things significantly, I think. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/74e452f4/attachment.htm From briqueabraque at yahoo.com Mon Mar 9 19:55:53 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Mon Mar 9 19:44:31 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot Message-ID: Hi, Here in Brazil we have a forest animal we name 'pregui?a' -- literally, lazyness. What better mascot we could have for Haskell? It lives (and sleeps) in trees, and if you see the main picture in wikipedia articles you can easily imagine the tree branch beeing replaced by a lambda: http://en.wikipedia.org/wiki/Sloth http://pt.wikipedia.org/wiki/Bicho-pregui%C3%A7a Best, Maur?cio From jfredett at gmail.com Mon Mar 9 19:59:02 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Mar 9 19:47:24 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: References: Message-ID: <49B5AD46.2020502@gmail.com> Hehe, I love it. Sloth is a synonym for Lazyness in English too, and they're so freaking cute... :) Maur??cio wrote: > Hi, > > Here in Brazil we have a forest animal we name 'pregui?a' -- literally, > lazyness. What better mascot we could have for Haskell? It lives (and > sleeps) in trees, and if you see the main picture in wikipedia articles > you can easily imagine the tree branch beeing replaced by a lambda: > > http://en.wikipedia.org/wiki/Sloth > > http://pt.wikipedia.org/wiki/Bicho-pregui%C3%A7a > > Best, > Maur?cio > > _______________________________________________ > 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: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/c880c94b/jfredett.vcf From deniz.a.m.dogan at gmail.com Mon Mar 9 20:00:01 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Mon Mar 9 19:48:21 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <49B5AD46.2020502@gmail.com> References: <49B5AD46.2020502@gmail.com> Message-ID: <7b501d5c0903091700m38d3f272l59552743989dc0fa@mail.gmail.com> It's got my vote! 2009/3/10 Joe Fredette : > Hehe, I love it. Sloth is a synonym for Lazyness in English too, and they're > so freaking cute... :) > > Maur??cio wrote: >> >> Hi, >> >> Here in Brazil we have a forest animal we name 'pregui?a' -- literally, >> lazyness. What better mascot we could have for Haskell? It lives (and >> sleeps) in trees, and if you see the main picture in wikipedia articles >> you can easily imagine the tree branch beeing replaced by a lambda: >> >> http://en.wikipedia.org/wiki/Sloth >> >> http://pt.wikipedia.org/wiki/Bicho-pregui%C3%A7a >> >> Best, >> Maur?cio >> >> _______________________________________________ >> 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 Mon Mar 9 20:08:19 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Mar 9 19:56:44 2009 Subject: [Haskell-cafe] Distributing Linux binaries In-Reply-To: <20090309202637.GD28269@whirlpool.galois.com> References: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> <20090309202637.GD28269@whirlpool.galois.com> Message-ID: <1236643699.22402.341.camel@localhost> On Mon, 2009-03-09 at 13:26 -0700, Don Stewart wrote: > lists: > > Hi folks, > > > > I've got an application to release. I'm releasing the source, but I also wanted > > to release binary versions for people that don't have GHC. I developed on > > Windows, so making a Windows executable was simple. I also have access to an > > Ubuntu Linux box, on which I can easily build and test my app. > > > > But, I'm a bit confused about how to release binaries for Linux. It's not so > > simple as on Windows. Or, maybe it is but I don't know it. What do people > > recommend as a way of distributing Linux binaries? I tried to make a Debian > > package and couldn't figure it out, but maybe that's overkill. GHC itself has > > some kind of tarball for the binary distributions, one for Debian and one for > > Red Hat. How would I make such a package and what would go into it? There's > > only one executable, so it shouldn't be too complicated. > > You could make a .cabal package for it, and use that to construct a > binary tar.gz bundle that's installable. > > Duncan, is there a cabal binary-dist? No. If we want it then someone needs to look at this ticket: http://hackage.haskell.org/trac/hackage/ticket/47 What you can do however is use cabal to make an install image (cabal copy --destdir=) and then write your own install script or make a deb or rpm or whatever. Duncan From how2paut at gmail.com Mon Mar 9 20:14:20 2009 From: how2paut at gmail.com (Windoze) Date: Mon Mar 9 20:02:41 2009 Subject: [Haskell-cafe] Building/Prerequisites->Linux->glibc-devel libedit-devel ? Message-ID: <22376307.post@talk.nabble.com> Greetings, am considering learning how to do a build for my slackware-based distro. The doc sited below say's it requires: glibc-devel libedit-devel ncurses-devel gmp-devel .etc. Must I used the dev versions, or will it work with the lastest, stable release versions of same? thanks much for the assistance http://hackage.haskell.org/trac/ghc/wiki/Building/Prerequisites http://hackage.haskell.org/trac/ghc/wiki/Building/Prerequisites -- View this message in context: http://www.nabble.com/Building-Prerequisites-%3ELinux-%3Eglibc-devel--libedit-devel---tp22376307p22376307.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From duncan.coutts at worc.ox.ac.uk Mon Mar 9 20:14:53 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Mar 9 20:03:18 2009 Subject: [Haskell-cafe] where does ghc specify ar options In-Reply-To: <7c737f300903082044x6e5b881at7af3a274fc17f256@mail.gmail.com> References: <7c737f300903082044x6e5b881at7af3a274fc17f256@mail.gmail.com> Message-ID: <1236644093.22402.348.camel@localhost> On Sun, 2009-03-08 at 22:44 -0500, Alexy Khrabrov wrote: > When bootstrapping cabal-install 0.6.2 on Mac OSX Leopard (Intel), I > get a problem when linking: > > Linking dist/build/cabal/cabal ... > ld: in /private/var/folders/mw/mwJSf7ErEa4w8nWyKyyqD++++TY/-Tmp-/zlib-0.5.0.0/dist/build/libHSzlib-0.5.0.0.a, > archive has no table of contents > > This had happened with other ar'chives on my Mac before where it > hadn't for some others. In all cases the fix was to make sure ranlib > is run on the archive in question, or s is passed to ar during the > creation. I have the latest XCode 312m gcc build 5490, and ghc 6.10.1 > from MacPorts. > > In order to ensure ar cr becomes ar crs, I need to find out where in > the ghc build process is it known how to create .a files? Where can > an "ar cr" be changed to "ar crs" on a system-wide ghc build basis? We'll need some help from you to investigate this. Cabal does run ranlib on libraries after it installs them. See updateLibArchive in Distribution/Simple/GHC.hs in the Cabal source code. You'll see in the code it looks for ranlib and ar. If neither are available it issues a warning and installs anyway. Perhaps on OSX it should be an error rather than a warning. So we'll want to check that it's really being run when the zlib package is being built. You can run any cabal command with -v or -v3 to see what commands it runs. BTW, how did you get the package installed in that location? Did it involve copying into a temp dir and copying again? I believe that on OSX, copying a .a file breaks the ar index. This is because for reasons best known to themselves Apple decided that the index is only valid if its timestamp is the same as the last modification time of the file. Duncan From donn at avvanta.com Mon Mar 9 20:31:12 2009 From: donn at avvanta.com (Donn Cave) Date: Mon Mar 9 20:19:32 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot References: <49B5AD46.2020502@gmail.com> Message-ID: <20090310003112.37AF4276C42@mail.avvanta.com> Quoth Joe Fredette : | Hehe, I love it. Sloth is a synonym for Lazyness in English too, and | they're so freaking cute... :) ... and so freaking slow! :) Donn From john at repetae.net Mon Mar 9 20:41:01 2009 From: john at repetae.net (John Meacham) Date: Mon Mar 9 20:29:24 2009 Subject: [Haskell-cafe] I want to write a compiler In-Reply-To: <1236607231-sup-9517@existential.local> References: <6f9f8f4a0903071532x3d4e550dvb8eeffca9488a4c3@mail.gmail.com> <1236473265-sup-9021@existential.local> <20090309122825.GB8842@sliver.repetae.net> <1236607231-sup-9517@existential.local> Message-ID: <20090310004101.GE8842@sliver.repetae.net> On Mon, Mar 09, 2009 at 09:25:58AM -0500, Austin Seipp wrote: > Indeed, I stumbled upon it whilst looking at how unsafeCoerce worked > (to find out it is super-duper-special and implemented as part of E.) > I think it's actually pretty clever, and who knows, maybe it could be > useful as at least a debugging aid. :) It is actually not all that special, it is just a primitive like any other than transates to a nop, or no code. Since the optimizer can't know what is inside a primitive in general, it leaves it alone and the only affect is the type coercion implicit in its signature. When translating to Grin, the unsafeCoerces are simply dropped. Coercions used to be more complicated because once upon a time I required them to be used to translate to/from newtype declared synonyms, I found they inhibited optimizations too much so switched to the current mechanism whereby newtype expansion happens transparently in the type checker when needed. As a side effect I worked hard to try to recognize and optimize around coercions, but now that they occur fairly rarely, it isn't much of an issue any more. > This is a very good point I hadn't even thought about! Indeed, since > GRIN represents thunks in a defunctionalized way - encoded as nodes - > dealing with boxed/unboxed values becomes more of the compiler's job, > since the nature of unboxed values etc. becomes more transparent. The main reason I think it is important is because I feel not including unboxed values from the get-go was one of the biggest false starts I had when writing jhc. When I initially started writing it I considered unboxed values as a feature to be added later. When I started implementing them, I found that there were a lot of decisions I would have made differently and a lot of places they would have greatly simplified my initial design had I had them from the start. Namely, A whole host of 'compiler magic' could have gone away if I implemented all primitive types in pure haskell like I implement floats and chars now, data Float = Float_ Float32_ data Char = Char Bits32_ (where Float32_ and Bits32_ are the unboxed raw types) Since instead I had the compiler implement Int and friends directly, it suddenly had the responisibity to conjure up all sorts of operations on them, such as the Num instances, creating the big mess of compiler magic in PrimitiveOperators.hs. The more I can express in the haskell source directly the better, it raises odd questions when the compiler has to do things like implement Num instances directly, like the instances are built in, but we might not have 'imported' the types needed to declare them into the current scope, so we end up having to deal with instancse for types that don't exist yet. In any case, yeah. if you plan on unboxed types at some point, include them from the start because they can simplify a lot to offset their cost of implementation, by trying to add them on later I ended up having to pay the cost of implementing them, but also had to deal with the cruft left over from not utilizing them from the beginning. > Since you bring this up, I figure this decision also had some > influence on E in lhc/jhc, considering its type system is rich enough > to distinguish values in whnf/boxed/unboxed etc.? Yeah, there were a couple things that motivated this. A big one is that evals are bad in jhc, signifigantly moreso than traditional ghc. The points-to analysis is the main way to fight it, but I also decided I wanted to give it the best shot possible by getting rid of as many evals as I could in higher level optimizations, which necessitated a fairly rich type system since it actually made sense for jhc to keep strict track of what was in WHNF vs not even if they were both boxed. in general ghc didn't care unless a value was either CPRable or unboxable, but jhc can benefit from such knowledge no matter what the type, even if it is a partially applied function. Though, it is interesting that GHC may be moving to a jhc-style semi-tagging mechanism according to this paper[1] so more optimizations may help both equally in the future. The other main motivating factor was that I was always enamoured with the idea of jhc supporting more than one source language, in particular, I wanted to explore it having an SML front end, so wanted a core type system that was equally good at expressing lazy haskell as strict ML, and more importantly would be able to seamlessly intermingle the two without difficulty. So, when designing it, I kept that in mind, "is this equally useful as a ML compilers core?" or a "wacky ML/Haskell hybrid?". Although the ML front end is more of a thought experiment at this point, I think it helped me come up with a coherent type system that had intruiging possibilies for haskell optimizations, as well as some language implications, such as the ability to declare new 'strict' algebraic types that may lead to new ideas for language extensions. John [1] http://research.microsoft.com/en-us/um/people/simonpj/papers/ptr-tag/ -- John Meacham - ?repetae.net?john? From aslatter at gmail.com Mon Mar 9 20:42:08 2009 From: aslatter at gmail.com (Antoine Latter) Date: Mon Mar 9 20:30:28 2009 Subject: [Haskell-cafe] Building/Prerequisites->Linux->glibc-devel libedit-devel ? In-Reply-To: <22376307.post@talk.nabble.com> References: <22376307.post@talk.nabble.com> Message-ID: <694519c50903091742rc64b185w420bf941a1f55894@mail.gmail.com> On Mon, Mar 9, 2009 at 7:14 PM, Windoze wrote: > > Greetings, > > am considering learning how to do a build for my slackware-based distro. > > The doc sited below say's it requires: > > glibc-devel > libedit-devel > ncurses-devel > gmp-devel > .etc. > > Must I used the dev versions, or will it work with the lastest, stable > release versions of same? > By "dev version" the instructions mean "be sure to install the C header files." In Debian-like distros, such packages have the "-dev" suffix. Antoine From anton at appsolutions.com Mon Mar 9 20:49:09 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Mon Mar 9 20:37:30 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: References: Message-ID: <49B5B905.3070200@appsolutions.com> Maur??cio wrote: > Here in Brazil we have a forest animal we name 'pregui?a' -- literally, > lazyness. What better mascot we could have for Haskell? It lives (and > sleeps) in trees, and if you see the main picture in wikipedia articles > you can easily imagine the tree branch beeing replaced by a lambda: > > http://en.wikipedia.org/wiki/Sloth > > http://pt.wikipedia.org/wiki/Bicho-pregui%C3%A7a The article says: "Sloths therefore have very large, specialized, slow-acting stomachs with multiple compartments in which symbiotic bacteria break down the tough leaves." Clearly a reference to the evil mangler. Anton From john at repetae.net Mon Mar 9 20:56:39 2009 From: john at repetae.net (John Meacham) Date: Mon Mar 9 20:44:59 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: <221b53ab0903080513n5d46cbdejaa33a655d8eda3a3@mail.gmail.com> References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> <1236511938.22402.297.camel@localhost> <221b53ab0903080513n5d46cbdejaa33a655d8eda3a3@mail.gmail.com> Message-ID: <20090310005639.GF8842@sliver.repetae.net> On Sun, Mar 08, 2009 at 01:13:33PM +0100, Svein Ove Aas wrote: > On Sun, Mar 8, 2009 at 12:32 PM, Duncan Coutts > wrote: > > Note also that the list of licenses mkcabal offers is wrong. You can get > > the list from the Cabal lib itself so there is no need to maintain the > > list manually. > > > It would also be nice to expand that list somewhat, to at least cover > the most used licences - GPL2, GPL3, AGPL, etc. Why would cabal need a list at all inside of it? It seems very odd to have to upgrade cabal just because I am using a different license. it seems that we should just bite the bullet and switch data License to newtype License = License String and simplify a lot of code to boot as well as create a normalized data layout. John -- John Meacham - ?repetae.net?john? From relapse.dev at gmx.com Mon Mar 9 21:01:23 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Mon Mar 9 20:47:55 2009 Subject: [Haskell-cafe] Re: ANN: Future 1.1.0 concurrency library In-Reply-To: <49B581EE.7050706__26504.6122869991$1236632179$gmane$org@list.mightyreason.com> References: <49B581EE.7050706__26504.6122869991$1236632179$gmane$org@list.mightyreason.com> Message-ID: ChrisK wrote: > Hello, > > As a side effect of the discussion of the new C++ future/promise > features at http://lambda-the-ultimate.org/node/3221 I have implemented > a Haskell package called "future" at > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/future > > This ought to do what C++ standard futures/promises do, plus a bit > more. The main operation is > > > forkPromise :: IO a -> IO (Promise a) > > This sets the "IO a" operation running in a fresh thread. The eventual > result can be accessed in many ways (non-blocking, blocking, blocking > with timeout). > > > let one :: Int; one = 1 > > p <- forkPromise (return (one+one)) > > x <- get > > y <- wait > > x is an Int with value 2. > y is an (Either SomeException Int) with value (Right 2). > > The useful thing about futures, as opposed to various IVar packages, is > handling the case where the forked operation ends with an exception. > The exception becomes the return value of the promise. The "get" > operation rethrows it, the "wait" operation returns it as (Left ...). > > There is also an "abort" command to kill a promise. The dead promise > may then have an exceptions as its value. > > The "plus a bit more" than C++ is the nonblocking "addTodo" feature. > This takes a continuation function from the "Either SomeException a" to > an IO operation. These continuation functions get queued and they are > run immediately after the the forked operation completes. Once > completed any new "addTodo" continuations run immediately. > > These continuations allow you to race a list of action and take the > first one done, or to collect the answers as they complete into a Chan. > Both of those options are demonstrated in Future.hs as racePromises and > forkPromises. > > It should be safe to use "unsafePerformIO . get" or "unsafePeformIO . > wait" to get lazy access to the result, which is itself immutable once set. > > Cheers, > Chris I used something similar to this for a monadic opengl "RPC" mechanism. The need was for transparently creating OGL objects from any context. Returning thunks that block on the result when finally evaluated works out real nice in practice. Its easy to manage, and performs better than dealing with several OS threads and GL contexts. From deliverable at gmail.com Mon Mar 9 21:02:20 2009 From: deliverable at gmail.com (Alexy Khrabrov) Date: Mon Mar 9 20:50:45 2009 Subject: [Haskell-cafe] where does ghc specify ar options In-Reply-To: <1236644093.22402.348.camel@localhost> References: <7c737f300903082044x6e5b881at7af3a274fc17f256@mail.gmail.com> <1236644093.22402.348.camel@localhost> Message-ID: > BTW, how did you get the package installed in that location? Did it > involve copying into a temp dir and copying again? I believe that on > OSX, copying a .a file breaks the ar index. This is because for > reasons > best known to themselves Apple decided that the index is only valid if > its timestamp is the same as the last modification time of the file. OK -- what I did was rather drastic -- I got ar as a part of cctools off Apple's Open Source and verified that it didn't run ranlib on my Leopard 10.5. However it turns out it's supposed to do so -- folks from MacPorts even got a flag -S to make it *not* tun ranlib... Yet they're on PPC, and I'm on Intel (MBP). So what I ended up doing is patching Apple's ar as described in that MacPorts thread: Why ar doesn't call ranlib on Mac? And after that, cabal-install did bootstrap.sh like a charm. I know some folks say that they don't need to run ranlib on their Macs, and some do, and I could have wrapped it in sh-wrappers and investigate it forever, but this issue has re-ar-ed its head often enough that I'm happy with just fetching the li'l slimy ar out of its source soup and fixing it in the bud. Cheers, Alexy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/e759fecf/attachment.htm From alexander.dunlap at gmail.com Mon Mar 9 21:29:28 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Mon Mar 9 21:17:50 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> Message-ID: <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> On Mon, Mar 9, 2009 at 3:12 AM, Henning Thielemann wrote: > > On Mon, 9 Mar 2009, Claus Reinke wrote: > >> Given the close relationship between uvector and vector, it would >> be very helpful if both package descriptions on hackage could point to a >> common haskell wiki page, starting out with the text >> and link above, plus a link to the stream fusion paper (I hadn't been >> aware that vector incorporates the recycling work, and had often wondered >> about the precise relationship between those >> two packages). Apart from saving others from similar confusion, >> that would also provide a place to record experience with those two >> alternatives. > > I have at least started a page which mentions the existing alternatives: > ? http://www.haskell.org/haskellwiki/Storable_Vector > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Thanks for all of the responses! So let me see if my summary is accurate here: - ByteString is for just that: strings of bytes, generally read off of a disk. The Char8 version just interprets the Word8s as Chars but doesn't do anything special with that. - Data.Text/text library is a higher-level library that deals with "text," abstracting over Unicode details and treating each element as a potentially-multibye "character." - utf8-string is a wrapper over ByteString that interprets the bytes in the bytestring as potentially-multibye unicode "characters." - uvector, storablevector and vector are all designed for dealing with arrays. They *can* be used for characters/word8s but are not specialized for that purpose, do not deal with Unicode at all, and are probably worse at it. They are better for dealing with things that you would generally use arrays for. If that seems accurate, I'll put it on the wiki. Alex From xj2106 at columbia.edu Mon Mar 9 22:28:25 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Mon Mar 9 22:16:46 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> (Alexander Dunlap's message of "Mon, 9 Mar 2009 18:29:28 -0700") References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> Message-ID: <87vdqi862e.fsf@columbia.edu> Alexander Dunlap writes: > - uvector, storablevector and vector are all designed for dealing with > arrays. They *can* be used for characters/word8s but are not > specialized for that purpose, do not deal with Unicode at all, and are > probably worse at it. They are better for dealing with things that you > would generally use arrays for. I think uvector only works with certain types that can be unboxed, while storablevector works with all types that instantiate Foreign.Storable.Storable. I don't know about vector. From the description of vector, I have the impression that it is quite unstable. How is it compared to uvector and storablevector? I need one of those to work with my code to possibly improve the efficiency. But I can't use uvector, because I can't use unboxed types. Should I use storablevector? Or vector? Thanks, Xiao-Yong -- c/* __o/* <\ * (__ */\ < From allbery at ece.cmu.edu Mon Mar 9 23:33:38 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Mar 9 23:22:15 2009 Subject: [Haskell-cafe] Building/Prerequisites->Linux->glibc-devel libedit-devel ? In-Reply-To: <22376307.post@talk.nabble.com> References: <22376307.post@talk.nabble.com> Message-ID: <48A02C18-0857-488C-A5A5-D13769C009BD@ece.cmu.edu> On 2009 Mar 9, at 20:14, Windoze wrote: > glibc-devel > libedit-devel > ncurses-devel > gmp-devel > .etc. > > Must I used the dev versions, or will it work with the lastest, stable > release versions of same? Linux distributions use foo-devel or foo-dev for the files necessary for development, i.e. header files and link-time shared libraries (libfoo.so, vs. libfoo.so.N which is the runtime shared object; you can have multiple runtime versions installed for backward compatibility). (This doesn't apply to NetBSD or FreeBSD, which always installs both runtime and developer components; foo-devel there does indeed mean the latest developer code.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/7010050b/PGP.bin From DekuDekuplex at Yahoo.com Tue Mar 10 00:49:29 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Tue Mar 10 00:37:58 2009 Subject: [Haskell-cafe] Re: Logo Preferences References: <49B4528F.4060306@semantic.org> <0dc9r4daiu6l3desr6br2qa2l6n2sgmgti@4ax.com> <3d96ac180903090413l4b1c1a61kbba0c7cb3b13119c@mail.gmail.com> <20090309115051.GA4250@matrix.chaos.earth.li> Message-ID: On Mon, 9 Mar 2009 11:50:51 +0000, Ian Lynagh wrote: >On Mon, Mar 09, 2009 at 11:13:40AM +0000, Sebastian Sylvan wrote: >> >> Another reason condorcet voting is nice is that there is no need to group >> "similar" items together. > >I think the plan is that once a logo "class" is chosen, we'll have >another vote for the actual colour scheme etc to be used, if applicable. > >Yes, we could have done this in a single vote, but then people would >need to spend time creating 30 variants of each logo, and we'd be >ranking 3000, rather than 100, options. The only difficulty with creating "classes" of logos in this way is that there seem to be some users who prefer only a specific member of a class, and who do not like other members of the same class. For example, there seem to be some users who like the second logo in group 61, but who would prefer something else to the most of the other logos in that group, so they would want to minimize the possibility of anything but the second logo from being chosen within that group. Perhaps classes should be created for viewing, but not for voting for, the logos, so that at the election, each variant can be uniquely identified. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From johan.tibell at gmail.com Tue Mar 10 05:41:54 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue Mar 10 05:30:14 2009 Subject: [Haskell-cafe] Re: [Haskell] Google Summer of Code 2009 In-Reply-To: <20090210142644.361a1d9e.Malcolm.Wallace@cs.york.ac.uk> References: <20090210142644.361a1d9e.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <90889fe70903100241m259af961ic5e96159ce635d07@mail.gmail.com> On Tue, Feb 10, 2009 at 3:26 PM, Malcolm Wallace wrote: > Gentle Haskellers, > > The Google Summer of Code will be running again this year. ?Once again, > haskell.org has the opportunity to bid to become a mentoring > organisation. ?(Although, as always, there is no guarantee of > acceptance.) > > If you have ideas for student projects that you think would benefit the > Haskell community, now is the time to start discussing them on mailing > lists of your choice. ?We especially encourage students to communicate > with the wider community: if you keep your ideas private, you have a > much worse chance of acceptance than if you develop ideas in > collaboration with those who will be your "customers", end-users, or > fellow-developers. ?This is the open-source world! > > The timeline is that Haskell.org will apply for GSoC membership between > 9-13 March, and if we are successful, students can submit applications > between 23 March - 3 April. Google is now accepting applications: http://google-opensource.blogspot.com/2009/03/google-summer-of-code-applications-now.html From duncan.coutts at worc.ox.ac.uk Tue Mar 10 05:51:05 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Mar 10 05:39:35 2009 Subject: [Haskell-cafe] where does ghc specify ar options In-Reply-To: <2AC0E222-81B7-4B14-AF7E-78446E91EB43@gmail.com> References: <7c737f300903082044x6e5b881at7af3a274fc17f256@mail.gmail.com> <1236644093.22402.348.camel@localhost> <2AC0E222-81B7-4B14-AF7E-78446E91EB43@gmail.com> Message-ID: <1236678665.22402.375.camel@localhost> On Mon, 2009-03-09 at 21:08 -0400, Alexy Khrabrov wrote: > Duncan -- > > On Mar 9, 2009, at 8:14 PM, Duncan Coutts wrote: > > BTW, how did you get the package installed in that location? Did it > > involve copying into a temp dir and copying again? I believe that on > > OSX, copying a .a file breaks the ar index. This is because for > > reasons > > best known to themselves Apple decided that the index is only valid if > > its timestamp is the same as the last modification time of the file. > > Oh -- and that's because instead of the supplied bootstrap.sh I used > one off some website, and it used /tmp which somehow put stuff in > there and registered it there. I then unregistered it and removed it > and redid the cabal-install, and it worked with my patched ar. Ahhh. So is there anything in Cabal or the bootstrap.sh that needs to be fixed for this problem? Duncan From haskell at list.mightyreason.com Tue Mar 10 05:53:38 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Mar 10 05:42:26 2009 Subject: [Haskell-cafe] Re: ANN: Future 1.1.0 concurrency library In-Reply-To: <20090309212207.GC29244@whirlpool.galois.com> References: <49B581EE.7050706@list.mightyreason.com> <20090309212207.GC29244@whirlpool.galois.com> Message-ID: Don Stewart wrote: > Who needs to build futures into the language -- all you need is MVars, eh? For a pure computation in Haskell one can use "par" (which did take changing the runtime, and arguably adding to the language). The future package I uploaded is just a clean way to get something a little like "par" for an IO computation, as a library. One can build many useful APIs quite cheaply using MVars. Hackage even has a few examples (many under the Concurrency heading). This API was interesting solely because it is in the C++ standard and the discussion about how the standard left out useful proposed parts of the API. Cheers, Chris From kyagrd at gmail.com Tue Mar 10 05:56:47 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Tue Mar 10 05:45:42 2009 Subject: [Haskell-cafe] ANN: sparsebit 0.5 - Sparse Bitmaps for Pattern Match Coverage Message-ID: sparsebit - Sparse Bitmaps for Pattern Match Coverage http://hackage.haskell.org/cgi-bin/hackage-scripts/package/sparsebit This library packages the functional peal paper 'Sparse Bitmaps for Pattern Match Coverage' submitted to ICFP 2009 by Ki Yung Ahn and Tim Sheard. You can look up the tutorial-like paper and the talk slides, which are availabel at: http://kyagrd.dyndns.org/wiki/SparseBitmapsForPatternMatchCoverage Abstract: Pattern matching coverage over Algebraic Data Types(ADTs) has most often been studied in the context of pattern compilation algorithms. However, it is worth considering the pattern matching coverage problem in isolation, since general solutions will be independent of the specifics of any implementation or language. We define an intuitive and mathematically well-established bit masking semantics for pattern match coverage. We design and implement a sparse bitmap data structure, which realizes this semantics in a compact and flexible manner. This bitmap data structure supports computing coverage solutions of large programs incrementally from coverage solutions of sub-programs. It can also be used as a common data representation for pattern coverage shared between different tools (e.g., compilers, linting tools, software analysis tools) that need pattern match coverage information. Additional source files Type.hs and TestType.hs packaged with this library provides the examples and QuickCheck extracted from the paper to demonstrate how to use this library. ==================================================================== Some additional notes: Personally, I am very happy to upload my first project on Hackage. If you are looking for simple and elegant way of describing pattern match coverage or testing exhaustiveness of pattern matching, we hope this may give you a better insight. This is a reference implementation, but I think it is still usable to some extent. One might want to define monadic version of the library functions and operators since the type representation in the program analysis tools might be monadic for implementation reasons (easy to generate fresh type variables) and performance reasons (to exploit sharing while unification of type variables). And in such cases, more optimized implementation of tensor product may be possible as well. And there are some other issues discussed in the paper as well. I was not able to make the haddock documentation appear in Hackage, although I have no problem generating documentation using "cabal haddock" locally. It would be nice if there is a way to see some diagnose of warning or error messages why haddock failed on Hackage. -- Ahn, Ki Yung From duncan.coutts at worc.ox.ac.uk Tue Mar 10 06:00:24 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Mar 10 05:48:53 2009 Subject: [Haskell-cafe] Mystified by Cabal In-Reply-To: <20090310005639.GF8842@sliver.repetae.net> References: <221b53ab0903070926v36403274qe36104b4ae28c8ff@mail.gmail.com> <1236511938.22402.297.camel@localhost> <221b53ab0903080513n5d46cbdejaa33a655d8eda3a3@mail.gmail.com> <20090310005639.GF8842@sliver.repetae.net> Message-ID: <1236679224.22402.382.camel@localhost> On Mon, 2009-03-09 at 17:56 -0700, John Meacham wrote: > On Sun, Mar 08, 2009 at 01:13:33PM +0100, Svein Ove Aas wrote: > > On Sun, Mar 8, 2009 at 12:32 PM, Duncan Coutts > > wrote: > > > Note also that the list of licenses mkcabal offers is wrong. You can get > > > the list from the Cabal lib itself so there is no need to maintain the > > > list manually. > > > > > It would also be nice to expand that list somewhat, to at least cover > > the most used licences - GPL2, GPL3, AGPL, etc. > > Why would cabal need a list at all inside of it? It seems very odd to > have to upgrade cabal just because I am using a different license. > > it seems that we should just bite the bullet and switch data License to > > newtype License = License String > > and simplify a lot of code to boot as well as create a normalized data > layout. Because it was not that way initially and changing away to something more sensible takes time so that we do not cause unnecessary breakage. Now it does allow any string at all. There are however a list of "well known" licenses and the point of that is so that we can collectively use the same name for the same thing. There's nothing however stopping you from using a custom license. At the moment you cannot give a name in the .cabal file to that custom license and upload it to hackage and I think that's what you're getting at. If everyone agrees that's the way to go then we can certainly change it. The hard part was phasing out the fragile parser. We are now half way through that cycle. When we no longer care about users of ghc-6.8 then we can make use of the extra flexibility. Duncan From Malcolm.Wallace at cs.york.ac.uk Tue Mar 10 06:19:41 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Mar 10 06:11:39 2009 Subject: [Haskell-cafe] Re: [Haskell] Google Summer of Code 2009 In-Reply-To: <90889fe70903100241m259af961ic5e96159ce635d07@mail.gmail.com> References: <20090210142644.361a1d9e.Malcolm.Wallace@cs.york.ac.uk> <90889fe70903100241m259af961ic5e96159ce635d07@mail.gmail.com> Message-ID: <20090310101941.3fb41484.Malcolm.Wallace@cs.york.ac.uk> > > The Google Summer of Code will be running again this year. ?Once > > again, haskell.org has the opportunity to bid to become a mentoring > > organisation. ?(Although, as always, there is no guarantee of > > acceptance.) > > Google is now accepting applications: Indeed. Since I am (perhaps by default) the GSoC org admin for haskell.org once again this year, and will shortly need to list our mentors on our application form, I am now soliciting volunteers to be mentors. Please email me directly. The mentoring group has two main jobs: * To look after students and their projects if/when they are accepted. If you have suggested, or feel strongly about, or have experience relevant to a particular project (currently on the trac[1], or reddit[2] - if not, then add it!), please consider volunteering to mentor it. This requires a commitment of maybe up to five hours a week (but often less) during the student coding phase (23rd May - 17th Aug). Having multiple mentors for a single project area is no problem - it just means more backup for students. * To review and rank student proposals. This requires a commitment of several hours across the review period (roughly 23rd March - 15th April), and also some enthusiasm for generally promoting projects that will benefit the Haskell community as a whole. The reviewers include all those who are willing to look after students for the summer. Of course there is no guarantee that your project will actually get student participation, but if you don't play at this stage, you definitely won't get one! Regards, Malcolm [1] http://hackage.haskell.org/trac/summer-of-code/ [2] http://www.reddit.com/r/haskell_proposals/ From johan.tibell at gmail.com Tue Mar 10 06:59:07 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue Mar 10 06:47:26 2009 Subject: [Haskell-cafe] Re: [Haskell] Google Summer of Code 2009 In-Reply-To: <20090310101941.3fb41484.Malcolm.Wallace@cs.york.ac.uk> References: <20090210142644.361a1d9e.Malcolm.Wallace@cs.york.ac.uk> <90889fe70903100241m259af961ic5e96159ce635d07@mail.gmail.com> <20090310101941.3fb41484.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <90889fe70903100359m581a56bdj9f0d50e12f10f14f@mail.gmail.com> On Tue, Mar 10, 2009 at 11:19 AM, Malcolm Wallace wrote: >> > The Google Summer of Code will be running again this year. ?Once >> > again, haskell.org has the opportunity to bid to become a mentoring >> > organisation. ?(Although, as always, there is no guarantee of >> > acceptance.) >> >> Google is now accepting applications: > > Indeed. ?Since I am (perhaps by default) the GSoC org admin for > haskell.org once again this year, and will shortly need to list our > mentors on our application form, I am now soliciting volunteers to be > mentors. ? Please email me directly. ?The mentoring group has two main > jobs: I took the liberty to create a People2009 page: http://hackage.haskell.org/trac/summer-of-code/wiki/People2009 -- Johan From ariep at xs4all.nl Tue Mar 10 09:50:22 2009 From: ariep at xs4all.nl (ariep) Date: Tue Mar 10 09:34:26 2009 Subject: [Haskell-cafe] Incompatibility of different (monad transformer) libraries Message-ID: <63c2e535e6a4e2f382c777103a37dc67@xs4all.nl> Hi, ==== Problem instance ==== In my code, I use some monad transformers. I used to use the "mtl" package, but I recently switched to the combination "transformers"/"monads-tf" (mainly for the Applicative instances). The same code also uses the "haskeline" library, for line reading. Haskeline allows to edit the user's history (previously entered lines), but only through a Control.Monad.State interface, and that happens to be the Control.Monad.State from "mtl". So now, my package also needs to import "mtl". This combination of package dependencies gives import conflicts: whenever I import some Control.Monad.{State,Error,Cont,...} module, there is more than one package providing such a module. ==== Solution? ==== For now, I resolve the ambiguity by using "Package imports", i.e. annotate the ambiguous imports by the right package name. Is this the best solution? The ghc manual states, that the package import extension should not be necessary. I can think of another solution, by creating a dedicated package, which imports mtl:Control.Monad.* and re-exports them under another name, but that's even less elegant than package imports. What is the recommended way to deal with module name conflicts, such as this one? Regards, Arie BTW: how can I let the user edit a line of text, from a non-empty starting value for the text? (In other words, actually *edit* a line, not enter a new one.) I currently do this by adding the starting value to the user's history, so he/she can get it by pressing the up arrow key. This is clearly not optimal. From mito at panix.com Tue Mar 10 10:18:38 2009 From: mito at panix.com (Gregory Michael Travis) Date: Tue Mar 10 10:06:56 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot Message-ID: <20090310141838.0F42213804@panix1.panix.com> Maur??cio sed: > Hi, > > Here in Brazil we have a forest animal we name 'preguiça' -- literally, > lazyness. What better mascot we could have for Haskell? It lives (and > sleeps) in trees, and if you see the main picture in wikipedia articles > you can easily imagine the tree branch beeing replaced by a lambda: > > http://en.wikipedia.org/wiki/Sloth > > http://pt.wikipedia.org/wiki/Bicho-pregui%C3%A7a Perfect! From manlio_perillo at libero.it Tue Mar 10 11:34:28 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 10 11:23:02 2009 Subject: [Haskell-cafe] Style Guide for Haskell Code Message-ID: <49B68884.8000206@libero.it> After a quick search with Google, it seems that there is not yet an "official" document for Style Guide for Haskell Code. I was only able to found: http://www.cs.caltech.edu/courses/cs11/material/haskell/misc/haskell_style_guide.html http://urchin.earth.li/~ian/style/haskell.html http://github.com/tibbe/haskell-style-guide/tree/master and, of course, the GHC style guide. Any plans for a common document? Thanks Manlio Perillo From byorgey at seas.upenn.edu Tue Mar 10 11:50:40 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Tue Mar 10 11:38:58 2009 Subject: [Haskell-cafe] ANN: sparsebit 0.5 - Sparse Bitmaps for Pattern Match Coverage In-Reply-To: References: Message-ID: <20090310155040.GA2283@seas.upenn.edu> > > I was not able to make the haddock documentation appear in Hackage, > although I have no problem generating documentation using "cabal > haddock" locally. It would be nice if there is a way to see some > diagnose of warning or error messages why haddock failed on Hackage. It is there now. Packages uploaded to hackage are not built immediately on upload, but in batches. Sometimes you have to wait a few hours after uploading a package for the package and documentation to be built. -Brent From conor at strictlypositive.org Tue Mar 10 11:59:58 2009 From: conor at strictlypositive.org (Conor McBride) Date: Tue Mar 10 11:48:23 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde Message-ID: Apologies for crossposting. Please forward this message to individuals or lists who may be interested. In addition to the recently advertised PhD position at Strathclyde on "Reusability and Dependent Types", I am delighted to advertise the following PhD opportunity. {--------------------------------------------------------- -- Haskell Types with Numeric Constraints ---------------- ---------------------------------------------------------} We are grateful to Microsoft Research for their sponsorship of this project, which includes an internship, and with it the chance to make a real difference to world of principled but practical programming. The project investigates the practical and theoretical impact of extending Haskell's type system with numeric expressions (representing sizes, or ranges, or costs, for example) and constraints capturing richer safety properties than are currently managed by static typing. It has three strands: (1) to investigate type inference with numeric constraints, (2) to investigate new programming structures, patterns, and techniques which exploit numeric indexing, and (3) to study the performance benefits derivable from richer guarantees. A bright student could bring significant benefits to developers using Haskell, a language with increasing industrial traction ? not least at Microsoft. Work on the Glasgow Haskell Compiler, at Strathclyde! {---------------------------------------------------------} The position is fully funded, covering stipend, fees (at the home/EU rate), equipment, and travel, starting in October 2009. The closing date for applications is 15th April 2009. For further details, see: http://personal.cis.strath.ac.uk/~conor/phds/ or email me (conor@cis.strath.ac.uk). I look forward to hearing from you. Yours &c Conor McBride From nonowarn at gmail.com Tue Mar 10 12:06:58 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Tue Mar 10 11:55:20 2009 Subject: [Haskell-cafe] ANNOUNCE: torch-0.1 Message-ID: <0796FD07-184E-4AFF-90EB-391E9DC937D5@gmail.com> Hello, I have wrote and uploaded my unit test library (or framework) torch-0.1 on Hackage. With torch, We can write simple unit test and run like this: > import Test.Torch > > main = run $ do > ok (odd 1) "assertion" > is 42 (7*6) "equality assertion" > isBottom (error undefined) "check whether value is bottom" > ans <- liftIO (putStr "\n5 + 7 = " >> readLn) > is ans 12 "sanity check :)" Despite QuickCheck and HUnit, Why I wrote unit test library now? There is two reasons. 1. QuickCheck is not all-round QuickCheck is awesome. But I often can't write Property when I want to test things, like not pure function. Even for pure function, I can't write Property by thinking _laws_ behind that with probability about 0.5. When I can't write Property, I want to write unit test using HUnit. But for me, HUnit does not fit to my hands. Because it is annoying that writing list of test literally in source code and confusing operators (I still can't remember distinction between (@=?) and (@?=)) This means when I read test written in HUnit, I can't read this without Documentation. And I got an idea for expressing structure of tests from a blog post about Monoid and Writer Monad. 2. Try to realize an idea that Writer monad can be treated as Monoid (and list of Test is Monoid) I read sigfpe's great blog post (http://blog.sigfpe.com/2009/01/ haskell-monoids-and-their-uses.html) and hit upon the idea that considering Writer as Monoid, list of tests can be expressed with Monad. And I tried to realize it, and want to sympathize this idea with Haskellers. I think almost complete realizing this idea in the library. Those is why I wrote this library. And It is my first package on Hackage, I apologize for any wrong about packaging. I hope you'll enjoy this! Thanks, nonowarn From bulat.ziganshin at gmail.com Tue Mar 10 12:06:05 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 10 12:01:14 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: References: Message-ID: <771169282.20090310190605@gmail.com> Hello Conor, Tuesday, March 10, 2009, 6:59:58 PM, you wrote: > {--------------------------------------------------------- > -- Haskell Types with Numeric Constraints ---------------- > ---------------------------------------------------------} are you have in mind integrating results into production ghc versions? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From johan.tibell at gmail.com Tue Mar 10 12:20:15 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue Mar 10 12:08:34 2009 Subject: [Haskell-cafe] Style Guide for Haskell Code In-Reply-To: <49B68884.8000206@libero.it> References: <49B68884.8000206@libero.it> Message-ID: <90889fe70903100920x3fe48e6dpa55b4d2e045904cc@mail.gmail.com> On Tue, Mar 10, 2009 at 4:34 PM, Manlio Perillo wrote: > After a quick search with Google, it seems that there is not yet an > "official" document for Style Guide for Haskell Code. > > I was only able to found: > > http://www.cs.caltech.edu/courses/cs11/material/haskell/misc/haskell_style_guide.html > http://urchin.earth.li/~ian/style/haskell.html > http://github.com/tibbe/haskell-style-guide/tree/master I plan to polish my style guide and add some things I haven't covered in the coming weeks. I believe it for the most part codifies what's common practice in the Haskell community. Cheers, Johan From nonowarn at gmail.com Tue Mar 10 12:49:33 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Tue Mar 10 12:37:51 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: torch-0.1 In-Reply-To: <0796FD07-184E-4AFF-90EB-391E9DC937D5@gmail.com> References: <0796FD07-184E-4AFF-90EB-391E9DC937D5@gmail.com> Message-ID: On Wed, Mar 11, 2009 at 1:06 AM, Yusaku Hashimoto wrote: >> import Test.Torch >> >> main = run $ do >> ? ok (odd 1) "assertion" >> ? is 42 (7*6) "equality assertion" >> ? isBottom (error undefined) "check whether value is bottom" >> ? ans <- liftIO (putStr "\n5 + 7 = " >> readLn) >> ? is ans 12 "sanity check :)" Sorry, Above code doesn't work. I fixed this. But this code still don't work as I expected in output order: import Test.Torch import Control.Monad.Trans (liftIO) import System.IO main = run $ do liftIO $ hSetBuffering stdout NoBuffering ok (odd 1) "assertion" is 42 (7*6) "equality assertion" isBottom (undefined::Int) "check whether value is bottom" ans <- liftIO (putStr "\n5 + 7 = " >> readLn) is ans 12 "sanity check :)" From conor at strictlypositive.org Tue Mar 10 13:01:54 2009 From: conor at strictlypositive.org (Conor McBride) Date: Tue Mar 10 12:50:12 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: <771169282.20090310190605@gmail.com> References: <771169282.20090310190605@gmail.com> Message-ID: <0882FC7A-09CA-4DB7-A968-30F13EC3B7A2@strictlypositive.org> Hi Bulat, hi all, On 10 Mar 2009, at 16:06, Bulat Ziganshin wrote: > Hello Conor, > > Tuesday, March 10, 2009, 6:59:58 PM, you wrote: > >> {--------------------------------------------------------- >> -- Haskell Types with Numeric Constraints ---------------- >> ---------------------------------------------------------} > > are you have in mind integrating results into production ghc versions? Subject to rigorous quality control, community approval, and Official Permission, yes. We'll prototype first, of course, but the Microsoft sponsorship provides an ideal opportunity to work with GHC HQ on this. If we do a good job (so we need a good student) it should become part of the real deal. Only this morning, I was lecturing on combinators for 2-dimensional layout and apologizing for the need to manage the sizes for "perfect fitting" by "smart constructor" abstraction rather than typing. I really want to rectify that. I can imagine similar considerations affect hardware design libraries too, and goodness knows what else. Wire up numerical indexing to parametrized monads and not only are you cooking with gas, you might even know how much gas you're cooking with! So, yes. It's "type-level integers that don't suck", and associated programming techniques, to be delivered via GHC and associated libraries. This is a real opportunity to make a difference (and also to stare out the window and watch the sun setting on central Glasgow, unless it's raining, which today it isn't). All the best Conor From lists at qseep.net Tue Mar 10 13:36:30 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Tue Mar 10 13:24:49 2009 Subject: [Haskell-cafe] Distributing Linux binaries In-Reply-To: <1236643699.22402.341.camel@localhost> References: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> <20090309202637.GD28269@whirlpool.galois.com> <1236643699.22402.341.camel@localhost> Message-ID: <670e468e0903101036n75f46428t847302991de24b44@mail.gmail.com> Thanks folks for your replies. I did learn, from your e-mails and from the cabal documentation (example 9 on page http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/builders.htm), how to build a tarball with an executable and LICENSE file, via cabal copy. It would have been nice to include the documentation (user's guide) as well, but I don't know how to get cabal copy to put that into the bundle. Unfortunately, I don't feel it's of great use to the end user. Now they have a tarball with paths like /usr/local/bin/vintbas and /usr/local/share/doc/vintage-basic-1.0/LICENSE.txt. Untarring it gives a warning and strips the leading /, so it won't untar in root unless you CD to root first. And of course you have to have root access to do that. If you want to install it in your user dir, you'll have to make a substitution for the paths. You suggested I write my own install script. But certainly this is a common situation, and someone has made a generic install script for this sort of thing? As I've said I tried to make a Debian package, folowing two different cabal-to-debian instructions, and neither one worked. If it is a hurdle for me, I can imagine a lot of people are getting frustrated at trying to distribute their binaries on Linux. - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090310/97b544e1/attachment.htm From wanghanyi21 at hotmail.com Tue Mar 10 13:54:47 2009 From: wanghanyi21 at hotmail.com (wanghanyi) Date: Tue Mar 10 13:43:06 2009 Subject: [Haskell-cafe] Using FosSyDe to translate haskell to VHDL. Message-ID: Dear all, I have used ForSyDe to translate a Haskell script to VHDL for a while, and I have one problem by applying where-clause during the translation. I wrote a small function Plus2.hs which is implied as following addTwof :: ProcFun (Int32 -> Int32) addTwof = $(newProcFun [d|addTwof :: Int32 -> Int32 addTwof n = addOnef+1 where addOnef = n +1 |]) *Plus2> writeVHDL plus2SysDef *** Exception: VHDL Compilation Error: Untranslatable function: where constructs are not supported in functions: where addOnef_0 = n_1 GHC.Num.+ 1 in process function `addTwof' (created in Plus2) used by process `plus2Proc' belonging to system definition `plus2' (created in ) The compiling process was fine, but the script could not be translated into VHDL, like the error i mentioned above. Is there any way to solve this problem if a where-clause is a must. Thanks all. Hanyi _________________________________________________________________ Live SearchÊÓÆµËÑË÷£¬¿ìËÙ¼ìË÷ÊÓÆµµÄÀûÆ÷£¡ http://www.live.com/?scope=video -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/fa7fd02d/attachment.htm From dons at galois.com Tue Mar 10 14:28:30 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 14:17:44 2009 Subject: [Haskell-cafe] Distributing Linux binaries In-Reply-To: <670e468e0903101036n75f46428t847302991de24b44@mail.gmail.com> References: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> <20090309202637.GD28269@whirlpool.galois.com> <1236643699.22402.341.camel@localhost> <670e468e0903101036n75f46428t847302991de24b44@mail.gmail.com> Message-ID: <20090310182830.GA1016@whirlpool.galois.com> > If it is a hurdle for me, I can imagine a lot of people are getting frustrated > at trying to distribute their binaries on Linux. Yes. This is not a new observation :) -- Don From rendel at cs.au.dk Tue Mar 10 14:38:32 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Tue Mar 10 14:25:34 2009 Subject: [Haskell-cafe] digest and zlib on Windows Message-ID: <49B6B3A8.9030505@cs.au.dk> Hi Eugene, I run into some troubles with the digest package on Windows. On unix, digest binds to zlib, but on Windows, the relevant c files from zlib are included. However, in digest-0.0.0.4, two header files were missing which were needed for compilation on my machine. With these header files added (from digits-0.0.0.3), digest compiles fine. Unfortunately, the zlib package has the same approach of including c files from zlib on Windows. That means that I could not use both zlib and digest together, because they contained conflicting symbols. Unfortunately, pandoc requires both zlib and digest. I solved the problem by removing the cbits from digest, and instead require the zlib on Windows. In other words, I deleted the cbits subdirectory, and changed the last few lines of digest.cabal from if !os(windows) extra-libraries: z else c-sources: cbits/adler32.c cbits/crc32.c include-dirs: cbits install-includes: zlib.h to the following: if !os(windows) extra-libraries: z else build-depends: zlib With this change, everything seems to work fine for me. Tillmann From matthijs at stdin.nl Tue Mar 10 15:23:57 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Tue Mar 10 15:12:16 2009 Subject: [Haskell-cafe] Using FosSyDe to translate haskell to VHDL. In-Reply-To: References: Message-ID: <20090310192357.GA24302@katherina.student.utwente.nl> Hi Hany, > *Plus2> writeVHDL plus2SysDef > *** Exception: VHDL Compilation Error: Untranslatable function: where constructs are not supported in functions: > where addOnef_0 = n_1 GHC.Num.+ 1 > in process function `addTwof' (created in Plus2) used by process `plus2Proc' belonging to system definition `plus2' (created in ) I don't know much about ForSyDe, but it seems that where clauses simply aren't supported. Perhaps let expressions are? The would mean something like the following: addTwof :: ProcFun (Int32 -> Int32) addTwof = $(newProcFun [d|addTwof :: Int32 -> Int32 let addOnef = n +1 in addTwof n = addOnef+1 |]) (Not sure if this is completely valid code, I'm not too familiar with TH..). Gr. Matthijs -------------- 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/20090310/fd1f0600/attachment.bin From jupdike at gmail.com Tue Mar 10 15:41:18 2009 From: jupdike at gmail.com (Jared Updike) Date: Tue Mar 10 15:29:36 2009 Subject: [Haskell-cafe] Re: Logo Preferences In-Reply-To: <20090309115051.GA4250@matrix.chaos.earth.li> References: <49B4528F.4060306@semantic.org> <0dc9r4daiu6l3desr6br2qa2l6n2sgmgti@4ax.com> <3d96ac180903090413l4b1c1a61kbba0c7cb3b13119c@mail.gmail.com> <20090309115051.GA4250@matrix.chaos.earth.li> Message-ID: <8b108f950903101241v68610afay79fa5f298da138d3@mail.gmail.com> I agree that we should use the first round of voting to learn what the general consensus of the Haskell community is on a logo design "idea" (and to filter out the non-viable logos). In the spirit of bikeshedding, I would love to see---and would volunteer to spend part of a day editing, say, the top one or two logos, in Photoshop---generating numerous variations on fonts, colors (text, emblem and background), and relative font/emblem sizes. (Alternately, the original author of the favorite logo(s) could produce said variations.) Then I think we should vote on the final minor variations. I can *almost* picture a few of the current logos becoming the Final logo, but not As Is; there are many great ideas but some of them (or combinations of a few of them) could be improved in minor ways, bringing things (at least to me) up to professional level for a logo. (cf. the python.org logo) Jared. On 3/9/09, Ian Lynagh wrote: > On Mon, Mar 09, 2009 at 11:13:40AM +0000, Sebastian Sylvan wrote: > > > > Another reason condorcet voting is nice is that there is no need to group > > "similar" items together. > > > I think the plan is that once a logo "class" is chosen, we'll have > another vote for the actual colour scheme etc to be used, if applicable. > > Yes, we could have done this in a single vote, but then people would > need to spend time creating 30 variants of each logo, and we'd be > ranking 3000, rather than 100, options. > > > Thanks > > Ian > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Tue Mar 10 15:40:30 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 15:29:51 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <87vdqi862e.fsf@columbia.edu> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> Message-ID: <20090310194030.GB1077@whirlpool.galois.com> xj2106: > Alexander Dunlap writes: > > > - uvector, storablevector and vector are all designed for dealing with > > arrays. They *can* be used for characters/word8s but are not > > specialized for that purpose, do not deal with Unicode at all, and are > > probably worse at it. They are better for dealing with things that you > > would generally use arrays for. > > I think uvector only works with certain types that can be > unboxed, while storablevector works with all types that > instantiate Foreign.Storable.Storable. I don't know about > vector. From the description of vector, I have the That's interesting. I'd expect Storable and UA to have the same set of inhabitants. Is there any difference? > impression that it is quite unstable. How is it compared to > uvector and storablevector? I need one of those to work > with my code to possibly improve the efficiency. But I > can't use uvector, because I can't use unboxed types. Hmm? If you can write a Storable instance, you can write a UA instance. -- Don From bulat.ziganshin at gmail.com Tue Mar 10 15:49:46 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 10 15:41:25 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090310194030.GB1077@whirlpool.galois.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> Message-ID: <265663706.20090310224946@gmail.com> Hello Don, Tuesday, March 10, 2009, 10:40:30 PM, you wrote: >> I think uvector only works with certain types that can be >> unboxed, while storablevector works with all types that >> instantiate Foreign.Storable.Storable. I don't know about >> vector. From the description of vector, I have the > That's interesting. I'd expect Storable and UA to have the same set of > inhabitants. Is there any difference? if uavector use ghc's built-in unboxed array operations (as Data.Array.Unboxed does) then it's necessarily bounded to types supported by those operations btw, i have extended this set in my own library by making a class which has implementation using those operations but may be extended further. OTOH, nowadays when ForeignArrays becomes as fast as built-in ones, i don't see any reasons for these built-in operations at all -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dons at galois.com Tue Mar 10 16:01:31 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 15:50:39 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <265663706.20090310224946@gmail.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> Message-ID: <20090310200131.GC1077@whirlpool.galois.com> bulat.ziganshin: > Hello Don, > > Tuesday, March 10, 2009, 10:40:30 PM, you wrote: > > >> I think uvector only works with certain types that can be > >> unboxed, while storablevector works with all types that > >> instantiate Foreign.Storable.Storable. I don't know about > >> vector. From the description of vector, I have the > > > That's interesting. I'd expect Storable and UA to have the same set of > > inhabitants. Is there any difference? > > if uavector use ghc's built-in unboxed array operations (as > Data.Array.Unboxed does) then it's necessarily bounded to types > supported by those operations And what is Storable limited to? Ultimately they're all limited to the primops for reading and writing, and to what types we can encode in those. So: primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp {- instance Storable Double instance Storable Bool instance Storable Char instance Storable Int instance Storable Float ... -} {- instance UA () instance (UA a, UA b) => UA (a :*: b) instance UA Bool instance UA Char instance UA Int instance UA Float instance UA Double ... -} So what's a type that's Storable, but not writable in UA (or UArray or ..) -- Don From mads_lindstroem at yahoo.dk Tue Mar 10 16:08:15 2009 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Tue Mar 10 16:05:14 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: References: Message-ID: <1236715695.4361.6.camel@localhost.localdomain> Hi Maur??cio Great idea. I would love a toy one with a Lambda logo. I found one on Amazon http://www.amazon.com/Plush-Sloth-Bear-Cuddlekin-12/dp/B000FBLP76 , but without the logo. But we would of cause need one with Haskell logo printed upon it. I could not find a place with user-definable textile printing (if that is the right term in english) on plush sloth bears. Greetings, Mads > Hi, > > Here in Brazil we have a forest animal we name 'pregui?a' -- literally, > lazyness. What better mascot we could have for Haskell? It lives (and > sleeps) in trees, and if you see the main picture in wikipedia articles > you can easily imagine the tree branch beeing replaced by a lambda: > > http://en.wikipedia.org/wiki/Sloth > > http://pt.wikipedia.org/wiki/Bicho-pregui%C3%A7a > > Best, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Tue Mar 10 16:19:22 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 16:08:31 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <1236715695.4361.6.camel@localhost.localdomain> References: <1236715695.4361.6.camel@localhost.localdomain> Message-ID: <20090310201922.GD1077@whirlpool.galois.com> I thought this was our unofficial mascot: http://www.haskell.org/sitewiki/images/8/85/NarleyYeeaaahh.jpg Available in plush form: http://www.amazon.com/Narwhal-Plush-Stuffed-Animal-Toy/dp/B0011DFUGE/ref=sr_1_3?ie=UTF8&s=toys-and-games&qid=1236716339&sr=1-3 YEEAAAAHH! mads_lindstroem: > Hi Maur??cio > > Great idea. I would love a toy one with a Lambda logo. > > I found one on Amazon > http://www.amazon.com/Plush-Sloth-Bear-Cuddlekin-12/dp/B000FBLP76 , but > without the logo. > > But we would of cause need one with Haskell logo printed upon it. I > could not find a place with user-definable textile printing (if that is > the right term in english) on plush sloth bears. > > > Greetings, > > Mads > > > Hi, > > > > Here in Brazil we have a forest animal we name 'pregui?a' -- literally, > > lazyness. What better mascot we could have for Haskell? It lives (and > > sleeps) in trees, and if you see the main picture in wikipedia articles > > you can easily imagine the tree branch beeing replaced by a lambda: > > > > http://en.wikipedia.org/wiki/Sloth > > > > http://pt.wikipedia.org/wiki/Bicho-pregui%C3%A7a > > > > Best, > > Maur?cio > > > > _______________________________________________ > > 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 florin.craciun at durham.ac.uk Tue Mar 10 16:44:18 2009 From: florin.craciun at durham.ac.uk (CRACIUN F.) Date: Tue Mar 10 16:32:50 2009 Subject: [Haskell-cafe] TASE 2009 - CALL FOR POSTER PRESENTATIONS Message-ID: <1C7F51B7A4A4F54389A69794AD79A24D0199C6A9@EXDUR3.mds.ad.dur.ac.uk> TASE 2009 - CALL FOR POSTER PRESENTATIONS ****************************************** * 3rd IEEE International Symposium on * Theoretical Aspects of Software Engineering * (TASE 2009) * 29-31 July 2009, Tianjin, China * http://www.dur.ac.uk/ieee.tase2009 * * For more information email: IEEE.TASE2009@durham.ac.uk ********************************************************** TASE 2009 will include a poster session during the conference. The session aims to give students and researchers an opportunity to present their research to the community, and to get responses from other researchers. SCOPE: Poster presentations are sought in all theoretical aspects of software engineering, including (but not limited to): * Requirements Engineering * Specification and Verification * Program Analysis * Software Testing * Model-Driven Engineering * Software Architectures and Design * Aspect and Object Orientation * Embedded and Real-Time Systems * Software Processes and Workflows * Component-Based Software Engineering * Software Safety, Security and Reliability * Reverse Engineering and Software Maintenance * Service-Oriented Computing * Semantic Web and Web Services * Type System and Theory * Program Logics and Calculus * Dependable Concurrency * Software Model Checking SUBMISSION PROCESS: A Poster proposal consists of: - a 50 word or less short abstract that summarizes the content of the poster - a set of keywords describing the technical area of the work - a two-page extended abstract, suitable for inclusion in the TASE 2009 conference proceedings. All abstracts must adhere to the two-column IEEE format. All Poster proposals are to be submitted by email to IEEE.TASE2009@durham.ac.uk. The file containing the two-page extended abstract must be in .pdf or .ps format. Upon acceptance, at least one of the authors must register with the TASE2009 conference in order to have their extended abstract included in the conference proceedings. Once registered, a bulletin board space of A1 paper size (594 mm wide and 841 mm high) will be provided for each presentation. In addition to the camera-ready version of the extended abstract, the authors are also requested to submit their poster of A1 paper size (594 mm wide and 841 mm high) for backup. An A1 poster sample template is available at http://www.dur.ac.uk/ieee.tase2009/poster.a1.ppt for authors to download. The authors can prepare 8 individual slides, save them in .jpg format and then place them on the above A1 sample. The Poster presenter will need to print out their Poster in advance and bring it to the conference for the Poster session. POSTER CONTENT: A small selection committee led by the Poster Chair will evaluate the poster proposals based on their contributions and on how effectively they communicate those contributions. All posters should include the following information: - The purpose and goals of the work. - Any background and motivation information needed to understand the work. - A summary of the contribution and/or results, in sufficient detail for a viewer to understand the work and/or results; especially key details, results and contributions, or the anticipated contributions if the work is at an early stage. - The relationship to other related efforts, where appropriate. - Where to find additional information. This should include (but is not restricted to): a web site where viewers can go to find additional information about the work, how to contact the authors (including email addresses), citations for any papers, books, or other materials that provide additional information. POSTER COMPETITION: A poster competition will be organised during the poster session. A panel of experts will be formed as referees for the competition. Awards will be given to the winners of the competition. IMPORTANT DATES: Poster proposals submission: April 22, 2009 Acceptance/rejection notification: May 6, 2009 Camera-ready version and Poster due: May 13, 2009 TASE 2009 Conference: July 29-31, 2009 CONTACT: For questions or requests, please contact the TASE 2009 poster chair, Florin Craciun (IEEE.TASE2009@durham.ac.uk). Please mention "poster session" in the subject of your email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090310/509c3a42/attachment.htm From vanenkj at gmail.com Tue Mar 10 16:49:54 2009 From: vanenkj at gmail.com (John Van Enk) Date: Tue Mar 10 16:38:11 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <20090310201922.GD1077@whirlpool.galois.com> References: <1236715695.4361.6.camel@localhost.localdomain> <20090310201922.GD1077@whirlpool.galois.com> Message-ID: Perhaps we could make a sloth variant clinging to a tree branch then replace the YEAAAAHH!! with YAAAWWWN!! /jve On Tue, Mar 10, 2009 at 4:19 PM, Don Stewart wrote: > I thought this was our unofficial mascot: > > http://www.haskell.org/sitewiki/images/8/85/NarleyYeeaaahh.jpg > > Available in plush form: > > > http://www.amazon.com/Narwhal-Plush-Stuffed-Animal-Toy/dp/B0011DFUGE/ref=sr_1_3?ie=UTF8&s=toys-and-games&qid=1236716339&sr=1-3 > > YEEAAAAHH! > > mads_lindstroem: > > Hi Maur??cio > > > > Great idea. I would love a toy one with a Lambda logo. > > > > I found one on Amazon > > http://www.amazon.com/Plush-Sloth-Bear-Cuddlekin-12/dp/B000FBLP76 , but > > without the logo. > > > > But we would of cause need one with Haskell logo printed upon it. I > > could not find a place with user-definable textile printing (if that is > > the right term in english) on plush sloth bears. > > > > > > Greetings, > > > > Mads > > > > > Hi, > > > > > > Here in Brazil we have a forest animal we name 'pregui?a' -- literally, > > > lazyness. What better mascot we could have for Haskell? It lives (and > > > sleeps) in trees, and if you see the main picture in wikipedia articles > > > you can easily imagine the tree branch beeing replaced by a lambda: > > > > > > http://en.wikipedia.org/wiki/Sloth > > > > > > http://pt.wikipedia.org/wiki/Bicho-pregui%C3%A7a > > > > > > Best, > > > Maur?cio > > > > > > _______________________________________________ > > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090310/a2ef5417/attachment.htm From aeyakovenko at gmail.com Tue Mar 10 16:50:27 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Tue Mar 10 16:38:44 2009 Subject: [Haskell-cafe] do nmergeIO or mergeIO preserve order? Message-ID: do nmergeIO or mergeIO preserve order? or not preserve order? From xj2106 at columbia.edu Tue Mar 10 16:52:50 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Tue Mar 10 16:41:09 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090310200131.GC1077@whirlpool.galois.com> (Don Stewart's message of "Tue, 10 Mar 2009 13:01:31 -0700") References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> Message-ID: <87r61585i5.fsf@columbia.edu> Don Stewart writes: > And what is Storable limited to? > > Ultimately they're all limited to the primops for reading and writing, > and to what types we can encode in those. So: > > primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp > ... > {- > instance Storable Double > instance Storable Bool > instance Storable Char > instance Storable Int > instance Storable Float > ... > -} > > {- > > instance UA () > instance (UA a, UA b) => UA (a :*: b) > instance UA Bool > instance UA Char > instance UA Int > instance UA Float > instance UA Double > ... > -} > > So what's a type that's Storable, but not writable in UA (or UArray or ..) So it's me who understand it wrong. If I want some high performance array with elements of custom data type, I'm stuck with Array, anyway? Is it possible to make instance UA UserDefinedDataType I'm not sure how to do that. Can you give me some clarification? Thanks, Xiao-Yong -- c/* __o/* <\ * (__ */\ < From bulat.ziganshin at gmail.com Tue Mar 10 16:55:35 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 10 16:51:32 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090310200131.GC1077@whirlpool.galois.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> Message-ID: <1815851200.20090310235535@gmail.com> Hello Don, Tuesday, March 10, 2009, 11:01:31 PM, you wrote: >> if uavector use ghc's built-in unboxed array operations (as >> Data.Array.Unboxed does) then it's necessarily bounded to types >> supported by those operations > And what is Storable limited to? > Ultimately they're all limited to the primops for reading and writing, the full story: ghc up to 6.6 has slow access to ForeignArrays, as you may recall therefore, those primitives was added. ByteArra# plus those primitives was the only way to have unboxed arrays with fast access starting with 6.6, ForeignArray access is no-op, so we can just use obvious Ptr operations (via Storable class) to get unboxed arrays fast access. so, no more need for those special ByteArray# access operations but Array library still old, so any effort based on its spources, got the same restrictions also, ByteArray# may be unpinned, but afaik, this isn't really important - it can be coerced to Ptr for the period of one operation -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Tue Mar 10 17:12:13 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 10 17:00:42 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <87r61585i5.fsf@columbia.edu> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <87r61585i5.fsf@columbia.edu> Message-ID: <1439221903.20090311001213@gmail.com> Hello Xiao-Yong, Tuesday, March 10, 2009, 11:52:50 PM, you wrote: > So it's me who understand it wrong. If I want some high > performance array with elements of custom data type, I'm > stuck with Array, anyway? ForeignArray will be the best here. just make you type instance of Storable. if you need *movable* arrays, you will have to implement your own array datatype or use ArrayRef library and declare your type as instance of Unboxed -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dons at galois.com Tue Mar 10 17:12:07 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 17:01:18 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <1815851200.20090310235535@gmail.com> References: <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> Message-ID: <20090310211207.GF1077@whirlpool.galois.com> bulat.ziganshin: > Hello Don, > > Tuesday, March 10, 2009, 11:01:31 PM, you wrote: > > >> if uavector use ghc's built-in unboxed array operations (as > >> Data.Array.Unboxed does) then it's necessarily bounded to types > >> supported by those operations > > > And what is Storable limited to? > > > Ultimately they're all limited to the primops for reading and writing, > > the full story: > > ghc up to 6.6 has slow access to ForeignArrays, as you may recall > > therefore, those primitives was added. ByteArra# plus those primitives > was the only way to have unboxed arrays with fast access > > starting with 6.6, ForeignArray access is no-op, so we can just use > obvious Ptr operations (via Storable class) to get unboxed arrays fast > access. so, no more need for those special ByteArray# access operations > > but Array library still old, so any effort based on its spources, got > the same restrictions > > also, ByteArray# may be unpinned, but afaik, this isn't really > important - it can be coerced to Ptr for the period of one operation Right, so my point stands: there's no difference now. If you can write a Storable instance, you can write a UA et al instance. And GHC 6.6 was released what, 11 October 2006? So this has been the case for a long time. -- Don From dons at galois.com Tue Mar 10 17:12:47 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 17:01:55 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <87r61585i5.fsf@columbia.edu> References: <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <87r61585i5.fsf@columbia.edu> Message-ID: <20090310211247.GG1077@whirlpool.galois.com> xj2106: > Don Stewart writes: > > > And what is Storable limited to? > > > > Ultimately they're all limited to the primops for reading and writing, > > and to what types we can encode in those. So: > > > > primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp > > ... > > {- > > instance Storable Double > > instance Storable Bool > > instance Storable Char > > instance Storable Int > > instance Storable Float > > ... > > -} > > > > {- > > > > instance UA () > > instance (UA a, UA b) => UA (a :*: b) > > instance UA Bool > > instance UA Char > > instance UA Int > > instance UA Float > > instance UA Double > > ... > > -} > > > > So what's a type that's Storable, but not writable in UA (or UArray or ..) > > So it's me who understand it wrong. If I want some high > performance array with elements of custom data type, I'm > stuck with Array, anyway? > > Is it possible to make > > instance UA UserDefinedDataType > > I'm not sure how to do that. Can you give me some > clarification? Yes, you can do that. This is the case for most of the new array libraries. -- Don From bulat.ziganshin at gmail.com Tue Mar 10 17:15:40 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 10 17:04:13 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090310211207.GF1077@whirlpool.galois.com> References: <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> <20090310211207.GF1077@whirlpool.galois.com> Message-ID: <732086550.20090311001540@gmail.com> Hello Don, Wednesday, March 11, 2009, 12:12:07 AM, you wrote: > Right, so my point stands: there's no difference now. If you can write a > Storable instance, you can write a UA et al instance. yes, if there is some class provided for this and not just hard-coded 4 or so base types > And GHC 6.6 was released what, 11 October 2006? So this has been the > case for a long time. unfortunately, Array library unboxed arrays still aren't based on any Unboxable *class* -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From steve at fenestra.com Tue Mar 10 17:17:55 2009 From: steve at fenestra.com (Steve Schafer) Date: Tue Mar 10 17:06:11 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <1236715695.4361.6.camel@localhost.localdomain> References: <1236715695.4361.6.camel@localhost.localdomain> Message-ID: On Tue, 10 Mar 2009 21:08:15 +0100, you wrote: >I found one on Amazon >http://www.amazon.com/Plush-Sloth-Bear-Cuddlekin-12/dp/B000FBLP76 , but >without the logo. > >But we would of cause need one with Haskell logo printed upon it. I >could not find a place with user-definable textile printing (if that is >the right term in english) on plush sloth bears. A sloth bear is a kind of bear, not a sloth. Amazon also has some sloth stuffed animals, too. If you get one that's reasonably large, then you can get a lambda-imprinted Cafe Press t-shirt in an infant size that would fit it. Steve Schafer Fenestra Technologies Corp. http://www.fenestra.com/ From xj2106 at columbia.edu Tue Mar 10 17:28:45 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Tue Mar 10 17:17:04 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090310211247.GG1077@whirlpool.galois.com> (Don Stewart's message of "Tue, 10 Mar 2009 14:12:47 -0700") References: <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <87r61585i5.fsf@columbia.edu> <20090310211247.GG1077@whirlpool.galois.com> Message-ID: <87mybt83ua.fsf@columbia.edu> Don Stewart writes: >> instance UA UserDefinedDataType >> >> I'm not sure how to do that. Can you give me some >> clarification? > > Yes, you can do that. This is the case for most of the new array > libraries. It goes beyond my current knowledge, now. How do you define a custom data type as an instance of UA or Storable? Xiao-Yong -- c/* __o/* <\ * (__ */\ < From lrpalmer at gmail.com Tue Mar 10 17:33:26 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Mar 10 17:21:44 2009 Subject: [Haskell-cafe] do nmergeIO or mergeIO preserve order? In-Reply-To: References: Message-ID: <7ca3f0160903101433y1850a8e8te1029164d349e565@mail.gmail.com> Although it is not formally specified, my intuition for the specification is that order is preserved within each of the lists. Luke On Tue, Mar 10, 2009 at 2:50 PM, Anatoly Yakovenko wrote: > do nmergeIO or mergeIO preserve order? or not preserve order? > _______________________________________________ > 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/20090310/f4bf389f/attachment.htm From aeyakovenko at gmail.com Tue Mar 10 17:41:11 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Tue Mar 10 17:29:29 2009 Subject: [Haskell-cafe] do nmergeIO or mergeIO preserve order? In-Reply-To: <7ca3f0160903101433y1850a8e8te1029164d349e565@mail.gmail.com> References: <7ca3f0160903101433y1850a8e8te1029164d349e565@mail.gmail.com> Message-ID: Hmm, yea, actually that makes sense. What i am looking for is something that maps over a list and returns the list in order which the values are evaluated. looks like i can implement that pretty easily with unamb. On Tue, Mar 10, 2009 at 2:33 PM, Luke Palmer wrote: > Although it is not formally specified, my intuition for the specification is > that order is preserved within each of the lists. > > Luke > > On Tue, Mar 10, 2009 at 2:50 PM, Anatoly Yakovenko > wrote: >> >> do nmergeIO or mergeIO preserve order? or not preserve order? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lrpalmer at gmail.com Tue Mar 10 17:44:07 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Mar 10 17:32:25 2009 Subject: [Haskell-cafe] do nmergeIO or mergeIO preserve order? In-Reply-To: References: <7ca3f0160903101433y1850a8e8te1029164d349e565@mail.gmail.com> Message-ID: <7ca3f0160903101444g4035bcefuf2c9bd65a0d2922f@mail.gmail.com> I think nmergeIO . map (:[]) should do the trick. Luke On Tue, Mar 10, 2009 at 3:41 PM, Anatoly Yakovenko wrote: > Hmm, yea, actually that makes sense. What i am looking for is > something that maps over a list and returns the list in order which > the values are evaluated. looks like i can implement that pretty > easily with unamb. > > On Tue, Mar 10, 2009 at 2:33 PM, Luke Palmer wrote: > > Although it is not formally specified, my intuition for the specification > is > > that order is preserved within each of the lists. > > > > Luke > > > > On Tue, Mar 10, 2009 at 2:50 PM, Anatoly Yakovenko < > aeyakovenko@gmail.com> > > wrote: > >> > >> do nmergeIO or mergeIO preserve order? or not preserve order? > >> _______________________________________________ > >> 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/20090310/270d6850/attachment.htm From dons at galois.com Tue Mar 10 17:48:35 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 17:37:48 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <732086550.20090311001540@gmail.com> References: <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> <20090310211207.GF1077@whirlpool.galois.com> <732086550.20090311001540@gmail.com> Message-ID: <20090310214835.GH1077@whirlpool.galois.com> bulat.ziganshin: > Hello Don, > > Wednesday, March 11, 2009, 12:12:07 AM, you wrote: > > > Right, so my point stands: there's no difference now. If you can write a > > Storable instance, you can write a UA et al instance. > > yes, if there is some class provided for this and not just hard-coded > 4 or so base types That's right. For example (supporting even pairs): instance (RealFloat a, UA a) => UA (Complex a) where newtype UArr (Complex a) = UAComplex (UArr (a :*: a)) newtype MUArr (Complex a) s = MUAComplex (MUArr (a :*: a) s) > > And GHC 6.6 was released what, 11 October 2006? So this has been the > > case for a long time. > > unfortunately, Array library unboxed arrays still aren't based on any > Unboxable *class* Hmm. Aren't all the array library types based on MArray and IArray? So I can define my own say, new STUArray element type by writing an instance of MArray for it. Like so: {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE CPP #-} -- get at low level representation stuff import Data.Array.Base import GHC.IOBase import GHC.ST ( ST(..), runST ) import GHC.Prim import GHC.Base import GHC.Word import GHC.Ptr import GHC.Float import GHC.Stable import GHC.Int import GHC.Word import Data.Array.Unboxed -- helpers import Data.Bits import Text.Printf import System.Environment import Control.Monad -- portable to 32 bit or 64 bit #include -- define a new data type we wish to store in unboxed arrays data Boolean = IsTrue | IsFalse deriving (Eq, Ord, Enum, Show, Bounded) -- write a program using an unboxed array of these things main = do n <- getArgs >>= readIO . head :: IO Int mapM_ (\i -> sieve (10000 `shiftL` (n-i))) [0, 1, 2] -- Nsieve with bit packing of a custom MyBool type. sieve n = do let r = runST (do a <- newArray (2,n) IsTrue :: ST s (STUArray s Int Boolean) go a n 2 0) printf "Primes up to %8d %8d\n" (n::Int) (r::Int) :: IO () go !a !}m !n !c | n == m = return c | otherwise = do e <- unsafeRead a n if e == IsTrue then let loop j | j < m = do x <- unsafeRead a j when (x == IsTrue) $ unsafeWrite a j IsFalse loop (j+n) | otherwise = go a m (n+1) (c+1) in loop (n `shiftL` 1) else go a m (n+1) c -- -- Create a new unboxed representation for MyBool -- We choose to use bit packing, storing them in a W# -- instance MArray (STUArray s) Boolean (ST s) where getBounds (STUArray l u _ _) = return (l,u) getNumElements (STUArray _ _ n _) = return n newArray (l,u) initialValue = ST $ \s1# -> case safeRangeSize (l,u) of { n@(I# n#) -> case newByteArray# (bOOL_SCALE n#) s1# of { (# s2#, marr# #) -> case bOOL_WORD_SCALE n# of { n'# -> let loop i# s3# | i# ==# n'# = s3# | otherwise = case writeWordArray# marr# i# e# s3# of { s4# -> loop (i# +# 1#) s4# } in case loop 0# s2# of { s3# -> (# s3#, STUArray l u n marr# #) }}}} where W# e# = if initialValue == IsTrue then maxBound else 0 unsafeNewArray_ (l,u) = unsafeNewArraySTUArray_ (l,u) bOOL_SCALE newArray_ arrBounds = newArray arrBounds IsFalse unsafeRead (STUArray _ _ _ marr#) (I# i#) = ST $ \s1# -> case readWordArray# marr# (bOOL_INDEX i#) s1# of { (# s2#, e# #) -> (# s2#, case (e# `and#` bOOL_BIT i#) `neWord#` int2Word# 0# of True -> IsTrue ; _ -> IsFalse #) } unsafeWrite (STUArray _ _ _ marr#) (I# i#) e = ST $ \s1# -> case bOOL_INDEX i# of { j# -> case readWordArray# marr# j# s1# of { (# s2#, old# #) -> case if e == IsTrue then old# `or#` bOOL_BIT i# else old# `and#` bOOL_NOT_BIT i# of { e# -> case writeWordArray# marr# j# e# s2# of { s3# -> (# s3#, () #) }}}} From bulat.ziganshin at gmail.com Tue Mar 10 17:52:38 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 10 17:41:17 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <87mybt83ua.fsf@columbia.edu> References: <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <87r61585i5.fsf@columbia.edu> <20090310211247.GG1077@whirlpool.galois.com> <87mybt83ua.fsf@columbia.edu> Message-ID: <192110823.20090311005238@gmail.com> Hello Xiao-Yong, Wednesday, March 11, 2009, 12:28:45 AM, you wrote: > It goes beyond my current knowledge, now. How do you define > a custom data type as an instance of UA or Storable? just look at existing instances. basically, for complex data type, you just use instances for its basic types, plus you need to calculate offset of second and following fields (using sizeOf in Storable class) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Tue Mar 10 17:54:34 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 10 17:43:05 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090310214835.GH1077@whirlpool.galois.com> References: <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> <20090310211207.GF1077@whirlpool.galois.com> <732086550.20090311001540@gmail.com> <20090310214835.GH1077@whirlpool.galois.com> Message-ID: <9310494390.20090311005434@gmail.com> Hello Don, Wednesday, March 11, 2009, 12:48:35 AM, you wrote: >> unfortunately, Array library unboxed arrays still aren't based on any >> Unboxable *class* > Hmm. Aren't all the array library types based on MArray and IArray? > So I can define my own say, new STUArray element type by writing an instance of > MArray for it. Like so: yes, you can, just this definition duplicates too much code -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dons at galois.com Tue Mar 10 17:55:09 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 17:44:17 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <9310494390.20090311005434@gmail.com> References: <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> <20090310211207.GF1077@whirlpool.galois.com> <732086550.20090311001540@gmail.com> <20090310214835.GH1077@whirlpool.galois.com> <9310494390.20090311005434@gmail.com> Message-ID: <20090310215509.GI1077@whirlpool.galois.com> bulat.ziganshin: > Hello Don, > > Wednesday, March 11, 2009, 12:48:35 AM, you wrote: > > >> unfortunately, Array library unboxed arrays still aren't based on any > >> Unboxable *class* > > > Hmm. Aren't all the array library types based on MArray and IArray? > > > So I can define my own say, new STUArray element type by writing an instance of > > MArray for it. Like so: > > yes, you can, just this definition duplicates too much code Ah yes. Then in that case that is indeed true. Array / UArray aren't as extensible as the newer systems modelled on Storable (like UA in vector/uvector). From manlio_perillo at libero.it Tue Mar 10 18:28:13 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 10 18:16:35 2009 Subject: [Haskell-cafe] ByteString in patterns Message-ID: <49B6E97D.7080409@libero.it> Hi. Using normal String type I can define a pattern like: > let foo "baz" = 777 > foo "baz" 777 But if I want to use ByteString, what should I do? This seems impossible, since ByteString data constructor is not available. Thanks Manlio Perillo From bos at serpentine.com Tue Mar 10 18:39:43 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Mar 10 18:28:01 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <49B6E97D.7080409@libero.it> References: <49B6E97D.7080409@libero.it> Message-ID: On Tue, Mar 10, 2009 at 3:28 PM, Manlio Perillo wrote: > This seems impossible, since ByteString data constructor is not available. > You can use view patterns, per http://www.serpentine.com/blog/2009/01/11/fun-with-haskell-view-patterns/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090310/5b9a39cc/attachment.htm From bulat.ziganshin at gmail.com Tue Mar 10 18:40:35 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Mar 10 18:29:20 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <49B6E97D.7080409@libero.it> References: <49B6E97D.7080409@libero.it> Message-ID: <1919092209.20090311014035@gmail.com> Hello Manlio, Wednesday, March 11, 2009, 1:28:13 AM, you wrote: > Using normal String type I can define a pattern like: > But if I want to use ByteString, what should I do? > This seems impossible, since ByteString data constructor is not available. for numeric types, it works via Num instances. we have now IsString type, may be it provides the same feature? i.e., are you tried? :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dons at galois.com Tue Mar 10 18:42:59 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 18:32:08 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <49B6E97D.7080409@libero.it> References: <49B6E97D.7080409@libero.it> Message-ID: <20090310224259.GK1077@whirlpool.galois.com> manlio_perillo: > Hi. > > Using normal String type I can define a pattern like: > > > let foo "baz" = 777 > > foo "baz" > 777 > > > But if I want to use ByteString, what should I do? > This seems impossible, since ByteString data constructor is not available. -XOverloadedStrings e.g. {-# LANGUAGE OverloadedStrings #-} import qualified Data.ByteString.Char8 as C isMatch :: C.ByteString -> Bool isMatch "match" = True isMatch _ = False main = print . map isMatch . C.lines =<< C.getContents From aeyakovenko at gmail.com Tue Mar 10 19:31:55 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Tue Mar 10 19:20:12 2009 Subject: [Haskell-cafe] do nmergeIO or mergeIO preserve order? In-Reply-To: <7ca3f0160903101444g4035bcefuf2c9bd65a0d2922f@mail.gmail.com> References: <7ca3f0160903101433y1850a8e8te1029164d349e565@mail.gmail.com> <7ca3f0160903101444g4035bcefuf2c9bd65a0d2922f@mail.gmail.com> Message-ID: i think this would still force me to evailuate the whole list, right? i would want something that pipes the results into a channel that i can lazyly read as the results are available. On Tue, Mar 10, 2009 at 2:44 PM, Luke Palmer wrote: > I think nmergeIO . map (:[]) should do the trick. > > Luke > > On Tue, Mar 10, 2009 at 3:41 PM, Anatoly Yakovenko > wrote: >> >> Hmm, yea, actually that makes sense. ?What i am looking for is >> something that maps over a list and returns the list in order which >> the values are evaluated. ?looks like i can implement that pretty >> easily with unamb. >> >> On Tue, Mar 10, 2009 at 2:33 PM, Luke Palmer wrote: >> > Although it is not formally specified, my intuition for the >> > specification is >> > that order is preserved within each of the lists. >> > >> > Luke >> > >> > On Tue, Mar 10, 2009 at 2:50 PM, Anatoly Yakovenko >> > >> > wrote: >> >> >> >> do nmergeIO or mergeIO preserve order? or not preserve order? >> >> _______________________________________________ >> >> Haskell-Cafe mailing list >> >> Haskell-Cafe@haskell.org >> >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> > > > From manlio_perillo at libero.it Tue Mar 10 19:35:46 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 10 19:24:14 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <20090310224259.GK1077@whirlpool.galois.com> References: <49B6E97D.7080409@libero.it> <20090310224259.GK1077@whirlpool.galois.com> Message-ID: <49B6F952.2080304@libero.it> Don Stewart ha scritto: > manlio_perillo: >> Hi. >> >> Using normal String type I can define a pattern like: >> >>> let foo "baz" = 777 >>> foo "baz" >> 777 >> >> >> But if I want to use ByteString, what should I do? >> This seems impossible, since ByteString data constructor is not available. > > -XOverloadedStrings > Perfect, thanks. Is this supported by other Haskell implementations, or planned for Haskell'? Manlio From dons at galois.com Tue Mar 10 19:43:31 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 19:32:42 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <49B6F952.2080304@libero.it> References: <49B6E97D.7080409@libero.it> <20090310224259.GK1077@whirlpool.galois.com> <49B6F952.2080304@libero.it> Message-ID: <20090310234330.GO1077@whirlpool.galois.com> manlio_perillo: > Don Stewart ha scritto: >> manlio_perillo: >>> Hi. >>> >>> Using normal String type I can define a pattern like: >>> >>>> let foo "baz" = 777 >>>> foo "baz" >>> 777 >>> >>> But if I want to use ByteString, what should I do? >>> This seems impossible, since ByteString data constructor is not available. >> >> -XOverloadedStrings > > Perfect, thanks. > > Is this supported by other Haskell implementations, or planned for Haskell'? Not as far as I know. It was added to GHC just over 2 years ago, http://article.gmane.org/gmane.comp.lang.haskell.cvs.all/31022 and isn't terribly widely used. Probably ByteString literals are the current main use (along with interesting EDSL applications, which was the original motivation afaik). -- Don From lrpalmer at gmail.com Tue Mar 10 19:49:41 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Mar 10 19:37:59 2009 Subject: [Haskell-cafe] do nmergeIO or mergeIO preserve order? In-Reply-To: References: <7ca3f0160903101433y1850a8e8te1029164d349e565@mail.gmail.com> <7ca3f0160903101444g4035bcefuf2c9bd65a0d2922f@mail.gmail.com> Message-ID: <7ca3f0160903101649g66c8e285p9bb8d471cb6021de@mail.gmail.com> Oh, you're right. Here are some thoughts. You want the list you get back to only contain values in WHNF. This differs from mergeIO & co., which are simply evaluating the spine of the list, and don't even look at the values. I would also consider it bad style to be fully polymorphic in this case, as you require polymorphic seq, which is evil (though I don't have the space to argue this right now :-). Unamb would be bad style, also, since your semantics are nondeterministic and so you wouldn't meet the precondition. Surely your result would have to be in IO. ("amb" would be okay) Here is how I would do it: chooseIO :: [IO a] -> IO [a] chooseIO xs = do chan <- newChan let eval io = forkIO (io >>= writeChan chan) forkIO $ mapM_ eval xs getChanContents chan (The list never ends in this case, even when xs is finite. I think it's possible to make the result finite with the argument is, and maintain good GC properties, but it would take some care) The reason I take a list of [IO a] is to avoid polymorphic seq; the elements of the list have built in what it means to evaluate them. This also buys you more flexibility (but also fewer guarantees...). For the working Haskeller, it is safe to avoid all this pedantic zealotry... I'm just being a purist. Luke On Tue, Mar 10, 2009 at 5:31 PM, Anatoly Yakovenko wrote: > i think this would still force me to evailuate the whole list, right? > i would want something that pipes the results into a channel that i > can lazyly read as the results are available. > > On Tue, Mar 10, 2009 at 2:44 PM, Luke Palmer wrote: > > I think nmergeIO . map (:[]) should do the trick. > > > > Luke > > > > On Tue, Mar 10, 2009 at 3:41 PM, Anatoly Yakovenko < > aeyakovenko@gmail.com> > > wrote: > >> > >> Hmm, yea, actually that makes sense. What i am looking for is > >> something that maps over a list and returns the list in order which > >> the values are evaluated. looks like i can implement that pretty > >> easily with unamb. > >> > >> On Tue, Mar 10, 2009 at 2:33 PM, Luke Palmer > wrote: > >> > Although it is not formally specified, my intuition for the > >> > specification is > >> > that order is preserved within each of the lists. > >> > > >> > Luke > >> > > >> > On Tue, Mar 10, 2009 at 2:50 PM, Anatoly Yakovenko > >> > > >> > wrote: > >> >> > >> >> do nmergeIO or mergeIO preserve order? or not preserve order? > >> >> _______________________________________________ > >> >> 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/20090310/67c9edb1/attachment.htm From manlio_perillo at libero.it Tue Mar 10 19:53:10 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 10 19:41:35 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <20090310234330.GO1077@whirlpool.galois.com> References: <49B6E97D.7080409@libero.it> <20090310224259.GK1077@whirlpool.galois.com> <49B6F952.2080304@libero.it> <20090310234330.GO1077@whirlpool.galois.com> Message-ID: <49B6FD66.7040402@libero.it> Don Stewart ha scritto: > [...] >>> -XOverloadedStrings >> Perfect, thanks. >> >> Is this supported by other Haskell implementations, or planned for Haskell'? > > Not as far as I know. It was added to GHC just over 2 years ago, > > http://article.gmane.org/gmane.comp.lang.haskell.cvs.all/31022 > > and isn't terribly widely used. Probably ByteString literals are the > current main use (along with interesting EDSL applications, which was > the original motivation afaik). > Ok, thanks. In my case it just makes the code nicer; it is not a critical feature. Manlio From rj248842 at hotmail.com Tue Mar 10 19:58:45 2009 From: rj248842 at hotmail.com (R J) Date: Tue Mar 10 19:47:03 2009 Subject: [Haskell-cafe] Horner's Rule, foldl, and direct recursion Message-ID: Given a list of decimal digits represented by Integers between 0 and 9--for example, the list [1,2,3, 4]--with the high-order digit at the left, the list can be converted to a decimal integer n using the following formula, an instance of Horner's rule: n = 10 * 10 * 10 * 1 + 10 * 10 * 2 + 10 * 3 + 4 = 10 * (10 * 10 * 1 + 10 * 2 + 3) + 4 = 10 * (10 *(10 * 1 + 2) + 3) + 4 In Haskell, the foldl function neatly captures this pattern: horner :: [Integer] -> Integer horner = myFoldl timesPlus 0 where timesPlus x y = 10 * x + y What is the direct recursive calculation of this function without using the call to foldl? In other words, what's the second equation of: horner2 :: [Integer] -> Integer horner2 [] = 0 horner2 (x : xs) = ? Given that we've already got the definition using foldl, it ought to be easy to express the second equation, but it's eluding me. Thanks. _________________________________________________________________ Windows Live? Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090310/380ea307/attachment.htm From manlio_perillo at libero.it Tue Mar 10 20:02:13 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 10 19:50:37 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <20090310224259.GK1077@whirlpool.galois.com> References: <49B6E97D.7080409@libero.it> <20090310224259.GK1077@whirlpool.galois.com> Message-ID: <49B6FF85.4070104@libero.it> Don Stewart ha scritto: > [...] > {-# LANGUAGE OverloadedStrings #-} > > import qualified Data.ByteString.Char8 as C > > isMatch :: C.ByteString -> Bool > isMatch "match" = True > isMatch _ = False > > main = print . map isMatch . C.lines =<< C.getContents > What is the reason why instance declarations for IsString class are not defined for available ByteStrings? I need to define it by myself. Thanks Manlio Perillo From daniel.is.fischer at web.de Tue Mar 10 20:11:00 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Mar 10 19:59:17 2009 Subject: [Haskell-cafe] Horner's Rule, foldl, and direct recursion In-Reply-To: References: Message-ID: <200903110111.00828.daniel.is.fischer@web.de> Am Mittwoch, 11. M?rz 2009 00:58 schrieb R J: > Given a list of decimal digits represented by Integers between 0 and 9--for > example, the list [1,2,3, 4]--with the high-order digit at the left, the > list can be converted to a decimal integer n using the following formula, > an instance of Horner's rule: > > n = 10 * 10 * 10 * 1 + 10 * 10 * 2 + 10 * 3 + 4 > = 10 * (10 * 10 * 1 + 10 * 2 + 3) + 4 > = 10 * (10 *(10 * 1 + 2) + 3) + 4 > > In Haskell, the foldl function neatly captures this pattern: > > horner :: [Integer] -> Integer > horner = myFoldl timesPlus 0 > where timesPlus x y = 10 * x + y > > What is the direct recursive calculation of this function without using the > call to foldl? In other words, what's the second equation of: > > horner2 :: [Integer] -> Integer > horner2 [] = 0 > horner2 (x : xs) = ? > > Given that we've already got the definition using foldl, it ought to be > easy to express the second equation, but it's eluding me. > > Thanks. horner2 (x:xs) = go x xs where go m [] = m go m (y:ys) = go (10*m+y) ys But I always write it as foldl' ((+) . (*10)) 0 From dons at galois.com Tue Mar 10 20:51:07 2009 From: dons at galois.com (Don Stewart) Date: Tue Mar 10 20:40:14 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <49B6FF85.4070104@libero.it> References: <49B6E97D.7080409@libero.it> <20090310224259.GK1077@whirlpool.galois.com> <49B6FF85.4070104@libero.it> Message-ID: <20090311005107.GP1077@whirlpool.galois.com> manlio_perillo: > Don Stewart ha scritto: >> [...] >> {-# LANGUAGE OverloadedStrings #-} >> >> import qualified Data.ByteString.Char8 as C >> >> isMatch :: C.ByteString -> Bool >> isMatch "match" = True >> isMatch _ = False >> >> main = print . map isMatch . C.lines =<< C.getContents >> > > What is the reason why instance declarations for IsString class are not > defined for available ByteStrings? > > I need to define it by myself. They're exported from Data.ByteString.Char8 From aeyakovenko at gmail.com Tue Mar 10 20:52:37 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Tue Mar 10 20:40:55 2009 Subject: [Haskell-cafe] do nmergeIO or mergeIO preserve order? In-Reply-To: <7ca3f0160903101649g66c8e285p9bb8d471cb6021de@mail.gmail.com> References: <7ca3f0160903101433y1850a8e8te1029164d349e565@mail.gmail.com> <7ca3f0160903101444g4035bcefuf2c9bd65a0d2922f@mail.gmail.com> <7ca3f0160903101649g66c8e285p9bb8d471cb6021de@mail.gmail.com> Message-ID: > I would also consider it bad style to be fully polymorphic in this case, as > you require polymorphic seq, which is evil (though I don't have the space to > argue this right now :-).? Unamb would be bad style, also, since your > semantics are nondeterministic and so you wouldn't meet the precondition. > Surely your result would have to be in IO.? ("amb" would be okay) what do you mean by fully polymorphic? > Here is how I would do it: > > chooseIO :: [IO a] -> IO [a] > chooseIO xs = do > ??? chan <- newChan > ??? let eval io = forkIO (io >>= writeChan chan) > ??? forkIO $ mapM_ eval xs > ??? getChanContents chan Cool, thanks, thats basically what iw as thinking to. Anatoly From xj2106 at columbia.edu Tue Mar 10 21:22:28 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Tue Mar 10 21:10:50 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <192110823.20090311005238@gmail.com> (Bulat Ziganshin's message of "Wed, 11 Mar 2009 00:52:38 +0300") References: <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <87r61585i5.fsf@columbia.edu> <20090310211247.GG1077@whirlpool.galois.com> <87mybt83ua.fsf@columbia.edu> <192110823.20090311005238@gmail.com> Message-ID: <87iqmg97l7.fsf@columbia.edu> Hi, thanks for the hint. I'll see what I can do with it. Xiao-Yong Bulat Ziganshin writes: > Hello Xiao-Yong, > > Wednesday, March 11, 2009, 12:28:45 AM, you wrote: > >> It goes beyond my current knowledge, now. How do you define >> a custom data type as an instance of UA or Storable? > > just look at existing instances. basically, for complex data type, you > just use instances for its basic types, plus you need to calculate > offset of second and following fields (using sizeOf in Storable class) -- c/* __o/* <\ * (__ */\ < From valheru at chariot.net.au Tue Mar 10 22:08:55 2009 From: valheru at chariot.net.au (Mark Spezzano) Date: Tue Mar 10 21:57:39 2009 Subject: [Haskell-cafe] Parallel programming in Haskell (threads, cores, processors) Message-ID: <000001c9a1ee$55c10010$01430030$@net.au> Hi, I’m an experienced software developer, but a bit of a newbie when it comes to parallel processing in any language. I’ve done some multithreading in Java and C++ on a single processor, single core architecture only. First, let me define some terms: Multithreading: this is multiple processes running on one processor and is the conventional way to do parallel programming Multicore: this is when we have two (or more) cores within the one CPU Multiprocessor: this is when we have multiple CPUs Question 1: Is there any programmatic change in dealing with multiple threads as opposed to multiple cores in most languages (specifically Haskell)? That is, to write multiple threads you normally “spin-off” a new thread which runs in parallel along with other threads. Is Haskell smart enough to do this by magic by itself, or would I need to tell it explicitly : Run thread A whilst running thread B Also, what about multicore architectures? Do I have to tell the language to spin off two separate programs to run on each core and then somehow use some kind of communications to exchange data? I also assume that, in theory it would be possible to have multiple threads running on each core. Say, 3 threads spawned from program 1 running on core 1 and 5 threads on program 2 running on core 2 Likewise I would suppose that it would be possible to have multiprocessors, each potentially multicore, each core running multiple threads. Question 2: In light of the above statement, is the programmatic change DIFFERENT for dealing with each of a) Multithreading in Haskell versus b) Multicores in Haskell verus c) Multiprocessors in Haskell References or info appreciated. Just curious. Mark No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.9/1993 - Release Date: 10/03/2009 7:19 AM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/a94320f6/attachment.htm From mark.spezzano at chariot.net.au Tue Mar 10 22:38:05 2009 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Tue Mar 10 22:26:50 2009 Subject: [Haskell-cafe] Parallel programming (threads, cores, processors) Message-ID: <001901c9a1f2$69430fd0$3bc92f70$@spezzano@chariot.net.au> Hi, I’m an experienced software developer, but a bit of a newbie when it comes to parallel processing in any language. I’ve done some multithreading in Java and C++ on a single processor, single core architecture only. First, let me define some terms: Multithreading: this is multiple processes running on one processor and is the conventional way to do parallel programming Multicore: this is when we have two (or more) cores within the one CPU Multiprocessor: this is when we have multiple CPUs Question 1: Is there any programmatic change in dealing with multiple threads as opposed to multiple cores in most languages (specifically Haskell)? That is, to write multiple threads you normally “spin-off” a new thread which runs in parallel along with other threads. Is Haskell smart enough to do this by magic by itself, or would I need to tell it explicitly : Run thread A whilst running thread B Also, what about multicore architectures? Do I have to tell the language to spin off two separate programs to run on each core and then somehow use some kind of communications to exchange data? I also assume that, in theory it would be possible to have multiple threads running on each core. Say, 3 threads spawned from program 1 running on core 1 and 5 threads on program 2 running on core 2 Likewise I would suppose that it would be possible to have multiprocessors, each potentially multicore, each core running multiple threads. Question 2: In light of the above statement, is the programmatic change DIFFERENT for dealing with each of a) Multithreading in Haskell versus b) Multicores in Haskell verus c) Multiprocessors in Haskell References or info appreciated. Just curious. Mark No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.9/1993 - Release Date: 10/03/2009 7:19 AM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/f7308a81/attachment.htm From s.clover at gmail.com Tue Mar 10 23:23:25 2009 From: s.clover at gmail.com (Sterling Clover) Date: Tue Mar 10 23:11:38 2009 Subject: [Haskell-cafe] Parallel programming (threads, cores, processors) In-Reply-To: <001901c9a1f2$69430fd0$3bc92f70$@spezzano@chariot.net.au> References: <001901c9a1f2$69430fd0$3bc92f70$@spezzano@chariot.net.au> Message-ID: <12C0EE2A-21D3-4F12-88D6-FEAFAB738EF8@gmail.com> On Mar 10, 2009, at 10:38 PM, Mark Spezzano wrote: > Hi, > > I?m an experienced software developer, but a bit of a newbie when > it comes to parallel processing in any language. > > Question 1: > > Is there any programmatic change in dealing with multiple threads > as opposed to multiple cores in most languages (specifically Haskell)? > > That is, to write multiple threads you normally ?spin-off? a new > thread which runs in parallel along with other threads. Is Haskell > smart enough to do this by magic by itself, or would I need to tell > it explicitly : Run thread A whilst running thread B > > Also, what about multicore architectures? Do I have to tell the > language to spin off two separate programs to run on each core and > then somehow use some kind of communications to exchange data? > GHC's parallel runtime, which is what we're really talking about when we're talking about Haskell concurrency, operates roughly like this: Threads at the language level are "green" -- i.e. they are conceptually threads, and the runtime schedules them as it sees fit, but they aren't tied to any given core for execution. You can create (using the forkIO primitive) as many new threads as you like. If you then execute your program with runtime options (i.e. +RTS -N 2 for two cores) that specify how many actually operating system threads you want, the runtime will then map your set of green threads onto OS threads (and presumably cores) in what it thinks is an efficient manner. Communication between threads is via MVars, which are like one-item mailboxes, and are one concurrency primitive, or TVars, which are for Software Transactional Memory. > I also assume that, in theory it would be possible to have multiple > threads running on each core. Say, 3 threads spawned from program 1 > running on core 1 and 5 threads on program 2 running on core 2 > Generally, the runtime system moves threads between cores as it sees fit. However, you can tie threads to particular cores using other concurrency primitives (i.e. runInBoundThread). See the documentation for Control.Concurrent (http://www.haskell.org/ ghc/docs/latest/html/libraries/base/Control-Concurrent.html) and Control.Concurrent.STM (http://www.haskell.org/ghc/docs/latest/html/ libraries/stm/Control-Concurrent-STM.html) for more details. > Likewise I would suppose that it would be possible to have > multiprocessors, each potentially multicore, each core running > multiple threads. > Yep, see above, although I don't know of any way to distinguish between cores and processors as you're really just mapping to OS threads (i.e. capabilities) and relying on the OS to distribute these among cores and processors reasonably. > Question 2: > > In light of the above statement, is the programmatic change > DIFFERENT for dealing with each of > > a) Multithreading in Haskell versus > > b) Multicores in Haskell verus > > c) Multiprocessors in Haskell > Generally, you'll want to write concurrent Haskell code as an abstraction to think about things that are "naturally" concurrent -- i.e. which are best thought of as happening at the same time. At runtime, you specify how many OS capabilities you want to map onto. For algorithms where you want computations to happen in parallel, there's an entirely different set of operations, based around `par` (see Control.Parallel [http://www.haskell.org/ghc/docs/latest/html/ libraries/parallel/Control-Parallel.html] and Control.Parallel.Strategies). In neither case should you need, generally, to concern yourself with the details of threads vs. cores vs. processors. Cheers, Sterl. From barsoap at web.de Wed Mar 11 00:46:00 2009 From: barsoap at web.de (Achim Schneider) Date: Wed Mar 11 00:34:31 2009 Subject: [Haskell-cafe] Re: Distributing Linux binaries References: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> <20090309202637.GD28269@whirlpool.galois.com> <1236643699.22402.341.camel@localhost> <670e468e0903101036n75f46428t847302991de24b44@mail.gmail.com> Message-ID: <20090311054600.6d90e5dd@solaris> Lyle Kopnicky wrote: > If it is a hurdle for me, I can imagine a lot of people are getting > frustrated at trying to distribute their binaries on Linux. > I don't think so. Developers usually just don't, and the distribution packagers seem to enjoy their specific messes... otherwise, they wouldn't package, or rewrite their package management. OTOH, as a user I utterly dislike things like loki installers, or, even worse, some rpm for some random RedHat version as the only available download. If you really, really think that I'd like to use a binary package, and want to make me happy, make a tarball that fits into /opt, with a layout like foo/bin/foo-bin foo/bin/foo foo/share/data.foo foo/README.foo , foo/bin/foo being a shell script containing some magic to set FOO_DATA_DIR [1] to some value and then calls foo-bin, passing all command line options. The simpler the better, I rather hardcode paths according to my install than read through 300 lines of shell code. This, of course, isn't at all preferable to providing, in my case, a single .ebuild with build instructions and either get it included in the gentoo repository, or provide an overlay (and get that included in the overlay list) In a project, you usually either a) have someone who does all the packaging for major distros (which is a cool thing to do if you can't code yourself and don't want to be stuck with writing documentation), b) have each of the developers do packages for the distro they're using c) are lucky enough to be big (or important) enough so that distro package maintainers do the work for you. In either case, a source tarball is, and always will be, the most important thing to provide and the basis on which every other effort is built. If somebody is complaining that you're not providing more, recruit that somebody. In short: Just do a source tarball and don't worry about the rest. In the haskell case, just do a cabalised repo or tarball, preferably get it onto hackage, and don't worry about the rest. There are tools that automagically generate distribution packages from that. [1] and LD_LIBRARY_PATH and LD_PRELOAD -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From mark.spezzano at chariot.net.au Wed Mar 11 02:11:42 2009 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Wed Mar 11 02:00:28 2009 Subject: [Haskell-cafe] Generics Versus Parametric Polymorphism Message-ID: <004401c9a210$4104a650$c30df2f0$@spezzano@chariot.net.au> Hi, Just wondering if Generics and Parametric polymorphism are one and the same in Haskell. I read (somewhere!) an article stating that generics might be included in Haskell Prime but I thought that they’re already included as parametric polymorphism. Did I misread something? Or is generics in Haskell referring to something completely different. Cheers, Mark Spezzano No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.9/1993 - Release Date: 10/03/2009 7:19 AM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/59cfae88/attachment-0001.htm From dons at galois.com Wed Mar 11 02:29:36 2009 From: dons at galois.com (Don Stewart) Date: Wed Mar 11 02:18:56 2009 Subject: [Haskell-cafe] Generics Versus Parametric Polymorphism In-Reply-To: <004401c9a210$4104a650$c30df2f0$@spezzano@chariot.net.au> References: <004401c9a210$4104a650$c30df2f0$@spezzano@chariot.net.au> Message-ID: <20090311062936.GA3222@whirlpool.galois.com> mark.spezzano: > Hi, > > Just wondering if Generics and Parametric polymorphism are one and the same in > Haskell. > > I read (somewhere!) an article stating that generics might be included in > Haskell Prime but I thought that they?re already included as parametric > polymorphism. > > Did I misread something? Or is generics in Haskell referring to something > completely different. Parametric polymorphism is kinda boring in Haskell -- since it's been there since the beginning. We tend to reserve the term "generics" for higher order, and fancier, polymorphism. These kinds of things: http://hackage.haskell.org/packages/archive/pkg-list.html#cat:generics -- Don From alp at mestan.fr Wed Mar 11 03:35:18 2009 From: alp at mestan.fr (Alp Mestan) Date: Wed Mar 11 03:23:35 2009 Subject: [Haskell-cafe] Generics Versus Parametric Polymorphism In-Reply-To: <20090311062936.GA3222@whirlpool.galois.com> References: <20090311062936.GA3222@whirlpool.galois.com> Message-ID: > > Parametric polymorphism is kinda boring in Haskell -- since it's been > there since the beginning. > > We tend to reserve the term "generics" for higher order, and fancier, > polymorphism. These kinds of things: > > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:generics > > -- Don > I think he was refering to "Java Generics", this kind of things. Java's generics are much less powerful than parametric polymorphism in Haskell. -- Alp Mestan In charge of the C++ section on Developpez.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/677d636f/attachment.htm From bulat.ziganshin at gmail.com Wed Mar 11 05:03:03 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Mar 11 04:51:32 2009 Subject: [Haskell-cafe] Generics Versus Parametric Polymorphism In-Reply-To: <004401c9a210$4104a650$c30df2f0$@spezzano@chariot.net.au> References: <004401c9a210$4104a650$c30df2f0$@spezzano@chariot.net.au> Message-ID: <1179522068.20090311120303@gmail.com> Hello Mark, Wednesday, March 11, 2009, 9:11:42 AM, you wrote: > Just wondering if Generics and Parametric polymorphism are one and the same in Haskell. haskell Parametric polymorphism is the same type of thing as Java Generics :) haskell Generics provides ability to define procedures polymorphic by *any* data type with just a fixed number of definitions there are at least dozen of various tools/libraries supporting Generics in some way in haskell, so indeed we are interested to have at least one with guaranteed availability google for "scrap your boilerplate" paper for a description of one of the most popular Generics implementation -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ketil at malde.org Wed Mar 11 05:25:31 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Mar 11 05:13:10 2009 Subject: [Haskell-cafe] Distributing Linux binaries In-Reply-To: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> (Lyle Kopnicky's message of "Mon\, 9 Mar 2009 13\:25\:33 -0700") References: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> Message-ID: <87iqmgo1h0.fsf@malde.org> Lyle Kopnicky writes: > I tried to make a Debian package and couldn't figure it out, Me too. I don't know why .debs are so hard to get right, most if not all the necessary information should be in the .cabal file. Maybe I'm overly naive here. > but maybe that's overkill. I don't think so. Don S. has more or less singlehandedly ported all of Hackage to Arch Linux. We really should have a central .deb repository for Hackage that could serve as a basis for Debian-based distributions as well as a more cutting-edge alternative for stuff that is not yet in your favorite distro. > GHC itself has some kind of tarball for the > binary distributions, one for Debian and one for Red Hat. How would > I make such a package and what would go into it? > There's only one executable, so it shouldn't be too complicated. > I figure the main issue on Linux is that when you compile it, it's linked to > specific shared libraries. I often distribute binaries simply by distributing the executable file. Usually, it will work on most contemporary Linuxes, and if it doesn't, you often have compat packages of libraries that fixes it. If you in addition pass -optl-static to GHC, it will link - with some caveats - statically, improving the chances of your binary working in uncharted territories. -k -- If I haven't seen further, it is by standing in the footprints of giants From haskell at list.mightyreason.com Wed Mar 11 05:25:08 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Wed Mar 11 05:13:36 2009 Subject: [Haskell-cafe] Re: do nmergeIO or mergeIO preserve order? In-Reply-To: References: Message-ID: <49B78374.9050308@list.mightyreason.com> Anatoly Yakovenko wrote: > do nmergeIO or mergeIO preserve order? or not preserve order? If you have a list of operations "[IO a]" then the future package at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/future can do this. It's 'forkPromises' function returns a "Chan a" which can be used to get the non-order preserving results (actually "Either SomeExcption a"). If you are feeling lucky you can use "getChanContents" and "filter" to get a lazy "[a]" which is the results as they are completed. -- Chris From porges at porg.es Wed Mar 11 05:35:18 2009 From: porges at porg.es (porges@porg.es) Date: Wed Mar 11 05:23:41 2009 Subject: [Haskell-cafe] Generics Versus Parametric Polymorphism In-Reply-To: <1179522068.20090311120303@gmail.com> Message-ID: An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/75b176cc/attachment.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 270 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/75b176cc/signature.bin From leather at cs.uu.nl Wed Mar 11 06:06:44 2009 From: leather at cs.uu.nl (Sean Leather) Date: Wed Mar 11 05:55:00 2009 Subject: [Haskell-cafe] Generics Versus Parametric Polymorphism In-Reply-To: <-5714788993414206221@unknownmsgid> References: <-5714788993414206221@unknownmsgid> Message-ID: <3c6288ab0903110306v49e2293lb1bbd986c0016a8e@mail.gmail.com> Hi Mark, > Just wondering if Generics and Parametric polymorphism are one and the same > in Haskell. > > I read (somewhere!) an article stating that generics might be included in > Haskell Prime but I thought that they?re already included as parametric > polymorphism. > To see the current status of Haskell Prime, visit the Trac page: http://hackage.haskell.org/trac/haskell-prime/ > Did I misread something? Or is generics in Haskell referring to something > completely different. > I'm not sure which article you read, but there is a lot of ambiguity in the term "generics." Depending on whom you talk to, it means a different thing. But I can give you some pointers to where you can learn about many of the possible interpretations. The following paper gives a useful vocabulary for describing the different types of "generics." Just by reading section 2 you can see how confusing it is when so many techniques are referred to as generic programming. For example, parametric polymorphism is an example of genericity by type here. In the Haskell world, (as Don said) it's not considered generics, but in Java (as Alp remarked), it's called generics. http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf There's a comparison paper from 2003 that presents language support for generics in C++, ML, Haskell, Eiffel, Java, and C#. Things have changed a bit since then, but it's an interesting read. http://ece-www.colorado.edu/~siek/pubs/comparing_generic_programming03.pdf "Generics" in Haskell has come to be known as datatype-generic programming. In the past, it has been labeled polytypism, structural polymorphism, or typecase. This refers to the technique of writing functions or programs that work for many types and have knowledge about the structure of the type (mentioned by Bulat). Generic Haskell is a (non-standard) language extension to Haskell. It was used to explore the possibilities of datatype-generic programming (DGP) with Haskell. The following paper compares varying approaches of DGP to Generic Haskell. http://people.cs.uu.nl/johanj/publications/ComparingGP.pdf In the last few years, people have seen the power of Haskell's type system, and GHC has developed some interesting extensions to that type system. As a result of this and the difficulty with maintaining language extensions external to a compiler (e.g. Generic Haskell), libraries for DGP in Haskell have become much more common and powerful. The following article compares a large number of these libraries. http://www.cs.uu.nl/wiki/Alexey/ComparingLibrariesForGenericProgrammingInHaskell Lastly, since I started working in this area over a year ago, I've been collecting references to published research. My citations are on CiteULike: http://www.citeulike.org/user/spl There are tags for "generics" and "datatype-generic" that give you a narrower view on the collection. http://www.citeulike.org/user/spl/tag/generics http://www.citeulike.org/user/spl/tag/datatype-generic Hope this helps to answer your questions. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/fe191dfa/attachment.htm From dev at mobileink.com Wed Mar 11 06:17:41 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Wed Mar 11 06:05:56 2009 Subject: [Haskell-cafe] Against cuteness Message-ID: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> Regarding logos/mascots: nothing personal folks, but I would like to cast a loud firm vote against all forms of cuteness, especially small furry animal cuteness. It's been done half to death, and we are not O'Reilly. Of all the billions of images from all the cultures in the world available to us we can surely find something that is witty or charming without being cute. -g -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/e69f76f1/attachment.htm From bulat.ziganshin at gmail.com Wed Mar 11 06:23:02 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Mar 11 06:11:38 2009 Subject: [Haskell-cafe] Generics Versus Parametric Polymorphism In-Reply-To: References: <1179522068.20090311120303@gmail.com> Message-ID: <417129646.20090311132302@gmail.com> Hello porges, Wednesday, March 11, 2009, 12:35:18 PM, you wrote: > Most importantly (or awesomely?), every time Haskell infers the > type of a function you've written, you get *the most generic possible* version, for free :) and using generics, you can get function polymorphic on *any* type just for few pennies more :))) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From g9ks157k at acme.softbase.org Wed Mar 11 06:21:43 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Wed Mar 11 06:11:57 2009 Subject: [Haskell-cafe] Re: [grapefruit] [reactive] FRP + physics / status of hpysics In-Reply-To: <200903061757.53755.g9ks157k@acme.softbase.org> References: <200903061751.32880.g9ks157k@acme.softbase.org> <200903061757.53755.g9ks157k@acme.softbase.org> Message-ID: <200903111121.43651.g9ks157k@acme.softbase.org> Am Freitag, 6. M?rz 2009 17:57 schrieb Wolfgang Jeltsch: > Am Freitag, 6. M?rz 2009 17:51 schrieb Wolfgang Jeltsch: > > By the way, the adress of the Grapefruit mailing list is > > grapefruit@projects.haskell.org, not grapefruit@haskell.org. > > Oh, this is really strange: I addressed my e-mail to > grapefruit@projects.haskell.org but the version arriving at the Reactive > mailing list has grapefruit@haskell.org in its To: header. However, my > e-mail also reached the Grapefruit mailing list (but Daniel B?nzli?s > didn?t) and the version there has the correct address in its To: headers. > > Does anyone know who is responsible for the Haskell mail server? > > Best wishes, > Wolfgang It was a misconfiguration of the mailserver which is believed to be fixed now. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Wed Mar 11 05:38:57 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Wed Mar 11 06:12:09 2009 Subject: [Haskell-cafe] FRP + physics / status of hpysics In-Reply-To: <20090307174925.GA8835@flit> References: <20090307174925.GA8835@flit> Message-ID: <200903111038.57860.g9ks157k@acme.softbase.org> Am Samstag, 7. M?rz 2009 18:49 schrieb Roman Cheplyaka: > Great! I'll have more free time after March 15, and we can arrange an > IRC meeting to discuss this. I?d be happy if you would also invite me to this IRC meeting when it will finally happen. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Wed Mar 11 06:06:37 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Wed Mar 11 06:12:20 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <49B5AD46.2020502@gmail.com> References: <49B5AD46.2020502@gmail.com> Message-ID: <200903111106.38093.g9ks157k@acme.softbase.org> Am Dienstag, 10. M?rz 2009 00:59 schrieb Joe Fredette: > Hehe, I love it. Sloth is a synonym for Lazyness in English too, and > they're so freaking cute... :) Same in German: The german ?Faultier? means ?lazy animal?. Best wishes, Wolfgang From bulat.ziganshin at gmail.com Wed Mar 11 06:25:01 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Mar 11 06:13:35 2009 Subject: [Haskell-cafe] Against cuteness In-Reply-To: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> Message-ID: <94508550.20090311132501@gmail.com> Hello Gregg, Wednesday, March 11, 2009, 1:17:41 PM, you wrote: > are not O'Reilly.? Of all the billions of images from all the > cultures in the world available to us we can surely find something > that is witty or charming without being cute. it will not be fun :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Wed Mar 11 06:27:02 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Mar 11 06:15:35 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <200903111106.38093.g9ks157k@acme.softbase.org> References: <49B5AD46.2020502@gmail.com> <200903111106.38093.g9ks157k@acme.softbase.org> Message-ID: <185556958.20090311132702@gmail.com> Hello Wolfgang, Wednesday, March 11, 2009, 1:06:37 PM, you wrote: >> Hehe, I love it. Sloth is a synonym for Lazyness in English too, and >> they're so freaking cute... :) > Same in German: The german ?Faultier? means ?lazy animal?. russian too, if that matter. i was really amazed by this idea. pure, lazy and fun! :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dev at mobileink.com Wed Mar 11 06:27:46 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Wed Mar 11 06:16:03 2009 Subject: [Haskell-cafe] Against cuteness In-Reply-To: <94508550.20090311132501@gmail.com> References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <94508550.20090311132501@gmail.com> Message-ID: <75cc17ac0903110327t2a068c57ua2b8d5d5846e7a8@mail.gmail.com> On Wed, Mar 11, 2009 at 5:25 AM, Bulat Ziganshin wrote: > Hello Gregg, > > Wednesday, March 11, 2009, 1:17:41 PM, you wrote: > > > are not O'Reilly. Of all the billions of images from all the > > cultures in the world available to us we can surely find something > > that is witty or charming without being cute. > > it will not be fun :) > Perhaps not, but it also won't be torture. I can't take any more cuteness. ;) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/4c3976b5/attachment.htm From mark.spezzano at chariot.net.au Wed Mar 11 06:58:52 2009 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Wed Mar 11 06:47:38 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent Message-ID: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> Hi, I’m very familiar with the concept of Design Patterns for OOP in Java and C++. They’re basically a way of fitting components of a program so that objects/classes fit together nicely like Lego blocks and it’s useful because it also provides a common “language” to talk about concepts, like Abstract Factory, or an Observer to other programmers. In this way one programmer can instantly get a feel what another programmer is talking about even though the concepts are fundamentally abstract. Because Haskell is not OO, it is functional, I was wondering if there is some kind of analogous “design pattern”/”template” type concept that describe commonly used functions that can be “factored out” in a general sense to provide the same kind of usefulness that Design Patterns do for OOP. Basically I’m asking if there are any kinds of “common denominator” function compositions that are used again and again to solve problems. If so, what are they called? Cheers, Mark Spezzano No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.9/1993 - Release Date: 10/03/2009 7:19 AM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/ed5add7b/attachment.htm From noteed at gmail.com Wed Mar 11 07:03:45 2009 From: noteed at gmail.com (minh thu) Date: Wed Mar 11 06:52:00 2009 Subject: [Haskell-cafe] Against cuteness In-Reply-To: <75cc17ac0903110327t2a068c57ua2b8d5d5846e7a8@mail.gmail.com> References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <94508550.20090311132501@gmail.com> <75cc17ac0903110327t2a068c57ua2b8d5d5846e7a8@mail.gmail.com> Message-ID: <40a414c20903110403k7905f17ey88cc2ed0e90d03@mail.gmail.com> 2009/3/11 Gregg Reynolds : > On Wed, Mar 11, 2009 at 5:25 AM, Bulat Ziganshin > wrote: >> >> Hello Gregg, >> >> Wednesday, March 11, 2009, 1:17:41 PM, you wrote: >> >> > are not O'Reilly. Of all the billions of images from all the >> > cultures in the world available to us we can surely find something >> > that is witty or charming without being cute. >> >> it will not be fun :) > > Perhaps not, but it also won't be torture. I can't take any more cuteness. > ;) > Let's use the tool of TMR cover on the sloth; laziness hammered ! Thu From noteed at gmail.com Wed Mar 11 07:12:51 2009 From: noteed at gmail.com (minh thu) Date: Wed Mar 11 07:01:07 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <-223952846378897397@unknownmsgid> References: <-223952846378897397@unknownmsgid> Message-ID: <40a414c20903110412w45b43d34n9006e102b8643d94@mail.gmail.com> 2009/3/11 Mark Spezzano : > Hi, > > > > I?m very familiar with the concept of Design Patterns for OOP in Java and > C++. They?re basically a way of fitting components of a program so that > objects/classes fit together nicely like Lego blocks and it?s useful because > it also provides a common ?language? to talk about concepts, like Abstract > Factory, or an Observer to other programmers. In this way one programmer can > instantly get a feel what another programmer is talking about even though > the concepts are fundamentally abstract. > > > > Because Haskell is not OO, it is functional, I was wondering if there is > some kind of analogous ?design pattern?/?template? type concept that > describe commonly used functions that can be ?factored out? in a general > sense to provide the same kind of usefulness that Design Patterns do for > OOP. Basically I?m asking if there are any kinds of ?common denominator? > function compositions that are used again and again to solve problems. If > so, what are they called? Hi, A particular instance of what can replace the idea of design pattern is given by this now famous post : http://blog.sigfpe.com/2009/01/haskell-monoids-and-their-uses.html You'll see that what 'speaks' to the haskell programmers, maybe in the same way you say design patterns speak to another oo programmer, is much more fitted to the language in haskell. At a lower scale, the reusability of some simple functions like fold or map is reflected at a higher scale by the reusability of concepts like monoids (whih 'exist' in the language, as type classes, while a pattern doesn't). Cheers, Thu From noteed at gmail.com Wed Mar 11 07:26:47 2009 From: noteed at gmail.com (minh thu) Date: Wed Mar 11 07:15:02 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <185556958.20090311132702@gmail.com> References: <49B5AD46.2020502@gmail.com> <200903111106.38093.g9ks157k@acme.softbase.org> <185556958.20090311132702@gmail.com> Message-ID: <40a414c20903110426u40abfca5kd98056adbec0df8a@mail.gmail.com> 2009/3/11 Bulat Ziganshin : > Hello Wolfgang, > > Wednesday, March 11, 2009, 1:06:37 PM, you wrote: > >>> Hehe, I love it. Sloth is a synonym for Lazyness in English too, and >>> they're so freaking cute... :) > >> Same in German: The german ?Faultier? means ?lazy animal?. > > russian too, if that matter. i was really amazed by this idea. > pure, lazy and fun! :) Same in french : 'paresseux' just means lazy. Thu From greenrd at greenrd.org Wed Mar 11 07:26:51 2009 From: greenrd at greenrd.org (Robin Green) Date: Wed Mar 11 07:15:15 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> References: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> Message-ID: <20090311112651.67cf478d@greenrd.org> The concept of "design pattern" tends not to be used by Haskell programmers - it brings a lot of baggage with it (like being formally documented in a particular way, being "proven" by being used in production several times, etc.) and it doesn't seem to be particularly useful for us in this heavyweight form. However, we do have a more lightweight concept of an "idiom" and "idiomatic Haskell". See http://www.haskell.org/haskellwiki/Category:Idioms (Not all of these pages should probably be in this category, but it gives you an idea.) -- Robin On Wed, 11 Mar 2009 21:28:52 +1030 "Mark Spezzano" wrote: > Hi, > > > > I?m very familiar with the concept of Design Patterns for OOP in Java > and C++. They?re basically a way of fitting components of a program > so that objects/classes fit together nicely like Lego blocks and it?s > useful because it also provides a common ?language? to talk about > concepts, like Abstract Factory, or an Observer to other programmers. > In this way one programmer can instantly get a feel what another > programmer is talking about even though the concepts are > fundamentally abstract. > > > > Because Haskell is not OO, it is functional, I was wondering if there > is some kind of analogous ?design pattern?/?template? type concept > that describe commonly used functions that can be ?factored out? in a > general sense to provide the same kind of usefulness that Design > Patterns do for OOP. Basically I?m asking if there are any kinds of > ?common denominator? function compositions that are used again and > again to solve problems. If so, what are they called? > > > > Cheers, > > > > Mark Spezzano > > > > > > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.557 / Virus Database: 270.11.9/1993 - Release Date: > 10/03/2009 7:19 AM > From barsoap at web.de Wed Mar 11 07:31:40 2009 From: barsoap at web.de (Achim Schneider) Date: Wed Mar 11 07:20:10 2009 Subject: [Haskell-cafe] Re: Design Patterns by Gamma or equivalent References: <17744.3320899785$1236769267@news.gmane.org> Message-ID: <20090311123140.28aab6ee@solaris> "Mark Spezzano" wrote: > Basically I___m asking if there are any kinds of ___common denominator___ > function compositions that are used again and again to solve > problems. If so, what are they called? > Haskellers tend to cast their design patterns into functions and libraries. What they're supposed to be called is a zealously heated discussion, there's, for example, return == pure == point and fmap == map == (.) == liftM [1] OTOH, we're said to not care at all: | Don't underrate Haskell programmers. The ones I know have the kind of | minds where if you switched the names to pig latin, they wouldn't skip | a beat. -- [2] If you're looking for a text that could be named "The N most (use|success)ful Haskell Design Patterns", I recommend having a look at the Typeclassopedia[3]. [1]well, at least there _could_ be. [2]http://www.mail-archive.com/boost@lists.boost.org/msg08898.html [3]http://byorgey.wordpress.com/2009/02/16/the-typeclassopedia-request-for-feedback/ -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From leather at cs.uu.nl Wed Mar 11 07:48:13 2009 From: leather at cs.uu.nl (Sean Leather) Date: Wed Mar 11 07:36:30 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <-223952846378897397@unknownmsgid> References: <-223952846378897397@unknownmsgid> Message-ID: <3c6288ab0903110448i49202b90rf914290502a076fc@mail.gmail.com> Hi Mark, Because Haskell is not OO, it is functional, I was wondering if there is > some kind of analogous ?design pattern?/?template? type concept that > describe commonly used functions that can be ?factored out? in a general > sense to provide the same kind of usefulness that Design Patterns do for > OOP. Basically I?m asking if there are any kinds of ?common denominator? > function compositions that are used again and again to solve problems. If > so, what are they called? > Look at Jeremy Gibbons' publications. All of the ones that have "pattern" or "origami" in the title describe design patterns in Haskell. Some of them relate to the translation of Gang-of-Four patterns. http://www.comlab.ox.ac.uk/people/publications/date/Jeremy.Gibbons.html Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/960846d5/attachment.htm From satnams at microsoft.com Wed Mar 11 09:24:47 2009 From: satnams at microsoft.com (Satnam Singh) Date: Wed Mar 11 09:13:20 2009 Subject: [Haskell-cafe] ThreadScope: Request for features for the performance tuning of parallel and concurrent Haskell programs Message-ID: Donnie Jones, Simon Marlow and I have been working on infrastructure for logging run-time events and a graphical viewer program called ThreadScope. Hopefully these features will make it into the next release of GHC. We hope the event-log viewer ThreadScope will be useful for the performance tuning of parallel and concurrent Haskell programs. You can see a few screen shots at the program's website http://raintown.org/threadscope Before making the release I thought it would be an idea to ask people what other features people would find useful or performance tuning. So if you have any suggestions please do let us know! Cheers, Satnam Singh ________________________________ Satnam Singh Microsoft 7 JJ Thomson Avenue Cambridge CB3 0FB United Kingdom Email: satnams@microsoft.com UK tel: +44 1223 479905 Fax: +44 1223 479 999 UK mobile: +44 7979 648412 USA cell: 206 330 1580 USA tel: 206 219 9024 URL: http://research.microsoft.com/~satnams Live Messenger: satnam@raintown.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/9f958b66/attachment.htm From deniz.a.m.dogan at gmail.com Wed Mar 11 09:52:33 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Wed Mar 11 09:40:49 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <40a414c20903110426u40abfca5kd98056adbec0df8a@mail.gmail.com> References: <49B5AD46.2020502@gmail.com> <200903111106.38093.g9ks157k@acme.softbase.org> <185556958.20090311132702@gmail.com> <40a414c20903110426u40abfca5kd98056adbec0df8a@mail.gmail.com> Message-ID: <7b501d5c0903110652qbcc5222jc27e06837f4a2da4@mail.gmail.com> 2009/3/11 minh thu : > 2009/3/11 Bulat Ziganshin : >> Hello Wolfgang, >> >> Wednesday, March 11, 2009, 1:06:37 PM, you wrote: >> >>>> Hehe, I love it. Sloth is a synonym for Lazyness in English too, and >>>> they're so freaking cute... :) >> >>> Same in German: The german ?Faultier? means ?lazy animal?. >> >> russian too, if that matter. i was really amazed by this idea. >> pure, lazy and fun! :) > > Same in french : 'paresseux' just means lazy. > > Thu In Swedish it translates to "late walker" (?) and in Turkish it's "lazy animal". Deniz From jgoerzen at complete.org Wed Mar 11 10:58:36 2009 From: jgoerzen at complete.org (John Goerzen) Date: Wed Mar 11 10:46:56 2009 Subject: [Haskell-cafe] QC 2.0 missing some stuff I need Message-ID: <20090311145836.GA26587@hustlerturf.com> Hi, QuickCheck 1.x had this function: evaluate :: Testable a => a -> Gen Result which I used in TestPack to help wrap a QuickCheck test as a HUnit test case. QuickCheck 2.x seems to have no pure evaluate-like function at all; all of its functions are in the IO monad and also write their result to stdout, according to the docs. Am I missing something? Thanks, -- John From hpacheco at gmail.com Wed Mar 11 10:58:38 2009 From: hpacheco at gmail.com (Hugo Pacheco) Date: Wed Mar 11 10:47:01 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <7b501d5c0903110652qbcc5222jc27e06837f4a2da4@mail.gmail.com> References: <49B5AD46.2020502@gmail.com> <200903111106.38093.g9ks157k@acme.softbase.org> <185556958.20090311132702@gmail.com> <40a414c20903110426u40abfca5kd98056adbec0df8a@mail.gmail.com> <7b501d5c0903110652qbcc5222jc27e06837f4a2da4@mail.gmail.com> Message-ID: <7b92c2840903110758t1cac3c0k7a5e66fda9ea3d1a@mail.gmail.com> I have previously thought of something like this, when the initial idea for a sloth was suggested: > I like the ideia, and could imagine something like this: > http://i41.tinypic.com/se65ux.jpg > > Sorry for the bad drawing and scanning quality. If someone likes the ideia, I'm sure > they can do much better than me :) > > hugo On Wed, Mar 11, 2009 at 1:52 PM, Deniz Dogan wrote: > 2009/3/11 minh thu : >> 2009/3/11 Bulat Ziganshin : >>> Hello Wolfgang, >>> >>> Wednesday, March 11, 2009, 1:06:37 PM, you wrote: >>> >>>>> Hehe, I love it. Sloth is a synonym for Lazyness in English too, and >>>>> they're so freaking cute... :) >>> >>>> Same in German: The german ?Faultier? means ?lazy animal?. >>> >>> russian too, if that matter. i was really amazed by this idea. >>> pure, lazy and fun! :) >> >> Same in french : 'paresseux' just means lazy. >> >> Thu > > In Swedish it translates to "late walker" (?) and in Turkish it's "lazy animal". > > Deniz > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- www.di.uminho.pt/~hpacheco From wanghanyi21 at hotmail.com Wed Mar 11 11:13:10 2009 From: wanghanyi21 at hotmail.com (wanghanyi) Date: Wed Mar 11 11:01:25 2009 Subject: [Haskell-cafe] Using FosSyDe to translate haskell to VHDL. In-Reply-To: <20090310192357.GA24302@katherina.student.utwente.nl> References: <20090310192357.GA24302@katherina.student.utwente.nl> Message-ID: Hey Matthijs Thanks for replying, and that might help. I will try with it to see if it works, and I am still looking for the answer myself. If there is anyone has worked with the Haskell to VHDL translater, plz let me know cause I have many to discuss. Thanks Hanyi > Date: Tue, 10 Mar 2009 20:23:57 +0100 > From: matthijs@stdin.nl > To: wanghanyi21@hotmail.com > CC: haskell-cafe@haskell.org > Subject: Re: [Haskell-cafe] Using FosSyDe to translate haskell to VHDL. > > Hi Hany, > > > *Plus2> writeVHDL plus2SysDef > > *** Exception: VHDL Compilation Error: Untranslatable function: where constructs are not supported in functions: > > where addOnef_0 = n_1 GHC.Num.+ 1 > > in process function `addTwof' (created in Plus2) used by process `plus2Proc' belonging to system definition `plus2' (created in ) > I don't know much about ForSyDe, but it seems that where clauses simply aren't > supported. Perhaps let expressions are? > > The would mean something like the following: > > addTwof :: ProcFun (Int32 -> Int32) > addTwof = $(newProcFun [d|addTwof :: Int32 -> Int32 > let addOnef = n +1 in > addTwof n = addOnef+1 > |]) > > (Not sure if this is completely valid code, I'm not too familiar with TH..). > > Gr. > > Matthijs _________________________________________________________________ MSN°²È«±£»¤ÖÐÐÄ£¬Ãâ·ÑÐÞ¸´ÏµÍ³Â©¶´£¬±£»¤MSN°²È«£¡ http://im.live.cn/safe/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/f0b96f2a/attachment.htm From batterseapower at hotmail.com Wed Mar 11 11:19:41 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Wed Mar 11 11:07:57 2009 Subject: [Haskell-cafe] QC 2.0 missing some stuff I need In-Reply-To: <20090311145836.GA26587@hustlerturf.com> References: <20090311145836.GA26587@hustlerturf.com> Message-ID: <9d4d38820903110819v4962e908s5296a1de72538114@mail.gmail.com> Hi John, I also had this problem when adding a QuickCheck 2 provider to test-framework (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/test-framework-quickcheck2). In the end I had to copy considerable portions of the QuickCheck2 code into the provider because there seems to be no pure interface at all :-(. This is especially important for test-framework because it may use threading to run several tests simultaneously, and you don't really want output from multiple tests interleaved on the console. Actually, despite copying a large chunk of QC2 into the provider I /still/ didn't entirely stop it from writing to the console, so failed QC2 properties running under test-framework write the arguments to the properties that demonstrate failure BEFORE the message telling you the property has failed! Upsetting, but I had to draw the line at copying code somewhere. Cheers, Max 2009/3/11 John Goerzen : > Hi, > > QuickCheck 1.x had this function: > > evaluate :: Testable a => a -> Gen Result > > which I used in TestPack to help wrap a QuickCheck test as a HUnit > test case. ?QuickCheck 2.x seems to have no pure evaluate-like > function at all; all of its functions are in the IO monad and also > write their result to stdout, according to the docs. ?Am I missing > something? > > Thanks, > > -- John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From manlio_perillo at libero.it Wed Mar 11 11:59:21 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Mar 11 11:47:41 2009 Subject: [Haskell-cafe] advice on a parsing function Message-ID: <49B7DFD9.9080504@libero.it> Hi. I'm still working on the Netflix Prize; now I have managed to implement a parsing function for the qualifying data set (or quiz set). The quiz set is in the format: 1: 10 20 30 2: 100 200 3: 1000 2000 3000 4000 5000 Where 1, 2, 3 are movie ids, and the others are user ids. The parsing program is at: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2300 The program reads the file using lazy IO. One of the feature I want is, for the quiz function, to be a *good producer*. I'm quite satisfied with the result (this is the first "complex" parsing function I have written in Haskell), and I have also managed to avoid the use of an accumulator. However I'm interested to know it there is a more efficient solution. The qualifying.txt file is 51MB, 2834601 lines. On my laptop, the function performance are: real 1m14.117s user 0m2.496s sys 0m0.136s CPU usage is about 3%, system load is about 0.20, memory usage is 4956 KB. What I'm worried about is: quiz' ((id, ":") : l) = (id, quiz'' l) : quiz' l quiz' ((id, _) : l) = quiz' l the problem here is that the same elements in the list are processed multiple times. I have written alternate versions. The first using foldl http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2303 (that, however, builds the entire data structure in memory, and in reverse order) The latter using foldr http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2304 (that, however, is incorrect and I'm unable to fix). The performances of the foldr version are very similar to the performances of the first implementation (it make use, however, of 3704 KB, and it is about 3 seconds faster). P.S: the expected result for the sample quiz set I have posted is: [(1,[10,20,30]),(2,[100,200]),(3,[1000,2000,3000,4000,5000])] The foldl version produces: [(3,[5000,4000,3000,2000,1000]),(2,[200,100]),(1,[30,20,10])] The foldr version produces: [(1,[]),(2,[10,20,30]),(3,[100,200]),(5000,[1000,2000,3000,4000])] Thanks Manlio Perillo From bugfact at gmail.com Wed Mar 11 12:02:50 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Mar 11 11:51:06 2009 Subject: [Haskell-cafe] Request: warn about language extensions that are not used Message-ID: When I put {-# OPTIONS_GHC -Wall -Werror #-} in my source file, I don't get compiler (GHC) warnings about redundant language extensions that I enabled. It would be nice if the compiler gave warnings about this, since after refactoring, some language extensions might not be needed anymore, and hence should be removed since fewer language extensions mean more stable and portable code no? What do you think? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/da01ea9c/attachment.htm From manlio_perillo at libero.it Wed Mar 11 12:09:51 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Mar 11 11:58:20 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <20090311005107.GP1077@whirlpool.galois.com> References: <49B6E97D.7080409@libero.it> <20090310224259.GK1077@whirlpool.galois.com> <49B6FF85.4070104@libero.it> <20090311005107.GP1077@whirlpool.galois.com> Message-ID: <49B7E24F.8040009@libero.it> Don Stewart ha scritto: > manlio_perillo: >> Don Stewart ha scritto: >>> [...] >>> {-# LANGUAGE OverloadedStrings #-} >>> >>> import qualified Data.ByteString.Char8 as C >>> >>> isMatch :: C.ByteString -> Bool >>> isMatch "match" = True >>> isMatch _ = False >>> >>> main = print . map isMatch . C.lines =<< C.getContents >>> >> What is the reason why instance declarations for IsString class are not >> defined for available ByteStrings? >> >> I need to define it by myself. > > They're exported from Data.ByteString.Char8 > Then there is something I'm missing. Your code does not compile. Thanks Manlio Perillo From wchogg at gmail.com Wed Mar 11 12:16:46 2009 From: wchogg at gmail.com (Creighton Hogg) Date: Wed Mar 11 12:05:01 2009 Subject: [Haskell-cafe] Request: warn about language extensions that are not used In-Reply-To: References: Message-ID: <814617240903110916w6b500a51n7bed0e669779fab4@mail.gmail.com> 2009/3/11 Peter Verswyvelen : > When I put > {-# OPTIONS_GHC -Wall -Werror #-} > in my source file, I don't get compiler (GHC) warnings about redundant > language extensions that I enabled. > It would be nice if the?compiler?gave warnings about this, since after > refactoring, some language extensions might not be needed anymore, and hence > should be removed since fewer language extensions mean more stable and > portable code no? > What do you think? So you mean something like if you put {-# LANGUAGE GeneralizedNewtypeDeriving #-} in a file, but never do newtype deriving, it would warn you? I have no idea how hard that'd be to implement, but that sounds kind of cool. Useful for both refactoring and when you've inherited old code. Cheers, C From martijn at van.steenbergen.nl Wed Mar 11 12:18:54 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Mar 11 12:07:11 2009 Subject: [Haskell-cafe] Request: warn about language extensions that are not used In-Reply-To: References: Message-ID: <49B7E46E.2000801@van.steenbergen.nl> I'd love that. I've been wanting this for a while, at least subconsciously. Thanks for making it explicit. :-) Peter Verswyvelen wrote: > When I put > > {-# OPTIONS_GHC -Wall -Werror #-} > > in my source file, I don't get compiler (GHC) warnings about redundant > language extensions that I enabled. > > It would be nice if the compiler gave warnings about this, since after > refactoring, some language extensions might not be needed anymore, and > hence should be removed since fewer language extensions mean more stable > and portable code no? > > What do you think? > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From noteed at gmail.com Wed Mar 11 12:21:53 2009 From: noteed at gmail.com (minh thu) Date: Wed Mar 11 12:10:08 2009 Subject: [Haskell-cafe] advice on a parsing function In-Reply-To: <49B7DFD9.9080504@libero.it> References: <49B7DFD9.9080504@libero.it> Message-ID: <40a414c20903110921u55b3eb13l63a2b0c306d0edc1@mail.gmail.com> 2009/3/11 Manlio Perillo : > Hi. > > I'm still working on the Netflix Prize; now I have managed to implement a > parsing function for the qualifying data set (or quiz set). > > The quiz set is in the format: > > 1: > 10 > 20 > 30 > 2: > 100 > 200 > 3: > 1000 > 2000 > 3000 > 4000 > 5000 > > > Where 1, 2, 3 are movie ids, and the others are user ids. > > The parsing program is at: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2300 > > > The program reads the file using lazy IO. > One of the feature I want is, for the quiz function, to be a *good > producer*. > > I'm quite satisfied with the result (this is the first "complex" parsing > function I have written in Haskell), and I have also managed to avoid the > use of an accumulator. > > However I'm interested to know it there is a more efficient solution. > > > The qualifying.txt file is 51MB, 2834601 lines. > > On my laptop, the function performance are: > > real 1m14.117s > user 0m2.496s > sys 0m0.136s > > CPU usage is about 3%, > system load is about 0.20, > memory usage is 4956 KB. > > > What I'm worried about is: > > quiz' ((id, ":") : l) = (id, quiz'' l) : quiz' l > quiz' ((id, _) : l) = quiz' l > > > the problem here is that the same elements in the list are processed > multiple times. > > > I have written alternate versions. > The first using foldl > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2303 > (that, however, builds the entire data structure in memory, and in reverse > order) > > The latter using foldr > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2304 > (that, however, is incorrect and I'm unable to fix). Hi, I suggest you try an alternative strategy. That altenrative strategy is twofold, just like you have quiz' and quiz'. This alternate strategy avoid pattern matching on strings (which would be cumbersome for a bit more complex syntax). So you have to write two functions : one try to parse an 'id:' from the string. It either succeed and returns the Int value of the id, or it fails. You can use Either to encode success and failure. Furthermore that function has to return the remaining string (which is the same as received upon failure). The second function do a similar thing, this time failing on 'id:'. (And it still returns alos the remainstring). If you're familiar with the State monad, you can write the above two functions by using the string as the state. Now, given those two functions, try to apply them on your input string, feeding the next function application with the resulting string of the current application. What I proposed here is the very basics of a natural and very used parsing technique (google for parser combinators). That technic will scale well for more complex inputs, and, I believe, should provide you with sufficient performance. Cheers, Thu From deduktionstheorem at web.de Wed Mar 11 12:22:19 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Wed Mar 11 12:10:37 2009 Subject: [Haskell-cafe] View patterns and warnings about overlapping or non-exhaustive patterns Message-ID: <49B7E53B.2010801@web.de> Hi, I'm working on a data structure that uses Data.Sequence a lot, so views are important and I tried to simplify my code using view patterns. The problem is, that I keep getting warnings about both overlapping and non-exhaustive pattern matches. A simple test case: ===============================T.hs=============================== {-# LANGUAGE ViewPatterns #-} import Data.Sequence test :: Seq a -> Seq b -> String test (viewl -> EmptyL) (viewl -> EmptyL) = "empty, empty" test (viewl -> EmptyL) (viewl -> _ :< _) = "empty, non-empty" test (viewl -> _ :< _) (viewl -> EmptyL) = "non-empty, empty" test _ _ = "non-empty, non-empty" ================================================================== > ghci -Wall T.hs GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( T.hs, interpreted ) T.hs:6:0: Warning: Pattern match(es) are overlapped In the definition of `test': test ((viewl -> EmptyL)) ((viewl -> EmptyL)) = ... test ((viewl -> EmptyL)) ((viewl -> _ :< _)) = ... test ((viewl -> _ :< _)) ((viewl -> EmptyL)) = ... test _ _ = ... T.hs:6:0: Warning: Pattern match(es) are non-exhaustive In the definition of `test': Patterns not matched: Ok, modules loaded: Main. *Main> test empty (singleton 'a') "empty, non-empty" *Main> test (singleton 'b') (singleton 'a') "non-empty, non-empty" *Main> test (singleton 'b') empty "non-empty, empty" *Main> test empty empty "empty, empty" There are warnings about non-exhaustive and overlapping pattern matches, but the tests show that this isn't the case. So what's the problem? I don't want to turn off or ignore warnings. //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From bugfact at gmail.com Wed Mar 11 12:22:48 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Mar 11 12:11:03 2009 Subject: [Haskell-cafe] Request: warn about language extensions that are not used In-Reply-To: <814617240903110916w6b500a51n7bed0e669779fab4@mail.gmail.com> References: <814617240903110916w6b500a51n7bed0e669779fab4@mail.gmail.com> Message-ID: Yes, exactly. Indeed I should have given an example, thanks for doing so, I was too hasty being lazy :) On Wed, Mar 11, 2009 at 5:16 PM, Creighton Hogg wrote: > 2009/3/11 Peter Verswyvelen : > > When I put > > {-# OPTIONS_GHC -Wall -Werror #-} > > in my source file, I don't get compiler (GHC) warnings about redundant > > language extensions that I enabled. > > It would be nice if the compiler gave warnings about this, since after > > refactoring, some language extensions might not be needed anymore, and > hence > > should be removed since fewer language extensions mean more stable and > > portable code no? > > What do you think? > > So you mean something like if you put {-# LANGUAGE > GeneralizedNewtypeDeriving #-} in a file, but never do newtype > deriving, it would warn you? > > I have no idea how hard that'd be to implement, but that sounds kind > of cool. Useful for both refactoring and when you've inherited old > code. > > Cheers, > C > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/8415cc13/attachment.htm From svein.ove at aas.no Wed Mar 11 12:25:32 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Mar 11 12:13:47 2009 Subject: [Haskell-cafe] View patterns and warnings about overlapping or non-exhaustive patterns In-Reply-To: <49B7E53B.2010801@web.de> References: <49B7E53B.2010801@web.de> Message-ID: <221b53ab0903110925p6b9e5cbbo2ec861e75ada8047@mail.gmail.com> On Wed, Mar 11, 2009 at 5:22 PM, Stephan Friedrichs wrote: > Hi, > > I'm working on a data structure that uses Data.Sequence a lot, so views > are important and I tried to simplify my code using view patterns. > > The problem is, that I keep getting warnings about both overlapping and > non-exhaustive pattern matches. A simple test case: > The view pattern implementation is currently incomplete, specifically in that it is unable to decide whether a pattern match using them is overlapping or non-exhaustive. Arguably the warnings should be suppressed instead.. For the time being, it will *work*, you just won't get useful warnings. Hopefully it's going to be fixed for 10.2. -- Svein Ove Aas From dons at galois.com Wed Mar 11 12:25:49 2009 From: dons at galois.com (Don Stewart) Date: Wed Mar 11 12:14:55 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <49B7E24F.8040009@libero.it> References: <49B6E97D.7080409@libero.it> <20090310224259.GK1077@whirlpool.galois.com> <49B6FF85.4070104@libero.it> <20090311005107.GP1077@whirlpool.galois.com> <49B7E24F.8040009@libero.it> Message-ID: <20090311162549.GA5290@whirlpool.galois.com> manlio_perillo: > Don Stewart ha scritto: >> manlio_perillo: >>> Don Stewart ha scritto: >>>> [...] >>>> {-# LANGUAGE OverloadedStrings #-} >>>> >>>> import qualified Data.ByteString.Char8 as C >>>> >>>> isMatch :: C.ByteString -> Bool >>>> isMatch "match" = True >>>> isMatch _ = False >>>> >>>> main = print . map isMatch . C.lines =<< C.getContents >>>> >>> What is the reason why instance declarations for IsString class are >>> not defined for available ByteStrings? >>> >>> I need to define it by myself. >> >> They're exported from Data.ByteString.Char8 >> > > Then there is something I'm missing. > Your code does not compile. Sure it does: $ ghci A.hs GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( A.hs, interpreted ) Ok, modules loaded: Main. *Main> :t main main :: IO () You should give any error message, and the steps you took that lead to the error when making a bug report. -- Don From ndmitchell at gmail.com Wed Mar 11 12:27:21 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Mar 11 12:15:37 2009 Subject: [Haskell-cafe] View patterns and warnings about overlapping or non-exhaustive patterns In-Reply-To: <49B7E53B.2010801@web.de> References: <49B7E53B.2010801@web.de> Message-ID: <404396ef0903110927h35eda475na2ae204cda222c6d@mail.gmail.com> Hi Stephan, > I'm working on a data structure that uses Data.Sequence a lot, so views > are important and I tried to simplify my code using view patterns. > > The problem is, that I keep getting warnings about both overlapping and > non-exhaustive pattern matches. A simple test case: http://hackage.haskell.org/trac/ghc/ticket/2395 Add yourself to the CC list if it matters to you! Thanks Neil From daniel.is.fischer at web.de Wed Mar 11 12:29:22 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Mar 11 12:17:38 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <49B7E24F.8040009@libero.it> References: <49B6E97D.7080409@libero.it> <20090311005107.GP1077@whirlpool.galois.com> <49B7E24F.8040009@libero.it> Message-ID: <200903111729.22194.daniel.is.fischer@web.de> Am Mittwoch, 11. M?rz 2009 17:09 schrieb Manlio Perillo: > Don Stewart ha scritto: > > manlio_perillo: > >> Don Stewart ha scritto: > >>> [...] > >>> {-# LANGUAGE OverloadedStrings #-} > >>> > >>> import qualified Data.ByteString.Char8 as C > >>> > >>> isMatch :: C.ByteString -> Bool > >>> isMatch "match" = True > >>> isMatch _ = False > >>> > >>> main = print . map isMatch . C.lines =<< C.getContents > >> > >> What is the reason why instance declarations for IsString class are not > >> defined for available ByteStrings? > >> > >> I need to define it by myself. > > > > They're exported from Data.ByteString.Char8 > > Then there is something I'm missing. A recent enough bytestring package. Compiles and works with 0.9.1.4 > Your code does not compile. > > > > Thanks Manlio Perillo > Cheers, Daniel From manlio_perillo at libero.it Wed Mar 11 12:41:39 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Mar 11 12:30:00 2009 Subject: [Haskell-cafe] advice on a parsing function In-Reply-To: <40a414c20903110921u55b3eb13l63a2b0c306d0edc1@mail.gmail.com> References: <49B7DFD9.9080504@libero.it> <40a414c20903110921u55b3eb13l63a2b0c306d0edc1@mail.gmail.com> Message-ID: <49B7E9C3.6000803@libero.it> minh thu ha scritto: > [...] > I suggest you try an alternative strategy. > That altenrative strategy is twofold, just like you have > quiz' and quiz'. > This alternate strategy avoid pattern matching on strings > (which would be cumbersome for a bit more complex syntax). > But for this specific case it is very compact and elegant (IMHO). > [...] > Now, given those two functions, try to apply them > on your input string, feeding the next function application > with the resulting string of the current application. > So, I should not split the string into lines? An useful feature of my program is that it parses both an input like: 1: 1046323,2005-12-19 and 1: 1046323 If I write a parser from scratch I need to implement two separate functions. I will give it a try, just to check if it has better performances. Thanks Manlio From deduktionstheorem at web.de Wed Mar 11 12:54:49 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Wed Mar 11 12:43:06 2009 Subject: [Haskell-cafe] View patterns and warnings about overlapping or non-exhaustive patterns In-Reply-To: <221b53ab0903110925p6b9e5cbbo2ec861e75ada8047@mail.gmail.com> References: <49B7E53B.2010801@web.de> <221b53ab0903110925p6b9e5cbbo2ec861e75ada8047@mail.gmail.com> Message-ID: <49B7ECD9.9070900@web.de> Svein Ove Aas wrote: > [...] > > For the time being, it will *work*, you just won't get useful > warnings. Hopefully it's going to be fixed for 10.2. > Hmm I don't find #2395 anywhere on http://hackage.haskell.org/trac/ghc/milestone/6.10.2 :( //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From noteed at gmail.com Wed Mar 11 13:29:26 2009 From: noteed at gmail.com (minh thu) Date: Wed Mar 11 13:17:41 2009 Subject: [Haskell-cafe] advice on a parsing function In-Reply-To: <49B7E9C3.6000803@libero.it> References: <49B7DFD9.9080504@libero.it> <40a414c20903110921u55b3eb13l63a2b0c306d0edc1@mail.gmail.com> <49B7E9C3.6000803@libero.it> Message-ID: <40a414c20903111029r672d7313g43b2327f11b49f7d@mail.gmail.com> 2009/3/11 Manlio Perillo : > minh thu ha scritto: >> >> [...] >> I suggest you try an alternative strategy. >> That altenrative strategy is twofold, just like you have >> quiz' and quiz'. >> This alternate strategy avoid pattern matching on strings >> (which would be cumbersome for a bit more complex syntax). >> > > But for this specific case it is very compact and elegant (IMHO). I would say it is difficult to see what you're doing in the code without the desciption you gave in the mail. But you're right, it's not the string pattern matching which is the problem. It is more the pair (Int, rest of the bytestring which can begin or not with ':')... Why not have quiz' accepting just the bytestring (and not the id value), and returning the (Int,[Int]) ? >> [...] >> Now, given those two functions, try to apply them >> on your input string, feeding the next function application >> with the resulting string of the current application. >> > > So, I should not split the string into lines? See below. > An useful feature of my program is that it parses both an input like: > > 1: > 1046323,2005-12-19 > > and > 1: > 1046323 > > > If I write a parser from scratch I need to implement two separate functions. I didn't think to that but nothing prevent you to write the second function I suggested to account for that case, or for an end of line (if can 'eat' the ':' from the input, you can also eat a newline). Thu From noteed at gmail.com Wed Mar 11 13:38:04 2009 From: noteed at gmail.com (minh thu) Date: Wed Mar 11 13:26:20 2009 Subject: [Haskell-cafe] advice on a parsing function In-Reply-To: <40a414c20903111029r672d7313g43b2327f11b49f7d@mail.gmail.com> References: <49B7DFD9.9080504@libero.it> <40a414c20903110921u55b3eb13l63a2b0c306d0edc1@mail.gmail.com> <49B7E9C3.6000803@libero.it> <40a414c20903111029r672d7313g43b2327f11b49f7d@mail.gmail.com> Message-ID: <40a414c20903111038o3858af56x330451e48e5cd37a@mail.gmail.com> 2009/3/11 minh thu : > 2009/3/11 Manlio Perillo : >> minh thu ha scritto: >>> >>> [...] >>> I suggest you try an alternative strategy. >>> That altenrative strategy is twofold, just like you have >>> quiz' and quiz'. >>> This alternate strategy avoid pattern matching on strings >>> (which would be cumbersome for a bit more complex syntax). >>> >> >> But for this specific case it is very compact and elegant (IMHO). > > I would say it is difficult to see what you're doing in the code without > the desciption you gave in the mail. But you're right, it's not the string > pattern matching which is the problem. > > It is more the pair (Int, rest of the bytestring which can begin or > not with ':')... > > Why not have quiz' accepting just the bytestring (and not the id value), > and returning the (Int,[Int]) ? > >>> [...] >>> Now, given those two functions, try to apply them >>> on your input string, feeding the next function application >>> with the resulting string of the current application. >>> >> >> So, I should not split the string into lines? > > See below. > >> An useful feature of my program is that it parses both an input like: >> >> 1: >> 1046323,2005-12-19 >> >> and >> 1: >> 1046323 >> >> >> If I write a parser from scratch I need to implement two separate functions. > > I didn't think to that but nothing prevent you to write the second function I > suggested to account for that case, or for an end of line (if can 'eat' the ':' > from the input, you can also eat a newline). > > Thu Ok, The approach I suggested is a bit overkill. You can indeed use L.lines to split the input into lines then work on that. But still, avoid the pair (Int, Bytestring). Instead, you can basically map on each line the unsafeReadInt modified to : - return the id - return if it is one kind of id or the other kind. so : type UserId = Int type MovieId = Int unsafeReadInt :: Line -> Either MovieId UserId Now you have a nice list [Either MovieId UserId] that you need to transform into (MovieId, [UserId]). Sorry, for the previous response. Thu From manlio_perillo at libero.it Wed Mar 11 13:59:25 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Mar 11 13:47:45 2009 Subject: [Haskell-cafe] advice on a parsing function In-Reply-To: <40a414c20903111038o3858af56x330451e48e5cd37a@mail.gmail.com> References: <49B7DFD9.9080504@libero.it> <40a414c20903110921u55b3eb13l63a2b0c306d0edc1@mail.gmail.com> <49B7E9C3.6000803@libero.it> <40a414c20903111029r672d7313g43b2327f11b49f7d@mail.gmail.com> <40a414c20903111038o3858af56x330451e48e5cd37a@mail.gmail.com> Message-ID: <49B7FBFD.7080305@libero.it> minh thu ha scritto: > [...] > The approach I suggested is a bit overkill. You can indeed use L.lines > to split the input into lines then work on that. > > But still, avoid the pair (Int, Bytestring). Instead, you can basically map > on each line the unsafeReadInt modified to : > - return the id > - return if it is one kind of id or the other kind. > > so : > type UserId = Int > type MovieId = Int > unsafeReadInt :: Line -> Either MovieId UserId > > Now you have a nice list [Either MovieId UserId] that > you need to transform into (MovieId, [UserId]). > Thanks, this seems a much better solution. Manlio From manlio_perillo at libero.it Wed Mar 11 14:01:48 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Mar 11 13:50:10 2009 Subject: [Haskell-cafe] ByteString in patterns In-Reply-To: <20090311162549.GA5290@whirlpool.galois.com> References: <49B6E97D.7080409@libero.it> <20090310224259.GK1077@whirlpool.galois.com> <49B6FF85.4070104@libero.it> <20090311005107.GP1077@whirlpool.galois.com> <49B7E24F.8040009@libero.it> <20090311162549.GA5290@whirlpool.galois.com> Message-ID: <49B7FC8C.3090806@libero.it> Don Stewart ha scritto: > [...] >> Then there is something I'm missing. >> Your code does not compile. > > Sure it does: > As Daniel suggested, I'm using an old bytestring version that came with Debian Etch (GHC 6.8.2). Thanks Manlio From bugfact at gmail.com Wed Mar 11 14:05:02 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Mar 11 13:53:17 2009 Subject: [Haskell-cafe] Request: warn about language extensions that are not used In-Reply-To: <814617240903110916w6b500a51n7bed0e669779fab4@mail.gmail.com> References: <814617240903110916w6b500a51n7bed0e669779fab4@mail.gmail.com> Message-ID: Okay, I submitted it as a GHC feature request. Thanks for the feedback. On Wed, Mar 11, 2009 at 5:16 PM, Creighton Hogg wrote: > 2009/3/11 Peter Verswyvelen : > > When I put > > {-# OPTIONS_GHC -Wall -Werror #-} > > in my source file, I don't get compiler (GHC) warnings about redundant > > language extensions that I enabled. > > It would be nice if the compiler gave warnings about this, since after > > refactoring, some language extensions might not be needed anymore, and > hence > > should be removed since fewer language extensions mean more stable and > > portable code no? > > What do you think? > > So you mean something like if you put {-# LANGUAGE > GeneralizedNewtypeDeriving #-} in a file, but never do newtype > deriving, it would warn you? > > I have no idea how hard that'd be to implement, but that sounds kind > of cool. Useful for both refactoring and when you've inherited old > code. > > Cheers, > C > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/58c17999/attachment.htm From rj248842 at hotmail.com Wed Mar 11 14:24:55 2009 From: rj248842 at hotmail.com (R J) Date: Wed Mar 11 14:13:15 2009 Subject: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr? Message-ID: foldl and foldr are defined as follows: foldr :: (a -> b -> b) -> b -> [a] -> b foldr f e [] = e foldr f e (x : xs) = f x (foldr f e xs) foldl :: (b -> a -> b) -> b -> [a] -> b foldl f e [] = e foldl f e (x : xs) = foldl f (f e x) xs 1. I understand how these definitions work, and yet I'm unable to implement foldl in terms of foldr. What's a systematic approach to identifying such an implementation, and what is the implementation? 2. I believe that the reverse implementation--namely, implementing foldr in terms of foldl--is impossible. What's the proof of that? 3. Any advice on how, aside from tons of practice, to develop the intuition for rapidly seeing solutions to questions like these would be much appreciated. The difficulty a newbie faces in answering seemingly simple questions like these is quite discouraging. _________________________________________________________________ Express your personality in color! Preview and select themes for Hotmail?. http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/c07cfd68/attachment.htm From aneumann at inf.fu-berlin.de Wed Mar 11 14:33:47 2009 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Wed Mar 11 14:22:20 2009 Subject: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr? In-Reply-To: References: Message-ID: <077A05E7-8128-41EF-97F3-87F81CE19868@inf.fu-berlin.de> Read this excellent paper: http://www.cs.nott.ac.uk/~gmh/fold.pdf Am 11.03.2009 um 19:24 schrieb R J: > foldl and foldr are defined as follows: > > foldr :: (a -> b -> b) -> b -> [a] -> b > foldr f e [] = e > foldr f e (x : xs) = f x (foldr f e xs) > > foldl :: (b -> a -> b) -> b -> [a] -> b > foldl f e [] = e > foldl f e (x : xs) = foldl f (f e x) xs > > 1. I understand how these definitions work, and yet I'm unable to > implement foldl in terms of foldr. What's a systematic approach to > identifying such an implementation, and what is the implementation? > > 2. I believe that the reverse implementation--namely, implementing > foldr in terms of foldl--is impossible. What's the proof of that? > > 3. Any advice on how, aside from tons of practice, to develop the > intuition for rapidly seeing solutions to questions like these > would be much appreciated. The difficulty a newbie faces in > answering seemingly simple questions like these is quite discouraging. > > Express your personality in color! Preview and select themes for > Hotmail?. See how. > _______________________________________________ > 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/20090311/4d9514ad/PGP.bin From manlio_perillo at libero.it Wed Mar 11 14:37:26 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Mar 11 14:25:48 2009 Subject: [Haskell-cafe] advice on a parsing function In-Reply-To: <49B7FBFD.7080305@libero.it> References: <49B7DFD9.9080504@libero.it> <40a414c20903110921u55b3eb13l63a2b0c306d0edc1@mail.gmail.com> <49B7E9C3.6000803@libero.it> <40a414c20903111029r672d7313g43b2327f11b49f7d@mail.gmail.com> <40a414c20903111038o3858af56x330451e48e5cd37a@mail.gmail.com> <49B7FBFD.7080305@libero.it> Message-ID: <49B804E6.401@libero.it> Manlio Perillo ha scritto: > minh thu ha scritto: >> [...] >> The approach I suggested is a bit overkill. You can indeed use L.lines >> to split the input into lines then work on that. >> >> But still, avoid the pair (Int, Bytestring). Instead, you can >> basically map >> on each line the unsafeReadInt modified to : >> - return the id >> - return if it is one kind of id or the other kind. >> >> so : >> type UserId = Int >> type MovieId = Int >> unsafeReadInt :: Line -> Either MovieId UserId >> >> Now you have a nice list [Either MovieId UserId] that >> you need to transform into (MovieId, [UserId]). >> > > Thanks, this seems a much better solution. > Done: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2309 real 1m15.220s user 0m4.816s sys 0m0.308s 3084 KB memory usage Previous version required 4956 KB of memory. Thanks again for the suggestion, Minh. Manlio From noteed at gmail.com Wed Mar 11 14:45:18 2009 From: noteed at gmail.com (minh thu) Date: Wed Mar 11 14:33:35 2009 Subject: [Haskell-cafe] advice on a parsing function In-Reply-To: <49B804E6.401@libero.it> References: <49B7DFD9.9080504@libero.it> <40a414c20903110921u55b3eb13l63a2b0c306d0edc1@mail.gmail.com> <49B7E9C3.6000803@libero.it> <40a414c20903111029r672d7313g43b2327f11b49f7d@mail.gmail.com> <40a414c20903111038o3858af56x330451e48e5cd37a@mail.gmail.com> <49B7FBFD.7080305@libero.it> <49B804E6.401@libero.it> Message-ID: <40a414c20903111145j2c254546x812b0cee315c6537@mail.gmail.com> 2009/3/11 Manlio Perillo : > Manlio Perillo ha scritto: >> >> minh thu ha scritto: >>> >>> [...] >>> The approach I suggested is a bit overkill. You can indeed use L.lines >>> to split the input into lines then work on that. >>> >>> But still, avoid the pair (Int, Bytestring). Instead, you can basically >>> map >>> on each line the unsafeReadInt modified to : >>> - return the id >>> - return if it is one kind of id or the other kind. >>> >>> so : >>> type UserId = Int >>> type MovieId = Int >>> unsafeReadInt :: Line -> Either MovieId UserId >>> >>> Now you have a nice list [Either MovieId UserId] that >>> you need to transform into (MovieId, [UserId]). >>> >> >> Thanks, this seems a much better solution. >> > > Done: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2309 One improvement you can do : In the line quiz' (Left id : l) = (id, quiz'' l) : quiz' l notice you use two times the 'l', and the next line of code pass through the Right case. Change your code so that quiz'' has a return type ([UserId],Bytestring). The above line becomes quiz' (Left id : l) = (id, ids) : quiz' rest where (ids,rest) = quiz'' l Thu From max.rabkin at gmail.com Wed Mar 11 14:52:39 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Wed Mar 11 14:40:58 2009 Subject: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr? In-Reply-To: References: Message-ID: 2009/3/11 R J : > 2.? I believe that the reverse implementation--namely, implementing foldr in > terms of foldl--is impossible.? What's the proof of that? That's correct. Consider their behaviour on infinite lists. --Max From dan.doel at gmail.com Wed Mar 11 15:02:29 2009 From: dan.doel at gmail.com (Dan Doel) Date: Wed Mar 11 14:51:00 2009 Subject: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr? In-Reply-To: References: Message-ID: <200903111502.29760.dan.doel@gmail.com> On Wednesday 11 March 2009 2:24:55 pm R J wrote: > foldl and foldr are defined as follows: > > foldr :: (a -> b -> b) -> b -> [a] -> b > foldr f e [] = e > foldr f e (x : xs) = f x (foldr f e xs) > > foldl :: (b -> a -> b) -> b -> [a] -> b > foldl f e [] = e > foldl f e (x : xs) = foldl f (f e x) xs > > 1. I understand how these definitions work, and yet I'm unable to > implement foldl in terms of foldr. What's a systematic approach to > identifying such an implementation, and what is the implementation? This is a bit tricky, because although the base cases of the two line up, the inductive cases do not. When that sort of thing happens, and you can't find a tweaking of the function that brings it into line with foldr, what one has to do is to start looking for definitions like: foldl'aux [] = e'aux foldl'aux (x:xs) = g x (foldl'aux xs) where you can get foldl from foldl'aux by applying some post-processing. In this case, you might fool around with foldl a bit: foldl f e [] = id e foldl f e (x:xs) = (\e -> foldl f (f e x) xs) e Noticing this, we might try factoring out the 'e' parameter, and building a function to apply it to... foldl' f [] = id foldl' f (x:xs) = \e -> foldl' f xs (f e x) = (\x e -> foldl' f xs (f e x)) x = (\x k e -> k (f e x)) x (foldl' f xs) And now this is in the correct form for implementation with foldr: foldl' f = foldr (\x k e -> k (f e x)) id And: foldl f e l = foldl' f l e = foldr (\x k e -> k (f e x)) id l e > 2. I believe that the reverse implementation--namely, implementing foldr > in terms of foldl--is impossible. What's the proof of that? This isn't a proof, but "foldl f z l" is bottom when l is an infinite list, regardless of f and z, whereas foldr works fine on infinite lists. This is at least a clue that implementing foldr in terms of foldl is a problem. Note that foldr *can* be implemented with foldl if you restrict yourself to finite lists. The definition is similar to the reverse. > 3. Any advice on how, aside from tons of practice, to develop the > intuition for rapidly seeing solutions to questions like these would be > much appreciated. The difficulty a newbie faces in answering seemingly > simple questions like these is quite discouraging. I recommend the paper Adrian Neumann linked to. :) -- Dan From daniel.is.fischer at web.de Wed Mar 11 15:09:36 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Mar 11 14:57:56 2009 Subject: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr? In-Reply-To: References: Message-ID: <200903112009.36896.daniel.is.fischer@web.de> Am Mittwoch, 11. M?rz 2009 19:24 schrieb R J: > foldl and foldr are defined as follows: > > foldr :: (a -> b -> b) -> b -> [a] -> b > foldr f e [] = e > foldr f e (x : xs) = f x (foldr f e xs) > > foldl :: (b -> a -> b) -> b -> [a] -> b > foldl f e [] = e > foldl f e (x : xs) = foldl f (f e x) xs > > 1. I understand how these definitions work, and yet I'm unable to > implement foldl in terms of foldr. What's a systematic approach to > identifying such an implementation, and what is the implementation? Implementation: myfoldl f e xs = foldr (flip f) e (reverse xs) Systematic approach: Assume you have an implementation. From considering simple cases, derive necessary conditions for the implementation. When the necessary conditions have narrowed the possibilities far enough down, check which of the remaining possibilities solve the problem. Here: foldl f e === foldr g v . h where h should be a simple polymorphic function on lists, h :: [a] -> [a] foldl f e [] = e, foldr g v (h []) = if null (h []) then v else g (h []) v since h should be generic, h [] can't be anything but [] or _|_, h [] = _|_ won't work with strict functions, so h [] = [] and v = e foldl f e [x] = f e x, foldr g e (h [x]) = if null (h [x]) then e else g (h [x]) e h [x] = [] would break for many f, as would h [x] = _|_, so h [x] can only be one of [x], [x,x], [x,x,x], ..., repeat x If h [x] = [x], we have foldr g e (h [x]) = g x e, and we must have forall x, e. f e x === g x e , hence g = flip f. If h [x] = [x,x] or [x,x,x] or ..., we would have to have f e x == x `g` (x `g` (... e)) pick a few simple examples which don't allow that, say f = (+), e = (0 :: Int), x = 1 f = (+), e = (1 :: Int), x = 1 foldl f e [x,y] = (e `f` x) `f` y foldr (flip f) e (h [x,y]) = ? foldr g e [u,v] = u `g` (v `g` e) with g = flip f, that reduces to (e `f` v) `f` u, so for [u,v] = [y,x] we have what we want, and our candidate is foldl f e =?= foldr (flip f) e . reverse The rest is tedious verification. > > 2. I believe that the reverse implementation--namely, implementing foldr > in terms of foldl--is impossible. What's the proof of that? foldr (++) [] (infinite list) that delivers something (unless all lists inside the infinite list are empty), but reverse (infinite list) never returns. > > 3. Any advice on how, aside from tons of practice, to develop the > intuition for rapidly seeing solutions to questions like these would be > much appreciated. The difficulty a newbie faces in answering seemingly > simple questions like these is quite discouraging. > Sorry, can't offer anything but practice. From lazycat.manatee at gmail.com Wed Mar 11 15:42:09 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Wed Mar 11 15:33:31 2009 Subject: [Haskell-cafe] How to insert character key self in sourceView? Message-ID: <87iqmfyhgu.fsf@debian.domain> Hi all, I use gtk2hs develop editor. I use below function handle key press event. keyPressHandler :: Event -> IO Bool keyPressHandler (Key {eventKeyName = keyName}) = do case keyName of "Escape" -> do mainQuit >> return True _ -> do -- How to insert character self? return True I need handle key press event, and insert itself if key is character (like: 'a' 'b' 'c'). How to insert character self in sourceView buffer? Below are complete source code: ------------------------------> source code start <------------------------------ import Graphics.UI.Gtk import Graphics.UI.Gtk.SourceView import Graphics.UI.Gtk.Abstract.Widget import Graphics.UI.Gtk.Gdk.Events import Text.Printf import Control.Monad main :: IO () main = do -- Init. initGUI -- Root frame. rootFrame <- windowNew onDestroy rootFrame mainQuit -- quit main loop when root frame close -- Root frame status. -- windowFullscreen rootFrame -- fullscreen windowSetPosition rootFrame WinPosCenter -- set init position windowSetDefaultSize rootFrame 400 300 -- set init size -- Main box. mainBox <- vBoxNew False 0 containerAdd rootFrame mainBox -- Source view box. sourceViewBox <- vBoxNew False 0 containerAdd mainBox sourceViewBox -- Source view. sourceView <- sourceViewNew boxPackStart sourceViewBox sourceView PackNatural 0 -- Echo area box. echoAreaBox <- vBoxNew False 0 echoAreaAlign <- alignmentNew 0 1 1 1 containerAdd echoAreaBox echoAreaAlign containerAdd mainBox echoAreaBox -- Echo area. echoArea <- statusbarNew boxPackStart echoAreaBox echoArea PackNatural 0 -- Display. widgetShowAll rootFrame -- Handle keystroke. onKeyPress rootFrame $ keyPressHandler -- Update echo area. updateEchoArea sourceView echoArea -- Loop mainGUI keyPressHandler :: Event -> IO Bool keyPressHandler (Key {eventKeyName = keyName}) = do case keyName of "Escape" -> do mainQuit >> return True _ -> do return True updateEchoArea :: SourceView -> Statusbar -> IO () updateEchoArea sv sb = do buf <- textViewGetBuffer sv mark <- textBufferGetInsert buf iter <- textBufferGetIterAtMark buf mark line <- textIterGetLine iter col <- textIterGetLineOffset iter statusbarPop sb 1 statusbarPush sb 1 $ printf "Line %4d, Column %3d" (line + 1) (col + 1) return () ------------------------------> source code end <------------------------------ Any help? Thanks! -- Andy From g9ks157k at acme.softbase.org Wed Mar 11 16:18:32 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Wed Mar 11 16:06:47 2009 Subject: [Haskell-cafe] How to insert character key self in sourceView? In-Reply-To: <87iqmfyhgu.fsf@debian.domain> References: <87iqmfyhgu.fsf@debian.domain> Message-ID: <200903112118.33100.g9ks157k@acme.softbase.org> Maybe you should direct your question to the Gtk2Hs users mailing list . Best wishes, Wolfgang From lazycat.manatee at gmail.com Wed Mar 11 16:32:09 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Wed Mar 11 16:23:35 2009 Subject: [Haskell-cafe] Re: How to insert character key self in sourceView? References: <87iqmfyhgu.fsf@debian.domain> Message-ID: <87ab7ryf5i.fsf@debian.domain> Andy Stewart writes: > Hi all, > > I use gtk2hs develop editor. > > I use below function handle key press event. > > keyPressHandler :: Event -> IO Bool > keyPressHandler (Key {eventKeyName = keyName}) = do > case keyName of > "Escape" -> do > mainQuit >> return True > _ -> do > -- How to insert character self? > return True > I answer self. Just modified like below: keyPressHandler :: Event -> IO Bool keyPressHandler (Key {eventKeyName = keyName}) = do case keyName of "Escape" -> do mainQuit >> return True _ -> return False Okay, now fix. :) -- Andy From bugfact at gmail.com Wed Mar 11 16:37:48 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Mar 11 16:26:06 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: <7b501d5c0903110652qbcc5222jc27e06837f4a2da4@mail.gmail.com> References: <49B5AD46.2020502@gmail.com> <200903111106.38093.g9ks157k@acme.softbase.org> <185556958.20090311132702@gmail.com> <40a414c20903110426u40abfca5kd98056adbec0df8a@mail.gmail.com> <7b501d5c0903110652qbcc5222jc27e06837f4a2da4@mail.gmail.com> Message-ID: In Dutch it is "luiaard' and that also means "lazy person". On Wed, Mar 11, 2009 at 2:52 PM, Deniz Dogan wrote: > 2009/3/11 minh thu : > > 2009/3/11 Bulat Ziganshin : > >> Hello Wolfgang, > >> > >> Wednesday, March 11, 2009, 1:06:37 PM, you wrote: > >> > >>>> Hehe, I love it. Sloth is a synonym for Lazyness in English too, and > >>>> they're so freaking cute... :) > >> > >>> Same in German: The german ?Faultier? means ?lazy animal?. > >> > >> russian too, if that matter. i was really amazed by this idea. > >> pure, lazy and fun! :) > > > > Same in french : 'paresseux' just means lazy. > > > > Thu > > In Swedish it translates to "late walker" (?) and in Turkish it's "lazy > animal". > > Deniz > _______________________________________________ > 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/20090311/334606ae/attachment.htm From ryani.spam at gmail.com Wed Mar 11 17:11:36 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Mar 11 16:59:52 2009 Subject: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr? In-Reply-To: References: Message-ID: <2f9b2d30903111411j11f407aak7b7b61000796a000@mail.gmail.com> 2009/3/11 R J : > 3.? Any advice on how, aside from tons of practice, to develop the intuition > for rapidly seeing solutions to questions like these would be much > appreciated.? The difficulty a newbie faces in answering seemingly simple > questions like these is quite discouraging. Don't be discouraged; this is far from a simple question. I still don't have an intuitive understanding of the "use functions" definition of foldl-in-terms-of-foldr: > foldl f z xs = foldr magic id xs z where > magic x k e = k (f e x) "magic" just looks like a bunch of characters that somehow typechecks. This definition of "magic" is slightly more comprehensible to me: > magic x k = k . flip f x The definition with reverse is easier to understand but seems less elegant: > foldl f z xs = foldr (flip f) z (reverse xs) But it does follow almost directly from these definitions for foldl and foldr on finite lists: foldr f z [x1, x2, x3, ..., xN] = x1 `f` (x2 `f` (x3 `f` ... (xN `f` z)...)) foldl f z [xN, ..., x3, x2, x1] = ((...(z `f` xN)... `f` x3) `f` x2) `f` x1 -- ryan From manlio_perillo at libero.it Wed Mar 11 18:13:02 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Mar 11 18:01:22 2009 Subject: [Haskell-cafe] generic sum for an UArr Message-ID: <49B8376E.3040007@libero.it> Hi. I have an array (Data.Array.Vector.UArr) of Word8 elements. Elements are stored as Word8 to keep memory usage down. Now I need to compute the sum of all the array elements; what is the best method? The sum must be of type Int. How efficient is to simply convert to an UArr Int, using: mapU fromIntegral v :: UArr Int ? What about, instead, of something like: genericSumU :: (UA e, Integral e) => UArr e -> Int genericSumU = foldU add 0 where add x y = x + fromIntegral y ? Unfortunately the latter does not compile: Couldn't match expected type `Int' against inferred type `e' `e' is a rigid type variable bound by the type signature for `genericSumU' at bin/process-data-1.hs:64:19 In the expression: foldU add 0 In the definition of `genericSumU': genericSumU = foldU add 0 where add x y = x + fromIntegral y Moreover, this is not really a generic version. I would like to have: genericSumU :: (Num i, UA e, Num e) => UArr e -> i is this possible? Thanks Manlio From daniel.is.fischer at web.de Wed Mar 11 18:27:10 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Mar 11 18:15:26 2009 Subject: [Haskell-cafe] generic sum for an UArr In-Reply-To: <49B8376E.3040007@libero.it> References: <49B8376E.3040007@libero.it> Message-ID: <200903112327.10899.daniel.is.fischer@web.de> Am Mittwoch, 11. M?rz 2009 23:13 schrieb Manlio Perillo: > Hi. > > I have an array (Data.Array.Vector.UArr) of Word8 elements. > Elements are stored as Word8 to keep memory usage down. > > Now I need to compute the sum of all the array elements; what is the > best method? > The sum must be of type Int. > > > How efficient is to simply convert to an UArr Int, using: > > mapU fromIntegral v :: UArr Int > ? > > > What about, instead, of something like: > > genericSumU :: (UA e, Integral e) => UArr e -> Int > genericSumU = foldU add 0 That would have to be foldlU, the type of foldU is foldU :: UA a => (a -> a -> a) -> a -> UArr a -> a while foldlU :: UA a => (b -> a -> b) -> b -> UArr a -> b > where > add x y = x + fromIntegral y > ? > > > Unfortunately the latter does not compile: > > Couldn't match expected type `Int' against inferred type `e' > `e' is a rigid type variable bound by > the type signature for `genericSumU' at > bin/process-data-1.hs:64:19 > In the expression: foldU add 0 > In the definition of `genericSumU': > genericSumU = foldU add 0 > where > add x y = x + fromIntegral y > > > Moreover, this is not really a generic version. > I would like to have: > > genericSumU :: (Num i, UA e, Num e) => UArr e -> i > > is this possible? > > > > Thanks Manlio > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From manlio_perillo at libero.it Wed Mar 11 18:55:50 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Mar 11 18:44:09 2009 Subject: [Haskell-cafe] generic sum for an UArr In-Reply-To: <200903112327.10899.daniel.is.fischer@web.de> References: <49B8376E.3040007@libero.it> <200903112327.10899.daniel.is.fischer@web.de> Message-ID: <49B84176.8070603@libero.it> Daniel Fischer ha scritto: > [...] >> genericSumU :: (UA e, Integral e) => UArr e -> Int >> genericSumU = foldU add 0 > > That would have to be foldlU, the type of foldU is > foldU :: UA a => (a -> a -> a) -> a -> UArr a -> a > > while > foldlU :: UA a => (b -> a -> b) -> b -> UArr a -> b > Damn... I was reading the source code of uvector, where foldU = foldlU and I totally forgot to check types. Thanks Manlio From duane.johnson at gmail.com Wed Mar 11 19:23:16 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Wed Mar 11 19:11:36 2009 Subject: [Haskell-cafe] Loading 3D points & normals into OpenGL? Message-ID: <356E06E1-FB4D-47EC-A8F2-ABE2E2B06CC7@gmail.com> Hi, I am considering writing a VRML (.wrl) parser so that I can load points and normals for a game I'm making in Haskell. Is there something around that will already do the trick? Or perhaps another format is preferred and already supported? Thanks, Duane Johnson (canadaduane) http://blog.inquirylabs.com/ From lrpalmer at gmail.com Wed Mar 11 19:28:50 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Mar 11 19:17:05 2009 Subject: [Haskell-cafe] Loading 3D points & normals into OpenGL? In-Reply-To: <356E06E1-FB4D-47EC-A8F2-ABE2E2B06CC7@gmail.com> References: <356E06E1-FB4D-47EC-A8F2-ABE2E2B06CC7@gmail.com> Message-ID: <7ca3f0160903111628i1c308e1fmf3f591a2bad7797c@mail.gmail.com> You might be interested in the obj library: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/obj Luke On Wed, Mar 11, 2009 at 5:23 PM, Duane Johnson wrote: > Hi, > > I am considering writing a VRML (.wrl) parser so that I can load points and > normals for a game I'm making in Haskell. Is there something around that > will already do the trick? Or perhaps another format is preferred and > already supported? > > Thanks, > Duane Johnson > (canadaduane) > http://blog.inquirylabs.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/20090311/d47191c8/attachment.htm From rick.richardson at gmail.com Wed Mar 11 20:19:53 2009 From: rick.richardson at gmail.com (Rick R) Date: Wed Mar 11 20:08:08 2009 Subject: [Haskell-cafe] Binary Parsing Message-ID: <9810b81b0903111719n69bd0235v983b621a27bd336a@mail.gmail.com> I have basic beginning to a parser for the BSON spec: http://www.mongodb.org/display/DOCS/BSON It is basically a binary compressed form of JSON. The usage model should be general, but I intend to read this data over TCP. Currently my system is quite inefficient, I convert leading bytes to Int then switch based on that type that that Int represtents. I was wondering if there is a tool set that exists for this purpose. For instance, should I use Data.Binary and make my Binary instance of get and put use the BSON protocol? Or is that not correct? I also looked at Parsec.ByteString, but that seems to only have a file input mechanism, and tcp buffers may be out of its scope. Are there any other tools that I should look at? I'm sure similar things have been done before. Can anyone point me to some open, successful implementations that I could mimick? -- We can't solve problems by using the same kind of thinking we used when we created them. - A. Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/fa726dbb/attachment.htm From Ben.Lippmeier at anu.edu.au Wed Mar 11 20:23:57 2009 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Wed Mar 11 20:12:12 2009 Subject: [Haskell-cafe] ThreadScope: Request for features for the performance tuning of parallel and concurrent Haskell programs In-Reply-To: References: Message-ID: <2E753E6C-E53E-4972-9A23-681B4A61A278@anu.edu.au> Hi Satnam, On 12/03/2009, at 12:24 AM, Satnam Singh wrote: > Before making the release I thought it would be an idea to ask > people what other features people would find useful or performance > tuning. So if you have any suggestions please do let us know! > Is it available in a branch somewhere to try out? Ben. From duane.johnson at gmail.com Wed Mar 11 20:36:53 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Wed Mar 11 20:25:12 2009 Subject: [Haskell-cafe] Loading 3D points & normals into OpenGL? In-Reply-To: <7ca3f0160903111628i1c308e1fmf3f591a2bad7797c@mail.gmail.com> References: <356E06E1-FB4D-47EC-A8F2-ABE2E2B06CC7@gmail.com> <7ca3f0160903111628i1c308e1fmf3f591a2bad7797c@mail.gmail.com> Message-ID: The MTL portion of that library depends on an external DevIL library ... is there a way to specify just the Obj portion which has no such dependency? Thanks, Duane On Mar 11, 2009, at 5:28 PM, Luke Palmer wrote: > You might be interested in the obj library: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/obj > > Luke > > On Wed, Mar 11, 2009 at 5:23 PM, Duane Johnson > wrote: > Hi, > > I am considering writing a VRML (.wrl) parser so that I can load > points and normals for a game I'm making in Haskell. Is there > something around that will already do the trick? Or perhaps another > format is preferred and already supported? > > Thanks, > Duane Johnson > (canadaduane) > http://blog.inquirylabs.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/20090311/834e6326/attachment.htm From tom.davie at gmail.com Wed Mar 11 20:39:55 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Mar 11 20:28:12 2009 Subject: [Haskell-cafe] Loading 3D points & normals into OpenGL? In-Reply-To: References: <356E06E1-FB4D-47EC-A8F2-ABE2E2B06CC7@gmail.com> <7ca3f0160903111628i1c308e1fmf3f591a2bad7797c@mail.gmail.com> Message-ID: <7EDFB992-3936-49A8-B56E-E72B9394B9DE@gmail.com> If you were to strip out all texture loading code, then yes, otherwise, no. Bob On 12 Mar 2009, at 01:36, Duane Johnson wrote: > The MTL portion of that library depends on an external DevIL > library ... is there a way to specify just the Obj portion which has > no such dependency? > > Thanks, > Duane > > On Mar 11, 2009, at 5:28 PM, Luke Palmer wrote: > >> You might be interested in the obj library: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/obj >> >> Luke >> >> On Wed, Mar 11, 2009 at 5:23 PM, Duane Johnson > > wrote: >> Hi, >> >> I am considering writing a VRML (.wrl) parser so that I can load >> points and normals for a game I'm making in Haskell. Is there >> something around that will already do the trick? Or perhaps >> another format is preferred and already supported? >> >> Thanks, >> Duane Johnson >> (canadaduane) >> http://blog.inquirylabs.com/ >> _______________________________________________ >> 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 dbueno at gmail.com Wed Mar 11 22:42:02 2009 From: dbueno at gmail.com (Denis Bueno) Date: Wed Mar 11 22:30:15 2009 Subject: [Haskell-cafe] Binary Parsing In-Reply-To: <9810b81b0903111719n69bd0235v983b621a27bd336a@mail.gmail.com> References: <9810b81b0903111719n69bd0235v983b621a27bd336a@mail.gmail.com> Message-ID: <6dbd4d000903111942q24a4be9am24b6de69fe7b90b5@mail.gmail.com> 2009/3/11 Rick R : > I have basic beginning to a parser for the BSON spec: > http://www.mongodb.org/display/DOCS/BSON > It is basically a binary compressed form of JSON. > The usage model should be general, but I intend to read this data over TCP. [...] > I was wondering if there is a tool set that exists for this purpose. For > instance, should I use Data.Binary and make my Binary instance of get and > put use the BSON protocol? Or is that not correct? It sounds like this would work well. I just used Data.Binary for the first time yesterday to parse a few several-hundred-megabyte files, and I have no complaints. Its interface allows for testing of nice properties, like that (decode . encode $ x) == x. Along with quickCheck and an Arbitrary instance for your unserialised types, this makes it easy to find problems in your coding. The Data.Binary authors have also gone to some trouble to make it all efficient -- you really should try it out. Denis From golubovsky at gmail.com Wed Mar 11 22:42:14 2009 From: golubovsky at gmail.com (Dimitry Golubovsky) Date: Wed Mar 11 22:30:29 2009 Subject: [Haskell-cafe] How to get program command line arguments in Unicode-aware way (Unix/Linux)? Message-ID: Hi, I am trying to process command line arguments that may contain Unicode (cyrillic in this example) characters. The standard GHC's getArgs seems to pass whatever was obtained from the underlying C library without any regard to encoding, e. g the following program (testarg.hs): module Main where import System.Environment main = do x <- getArgs mapM (putStrLn . show) x being invoked (ghc 6.10.1) runghc testarg -T '?????' prints the following: "-T" "\208\191\209\128\208\184<\208\178>\208\181\209\130" (not correct, all bytes were passed without proper encoding) Is there any way to get program arguments in GHC Unicode-aware? Or at least assuming that they are always in UTF-8? Something like System.IO.UTF8, but for command line arguments? Thanks. PS: BTW runhugs testarg -T '?????' prints: "-T" "\1087\1088\1080<\1074>\1077\1090" which is correct. -- Dimitry Golubovsky Anywhere on the Web From dbueno at gmail.com Wed Mar 11 22:54:23 2009 From: dbueno at gmail.com (Denis Bueno) Date: Wed Mar 11 22:42:37 2009 Subject: [Haskell-cafe] Data.Binary patches? Message-ID: <6dbd4d000903111954j11ff4931n2053aeb08b80c47b@mail.gmail.com> I've got a small patch for Data.Binary. Should I post it here, or is there some more appropriate forum? http://code.haskell.org/binary/ doesn't specify. Thanks, Denis From tanimoto at arizona.edu Wed Mar 11 23:00:15 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Wed Mar 11 22:48:29 2009 Subject: [Haskell-cafe] Data.Binary patches? In-Reply-To: <6dbd4d000903111954j11ff4931n2053aeb08b80c47b@mail.gmail.com> References: <6dbd4d000903111954j11ff4931n2053aeb08b80c47b@mail.gmail.com> Message-ID: Hi Denis, On Wed, Mar 11, 2009 at 9:54 PM, Denis Bueno wrote: > I've got a small patch for Data.Binary. ?Should I post it here, or is > there some more appropriate forum? > > http://code.haskell.org/binary/ doesn't specify. > > Thanks, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Denis > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > I've sent one to Don and he was quick to reply. But in general you can check the cabal file and send it to the maintainer: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary Cheers, Paulo From dbueno at gmail.com Wed Mar 11 23:00:21 2009 From: dbueno at gmail.com (Denis Bueno) Date: Wed Mar 11 22:48:39 2009 Subject: [Haskell-cafe] Re: Data.Binary patches? In-Reply-To: <6dbd4d000903111954j11ff4931n2053aeb08b80c47b@mail.gmail.com> References: <6dbd4d000903111954j11ff4931n2053aeb08b80c47b@mail.gmail.com> Message-ID: <6dbd4d000903112000h674c6c48p279e41188716036a@mail.gmail.com> On Wed, Mar 11, 2009 at 20:54, Denis Bueno wrote: > I've got a small patch for Data.Binary. ?Should I post it here, or is > there some more appropriate forum? In case whoever reads this is a Data.Binary maintainer, the patch is now attached, to save you some work. The .patch file is the output of darcs send -a --output=. Denis -------------- next part -------------- A non-text attachment was scrubbed... Name: getError.patch Type: application/octet-stream Size: 5352 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/ba811b45/getError.obj From mad.one at gmail.com Wed Mar 11 23:04:28 2009 From: mad.one at gmail.com (Austin Seipp) Date: Wed Mar 11 22:52:45 2009 Subject: [Haskell-cafe] How to get program command line arguments in Unicode-aware way (Unix/Linux)? In-Reply-To: References: Message-ID: <1236827030-sup-4450@existential.local> Excerpts from Dimitry Golubovsky's message of Wed Mar 11 21:42:14 -0500 2009: > Hi, > > I am trying to process command line arguments that may contain Unicode > (cyrillic in this example) characters. > > The standard GHC's getArgs seems to pass whatever was obtained from > the underlying C library > without any regard to encoding, e. g the following program (testarg.hs): > > module Main where > > import System.Environment > > main = do > x <- getArgs > mapM (putStrLn . show) x > > being invoked (ghc 6.10.1) > > runghc testarg -T '?????' > > prints the following: > > "-T" > "\208\191\209\128\208\184<\208\178>\208\181\209\130" > > (not correct, all bytes were passed without proper encoding) > > Is there any way to get program arguments in GHC Unicode-aware? Or at > least assuming that they are always in UTF-8? > Something like System.IO.UTF8, but for command line arguments? > > Thanks. > > PS: BTW runhugs testarg -T '?????' prints: > > "-T" > "\1087\1088\1080<\1074>\1077\1090" > > which is correct. > Hello, Would this approach work using utf8-string? import Codec.Binary.UTF8.String import System.Environment import Control.Monad main = do x <- liftM (map decodeString) getArgs mapM_ (putStrLn . encodeString) x Austin From artyom.shalkhakov at gmail.com Thu Mar 12 00:12:00 2009 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Thu Mar 12 00:00:21 2009 Subject: [Haskell-cafe] Loading 3D points & normals into OpenGL? In-Reply-To: <356E06E1-FB4D-47EC-A8F2-ABE2E2B06CC7@gmail.com> References: <356E06E1-FB4D-47EC-A8F2-ABE2E2B06CC7@gmail.com> Message-ID: Hello, Duane Johnson ?????(?) ? ????? ?????? Thu, 12 Mar 2009 05:23:16 +0600: > Is there something around that will already do the trick? Or perhaps > another > format is preferred and already supported? I'd advise you to restrict yourself to your (specific?) requirements. VRML is complex, and in fact can be an overkill to use in a (simple?) game. There's another route you can take, though: write an exporter from some intermediate format (like Collada or Blender), that would strip off features you don't intend to handle. -- Cheers, Artyom Shalkhakov From jon.fairbairn at cl.cam.ac.uk Thu Mar 12 05:49:35 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Thu Mar 12 05:38:00 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot References: <49B5AD46.2020502@gmail.com> Message-ID: Joe Fredette writes: > Hehe, I love it. Sloth is a synonym for Lazyness in English > too, and they're so freaking cute... :) I wouldn't say it was an exact synonym. Though the dictionary definitions are similar, sloth has a more negative connotation than laziness; the fourth deadly sin is called "sloth" rather than "laziness". I think using it as a mascot is a bad idea: "Haskell is so slow, they even chose a sloth as the mascot". -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2009-01-31) From bulat.ziganshin at gmail.com Thu Mar 12 05:57:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Mar 12 05:47:06 2009 Subject: [Haskell-cafe] How to get program command line arguments in Unicode-aware way (Unix/Linux)? In-Reply-To: References: Message-ID: <29822125.20090312125747@gmail.com> Hello Dimitry, Thursday, March 12, 2009, 5:42:14 AM, you wrote: depends on your OS. for windows i use this code: myGetArgs = do alloca $ \p_argc -> do p_argv_w <- commandLineToArgvW getCommandLineW p_argc argc <- peek p_argc argv_w <- peekArray (i argc) p_argv_w mapM peekTString argv_w >>== tail foreign import stdcall unsafe "windows.h GetCommandLineW" getCommandLineW :: LPTSTR foreign import stdcall unsafe "windows.h CommandLineToArgvW" commandLineToArgvW :: LPCWSTR -> Ptr CInt -> IO (Ptr LPWSTR) note that it doesn't skip over +RTS sections. btw, i plan to make unicode-aware version of System.Directory module to solve all these problems > I am trying to process command line arguments that may contain Unicode > (cyrillic in this example) characters. > The standard GHC's getArgs seems to pass whatever was obtained from > the underlying C library > without any regard to encoding, e. g the following program (testarg.hs): > module Main where > import System.Environment > main = do > x <- getArgs > mapM (putStrLn . show) x > being invoked (ghc 6.10.1) > runghc testarg -T '?????' > prints the following: > "-T" > "\208\191\209\128\208\184<\208\178>\208\181\209\130" > (not correct, all bytes were passed without proper encoding) > Is there any way to get program arguments in GHC Unicode-aware? Or at > least assuming that they are always in UTF-8? > Something like System.IO.UTF8, but for command line arguments? > Thanks. > PS: BTW runhugs testarg -T '?????' prints: > "-T" > "\1087\1088\1080<\1074>\1077\1090" > which is correct. -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Thu Mar 12 06:00:25 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Mar 12 05:48:52 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: References: <49B5AD46.2020502@gmail.com> Message-ID: <1218601974.20090312130025@gmail.com> Hello Jon, Thursday, March 12, 2009, 12:49:35 PM, you wrote: > I think using it as a mascot is a bad idea: "Haskell is so > slow, they even chose a sloth as the mascot". and it will be absolute truth :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From noteed at gmail.com Thu Mar 12 06:03:36 2009 From: noteed at gmail.com (minh thu) Date: Thu Mar 12 05:51:49 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: <1218601974.20090312130025@gmail.com> References: <49B5AD46.2020502@gmail.com> <1218601974.20090312130025@gmail.com> Message-ID: <40a414c20903120303w20125e96uf8a473b5cc175cf@mail.gmail.com> 2009/3/12 Bulat Ziganshin : > Hello Jon, > > Thursday, March 12, 2009, 12:49:35 PM, you wrote: > >> I think using it as a mascot is a bad idea: "Haskell is so >> slow, they even chose a sloth as the mascot". > > and it will be absolute truth :) Anyway, choosing a programming language based on its logo is quite childish. And wasn't the moto "Avoid success at all cost" ? Thu From satnams at microsoft.com Thu Mar 12 06:08:58 2009 From: satnams at microsoft.com (Satnam Singh) Date: Thu Mar 12 05:57:15 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: References: <49B5AD46.2020502@gmail.com> Message-ID: I agree that looking for a mascot that is inspired by "laziness" is a bad idea from a P.R. perspective (I am tired of people walking out the room when I give Haskell talks to general audiences and explain lazy evaluation). Perhaps this is just an indication of my dark and violent side, but choosing an animal with a killer instinct might be a better idea. A creature that would eat something small and furry as a mid afternoon snack How about a viper? http://viperfashion.com/wp-content/uploads/2008/12/5742_coiled_up_viper_snake_sticking_tongue_out.jpg Cheers, Satnam -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Jon Fairbairn Sent: 12 March 2009 09:50 To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot Joe Fredette writes: > Hehe, I love it. Sloth is a synonym for Lazyness in English > too, and they're so freaking cute... :) I wouldn't say it was an exact synonym. Though the dictionary definitions are similar, sloth has a more negative connotation than laziness; the fourth deadly sin is called "sloth" rather than "laziness". I think using it as a mascot is a bad idea: "Haskell is so slow, they even chose a sloth as the mascot". -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2009-01-31) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From bulat.ziganshin at gmail.com Thu Mar 12 06:12:58 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Mar 12 06:01:27 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: References: <49B5AD46.2020502@gmail.com> Message-ID: <1185843215.20090312131258@gmail.com> Hello Satnam, Thursday, March 12, 2009, 1:08:58 PM, you wrote: > Perhaps this is just an indication of my dark and violent side, but > choosing an animal with a killer instinct might be a better idea. A > creature that would eat something small and furry as a mid afternoon snack why not choose Hitler or Mao? this will clearly indicate our intentions :D -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From aapo at pokat.org Thu Mar 12 07:35:21 2009 From: aapo at pokat.org (Aapo Lehtinen) Date: Thu Mar 12 07:23:50 2009 Subject: [Haskell-cafe] Sugestion for a Haskell mascot In-Reply-To: References: <49B5AD46.2020502@gmail.com> <200903111106.38093.g9ks157k@acme.softbase.org> <185556958.20090311132702@gmail.com> <40a414c20903110426u40abfca5kd98056adbec0df8a@mail.gmail.com> <7b501d5c0903110652qbcc5222jc27e06837f4a2da4@mail.gmail.com> Message-ID: <49B8F379.7020906@pokat.org> Peter Verswyvelen wrote: > In Dutch it is "luiaard' and that also means "lazy person". > > > > > On Wed, Mar 11, 2009 at 2:52 PM, Deniz Dogan > > wrote: > > 2009/3/11 minh thu >: > > 2009/3/11 Bulat Ziganshin >: > >> Hello Wolfgang, > >> > >> Wednesday, March 11, 2009, 1:06:37 PM, you wrote: > >> > >>>> Hehe, I love it. Sloth is a synonym for Lazyness in English > too, and > >>>> they're so freaking cute... :) > >> > >>> Same in German: The german ?Faultier? means ?lazy animal?. > >> > >> russian too, if that matter. i was really amazed by this idea. > >> pure, lazy and fun! :) > > > > Same in french : 'paresseux' just means lazy. > > > > Thu > > In Swedish it translates to "late walker" (?) and in Turkish it's > "lazy animal". > > Deniz > _______________________________________________ > 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 > Meaning is same in Finnish, "laiskiainen", where "laiska" translates to "lazy". From bugfact at gmail.com Thu Mar 12 07:37:55 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Mar 12 07:26:08 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance Message-ID: I think. Or is it defined in some other package? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/539aabf4/attachment.htm From magnumbud2 at hotmail.com Thu Mar 12 07:45:11 2009 From: magnumbud2 at hotmail.com (michael millard) Date: Thu Mar 12 07:33:24 2009 Subject: [Haskell-cafe] Haskell SDL Message-ID: hi, im having trouble setting up the haskell sdl bindings for windows vista im trying to install using minGW but its just not installing correctly. does anyone know any good tutorials for this? _________________________________________________________________ Get 30 Free Emoticons for your Windows Live Messenger http://www.livemessenger-emoticons.com/funfamily/en-ie/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/7e0e9b4a/attachment.htm From deniz.a.m.dogan at gmail.com Thu Mar 12 07:53:37 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Mar 12 07:41:51 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: References: <49B5AD46.2020502@gmail.com> Message-ID: <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> 2009/3/12 Satnam Singh : > I agree that looking for a mascot that is inspired by "laziness" is a bad idea from a P.R. perspective (I am tired of people walking out the room when I give Haskell talks to general audiences and explain lazy evaluation). > > Perhaps this is just an indication of my dark and violent side, but choosing an animal with a killer instinct might be a better idea. A creature that would eat something small and furry as a mid afternoon snack > > How about a viper? http://viperfashion.com/wp-content/uploads/2008/12/5742_coiled_up_viper_snake_sticking_tongue_out.jpg Python already uses a snake and it reminds me too much of vi and viper-mode etc. If so many people are reluctant towards the sloth, why don't we just go for the narwhal? They're predators, they have built-in swords and they're just bad ass in general. Then of course, there's the downside that there's no connection to the language itself in any way. Deniz From colin at colina.demon.co.uk Thu Mar 12 07:57:15 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Mar 12 07:45:36 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> (Deniz Dogan's message of "Thu\, 12 Mar 2009 12\:53\:37 +0100") References: <49B5AD46.2020502@gmail.com> <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> Message-ID: >>>>> "Deniz" == Deniz Dogan writes: Deniz> 2009/3/12 Satnam Singh : >> I agree that looking for a mascot that is inspired by >> "laziness" is a bad idea from a P.R. perspective (I am tired of >> people walking out the room when I give Haskell talks to >> general audiences and explain lazy evaluation). >> >> Perhaps this is just an indication of my dark and violent side, >> but choosing an animal with a killer instinct might be a better >> idea. A creature that would eat something small and furry as a >> mid afternoon snack >> >> How about a viper? >> http://viperfashion.com/wp-content/uploads/2008/12/5742_coiled_up_viper_snake_sticking_tongue_out.jpg Deniz> Python already uses a snake and it reminds me too much of Deniz> vi and viper-mode etc. If so many people are reluctant Deniz> towards the sloth, why don't we just go for the narwhal? Deniz> They're predators, they have built-in swords and they're Deniz> just bad ass in general. Then of course, there's the Deniz> downside that there's no connection to the language itself Deniz> in any way. Why not just dispense with a mascot? It's rather childish. New motto for Haskell: "Avoid mascots at all cost". -- Colin Adams Preston Lancashire From deniz.a.m.dogan at gmail.com Thu Mar 12 07:59:49 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Mar 12 07:48:03 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: References: <49B5AD46.2020502@gmail.com> <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> Message-ID: <7b501d5c0903120459j46bd4e0fs44ad668c7d755a7b@mail.gmail.com> 2009/3/12 Colin Paul Adams : >>>>>> "Deniz" == Deniz Dogan writes: > > ? ?Deniz> 2009/3/12 Satnam Singh : > ? ?>> I agree that looking for a mascot that is inspired by > ? ?>> "laziness" is a bad idea from a P.R. perspective (I am tired of > ? ?>> people walking out the room when I give Haskell talks to > ? ?>> general audiences and explain lazy evaluation). > ? ?>> > ? ?>> Perhaps this is just an indication of my dark and violent side, > ? ?>> but choosing an animal with a killer instinct might be a better > ? ?>> idea. A creature that would eat something small and furry as a > ? ?>> mid afternoon snack > ? ?>> > ? ?>> How about a viper? > ? ?>> http://viperfashion.com/wp-content/uploads/2008/12/5742_coiled_up_viper_snake_sticking_tongue_out.jpg > > ? ?Deniz> Python already uses a snake and it reminds me too much of > ? ?Deniz> vi and viper-mode etc. ?If so many people are reluctant > ? ?Deniz> towards the sloth, why don't we just go for the narwhal? > ? ?Deniz> They're predators, they have built-in swords and they're > ? ?Deniz> just bad ass in general. ?Then of course, there's the > ? ?Deniz> downside that there's no connection to the language itself > ? ?Deniz> in any way. > > Why not just dispense with a mascot? It's rather childish. > > New motto for Haskell: > > "Avoid mascots at all cost". Let's have a vote about the official Haskell motto! Deniz From Alistair.Bayley at invesco.com Thu Mar 12 08:00:06 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Thu Mar 12 07:48:19 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> References: <49B5AD46.2020502@gmail.com> <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025EFF@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Deniz Dogan > > Python already uses a snake and it reminds me too much of vi and > viper-mode etc. If so many people are reluctant towards the sloth, > why don't we just go for the narwhal? They're predators, they have > built-in swords and they're just bad ass in general. Then of course, > there's the downside that there's no connection to the language itself > in any way. Something wrong with the Hercules beetle, used on the cover of Real World Haskell? http://book.realworldhaskell.org/ This book is already creating an association between the Hercules beetle and Haskell, so it seems quite reasonable to continue down that path. Isn't that how Perl got its camel? 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 DekuDekuplex at Yahoo.com Thu Mar 12 08:07:16 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu Mar 12 07:55:46 2009 Subject: [Haskell-cafe] Re: Against cuteness References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> Message-ID: On Wed, 11 Mar 2009 05:17:41 -0500, Gregg Reynolds wrote: >Regarding logos/mascots: nothing personal folks, but I would like to cast a >loud firm vote against all forms of cuteness, especially small furry animal >cuteness. It's been done half to death, and we are not O'Reilly. Of all >the billions of images from all the cultures in the world available to us we >can surely find something that is witty or charming without being cute. Sorry, but I cannot agree with you. I actually moved from New York to Tokyo partly because of the cuteness culture in Japan (and lack of it in New York--everything has to be black there to be cool for some reason), and I absolutely will not stand for any mascot that isn't cute. Here, there are a lot of Japanese Haskell fans who love the beauty of Haskell, and you will risk losing a lot of them if you choose a mascot without any cuteness factor. A lot of my friends meet together every month to study category theory and Haskel in a Category Theory Study Group (see http://www.sampou.org/cgi-bin/haskell.cgi?CategoryTheory%3A%B7%F7%CF%C0%CA%D9%B6%AF%B2%F1), and we all love Haskell for its simplicity and beauty. We like to think monadically. You can still distinguish yourself from O'Reilly without losing the cuteness factor with a logo like one of the following: An aqua lambda symbol superimposed on Planet Earth, representing a Haskellian Planet Earth: http://wikicompany.org/fs/img/haskell.png a three-dimensional lambda^2 logo stand, with the same logo in a transparent green upper portion an aluminum lower portion http://home.comcast.net/~flyingsquids/BlogStuff/HL2Logo2.jpg lambda -> theta tau, represented in Greek symbols of two colors: http://qthaskell.sourceforge.net/ Different from anything on O'Reilly, potentially Haskellian in spirit, and not animal mascots, but still cute. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From briqueabraque at yahoo.com Thu Mar 12 08:16:28 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Thu Mar 12 08:04:55 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: References: <49B5AD46.2020502@gmail.com> Message-ID: >> Hehe, I love it. Sloth is a synonym for Lazyness in English >> too, and they're so freaking cute... :) > > I wouldn't say it was an exact synonym. Though the > dictionary definitions are similar, sloth has a more > negative connotation than laziness; the fourth deadly sin is > called "sloth" rather than "laziness". > 'Pregui?a', the name in Portuguese, is also the name of that deadly sin. But then I would quote Brazilian writter M?rio Quintana: "A pregui?a ? a m?e do progresso. Se o homem n?o tivesse pregui?a de caminhar, n?o teria inventado a roda." [book: Na Volta da Esquina] My translation: "Sloth is the mother of progress. If not for the sloth of walking, mankind wouldn't have invented the wheel". Best, Maur?cio From lennart at augustsson.net Thu Mar 12 08:31:53 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Mar 12 08:20:06 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: <1185843215.20090312131258@gmail.com> References: <49B5AD46.2020502@gmail.com> <1185843215.20090312131258@gmail.com> Message-ID: I thought evil dictators was covered by the Stalin Scheme implementation. (We can always discuss which is the worse name of Stalin and Bigloo.) I don't see why we need a mascot at all. We've managed so far without one. On Thu, Mar 12, 2009 at 10:12 AM, Bulat Ziganshin wrote: > Hello Satnam, > > Thursday, March 12, 2009, 1:08:58 PM, you wrote: > >> Perhaps this is just an indication of my dark and violent side, but >> choosing an animal with a killer instinct might be a better idea. A >> creature that would eat something small and furry as a mid afternoon snack > > why not choose Hitler or Mao? this will clearly indicate our > intentions :D > > -- > 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 ketil at malde.org Thu Mar 12 08:39:20 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Mar 12 08:26:56 2009 Subject: [Haskell-cafe] Re: Against cuteness In-Reply-To: (Benjamin L. Russell's message of "Thu\, 12 Mar 2009 21\:07\:16 +0900") References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> Message-ID: <87bps6q5jb.fsf@malde.org> Benjamin L.Russell writes: >>Regarding logos/mascots: nothing personal folks, but I would like to cast a >>loud firm vote against all forms of cuteness, especially small furry animal > Sorry, but I cannot agree with you. I actually moved from New York to > Tokyo partly because of the cuteness culture > Here, there are a lot of Japanese Haskell fans who love the beauty of > Haskell, and you will risk losing a lot of them if you choose a mascot > without any cuteness factor. So it seems we'll either lose the cuteness-loving Japanese, or the slick and cool New Yorkers. A solution would be to find something that is interpreted as cute in Japan, and chiq in New York - but as we don't want everybody else to leave either, we probably want to avoid anything pornographic. Tricky. > You can still distinguish yourself from O'Reilly without losing the > cuteness factor with a logo like one of the following: [...] > a three-dimensional lambda^2 logo stand, with the same logo in a > transparent green upper portion an aluminum lower portion > http://home.comcast.net/~flyingsquids/BlogStuff/HL2Logo2.jpg Hmm...perhaps this is the solution we're looking for: shiny lambda handcuffs! Obsce^H^H^H^H^HSophisticated enough for the New Yorkers, cute enough for the Japanese, and avoiding the unfortunate laziness connotations by focusing on strictness and discipline instead. This definitely gets my vote. (If I still have one.) -k -- If I haven't seen further, it is by standing in the footprints of giants From claus.reinke at talk21.com Thu Mar 12 09:40:36 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Mar 12 09:28:59 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot References: <49B5AD46.2020502@gmail.com> Message-ID: >I agree that looking for a mascot that is inspired by "laziness" is a bad idea >from a P.R. perspective (I am tired of people walking out the room when I >give Haskell talks to general audiences and explain lazy evaluation). Do they walk out when you mention it or when you explain it?-) Lazy evaluation -as an optimization of non-strict evaluation- seems like an unambiguosly good idea. Lazy evaluation -as one efficient form of non-strict evaluation- has its pros and cons: neither strict nor non-strict evaluation fit all purposes, and the real trick is to find the right middle ground. It just so happens that non-strict is a safe default from which to try and reach that middle ground. In other words, even in non-PR terms, laziness is a stepping stone, not the ultimate goal. Your remark reminded me of some old slides of mine, where I tried to offer one perspective on the problems of "communicating fp ideas to general audiences". In brief, successful communication assumes some shared background, and if that doesn't exist, communication is difficult at best and usually fails. Haskellers often resort to formal maths models, which is fine for those with a shared background, not so fine for general audiences. In that old talk I suggested using a model that general audiences, and business folks in particular, are familiar with, and started to outline an initial "dictionary of fp terms" - the translation worked well enough to show that neither strict nor non-strict evaluation make for good business models, and that we're really looking for some form of "just in time" evaluation (of course, you have to keep in mind that my understanding of business terms is only that of an average general audience;-). I've temporarily put the slides here (note that the contact info, from one of my previous lives, is years out of date): http://www.cs.kent.ac.uk/~cr3/tmp/slides.pdf Perhaps you find some of the ideas useful? And now that we actually have some more business folks amongst us, perhaps some of them would like to comment on the suitability or otherwise of these ideas?-). Claus -- Lazy evaluation: been there, done that. From dev at mobileink.com Thu Mar 12 10:04:15 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Thu Mar 12 09:52:27 2009 Subject: [Haskell-cafe] monadic logo Message-ID: <75cc17ac0903120704t17463a07q24c895aba2a0b38f@mail.gmail.com> At risk of becoming the most hated man in all Haskelldom, I'd like to suggest that the Haskell logo not use lambda symbols. Or at least not as the central element. Sorry, I know I'm late to the party, but the thing is there is nothing distinctive about lambda; it's common to all FPLs. Besides, Lisp/Scheme already have that franchise. What is distinctive about Haskell it's use of the monad. The Pythagorean monad symbol is wonderfully simple: http://en.wikipedia.org/wiki/Monad_(Greek_philosophy). Something might also be done with the triad to reflect the fact that the monad in cat theory is actually a triple ( http://en.wikipedia.org/wiki/Triad_(Greek_philosophy) ). The "Cup or Monad" (http://www.sacred-texts.com/chr/herm/hermes4.htm), with a little bit of work, could be turned into an amusing Haskell manifesto. Lots of interesting imagery from the gnostic tradition ( http://www.sacred-texts.com/gno/th2/index.htm), although SICP seems already to have used something similar ( http://mitpress.mit.edu/images/products/books/0262011530-f30.jpg). Hermes Trismegistus = Thrice-great Hermes -> Haskell Trismegistus, Thrice-Glorious Haskell, etc. Might be too cute. There's also Leibniz' monadology - I can't think of any visual imagery to go with it, but he did end up with the "best of all possible worlds" hypothesis, which gives us a slogan sure to irritate: "Haskell - the best of all possible languages". Not to mention "Haskell Monadology" as a name for the official Haskell definition, etc. Hey, at least it isn't cute. -gregg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/dd458de7/attachment.htm From dev at mobileink.com Thu Mar 12 10:11:15 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Thu Mar 12 09:59:27 2009 Subject: [Haskell-cafe] Re: Against cuteness In-Reply-To: References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> Message-ID: <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> On Thu, Mar 12, 2009 at 7:07 AM, Benjamin L. Russell wrote: > > Here, there are a lot of Japanese Haskell fans who love the beauty of > Haskell, and you will risk losing a lot of them if you choose a mascot > without any cuteness factor. ?A lot of my friends meet together every I don't think so. Bad design will lose them (and many others), but good design and cuteness are two different things. > > You can still distinguish yourself from O'Reilly without losing the > cuteness factor with a logo like one of the following: > We must have vastly different ideas of cute. I don't consider those examples cute. How about this as a criterion: if it makes 13-year old Japanese girls squeal "kawaiiii!" then it's too cute. Also if it involves the color pink. -g From conal at conal.net Thu Mar 12 10:12:21 2009 From: conal at conal.net (Conal Elliott) Date: Thu Mar 12 10:00:34 2009 Subject: [Haskell-cafe] Request: warn about language extensions that are not used In-Reply-To: References: <814617240903110916w6b500a51n7bed0e669779fab4@mail.gmail.com> Message-ID: Thanks Peter. I'd love to have this feature also. I go back every so often and try removing each of the extensions listed in my LANGUAGE pragma. Didn't occur to me that the compiler could be doing it for me. Regards, - Conal 2009/3/11 Peter Verswyvelen > Okay, I submitted it as a GHC feature request. Thanks for the feedback. > On Wed, Mar 11, 2009 at 5:16 PM, Creighton Hogg wrote: > >> 2009/3/11 Peter Verswyvelen : >> > When I put >> > {-# OPTIONS_GHC -Wall -Werror #-} >> > in my source file, I don't get compiler (GHC) warnings about redundant >> > language extensions that I enabled. >> > It would be nice if the compiler gave warnings about this, since after >> > refactoring, some language extensions might not be needed anymore, and >> hence >> > should be removed since fewer language extensions mean more stable and >> > portable code no? >> > What do you think? >> >> So you mean something like if you put {-# LANGUAGE >> GeneralizedNewtypeDeriving #-} in a file, but never do newtype >> deriving, it would warn you? >> >> I have no idea how hard that'd be to implement, but that sounds kind >> of cool. Useful for both refactoring and when you've inherited old >> code. >> >> Cheers, >> C >> > > > _______________________________________________ > 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/20090312/4addebd3/attachment.htm From tom.davie at gmail.com Thu Mar 12 10:13:58 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Mar 12 10:02:13 2009 Subject: [Haskell-cafe] monadic logo In-Reply-To: <75cc17ac0903120704t17463a07q24c895aba2a0b38f@mail.gmail.com> References: <75cc17ac0903120704t17463a07q24c895aba2a0b38f@mail.gmail.com> Message-ID: <5473394C-F322-4D22-B16C-00AC496F8ABA@gmail.com> On 12 Mar 2009, at 15:04, Gregg Reynolds wrote: > At risk of becoming the most hated man in all Haskelldom, I'd like > to suggest that the Haskell logo not use lambda symbols. Or at > least not as the central element. Sorry, I know I'm late to the > party, but the thing is there is nothing distinctive about lambda; > it's common to all FPLs. Besides, Lisp/Scheme already have that > franchise. > > What is distinctive about Haskell it's use of the monad. The > Pythagorean monad symbol is wonderfully simple: No, what's distinctive about Haskell is usually the abuse of the monad. Encouraging people to think Haskell is all about monadic programming even more is a recipe for disaster. Just my 2? Bob From wagner.andrew at gmail.com Thu Mar 12 10:16:23 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Thu Mar 12 10:04:37 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] Message-ID: Can you expand on this a bit? I'm curious why you think this. On Thu, Mar 12, 2009 at 10:13 AM, Thomas Davie wrote: > > On 12 Mar 2009, at 15:04, Gregg Reynolds wrote: > > At risk of becoming the most hated man in all Haskelldom, I'd like to >> suggest that the Haskell logo not use lambda symbols. Or at least not as >> the central element. Sorry, I know I'm late to the party, but the thing is >> there is nothing distinctive about lambda; it's common to all FPLs. >> Besides, Lisp/Scheme already have that franchise. >> >> What is distinctive about Haskell it's use of the monad. The Pythagorean >> monad symbol is wonderfully simple: >> > No, what's distinctive about Haskell is usually the abuse of the monad. > > Encouraging people to think Haskell is all about monadic programming even > more is a recipe for disaster. > > Just my 2? > > Bob_______________________________________________ > > 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/20090312/7df7f3df/attachment.htm From bugfact at gmail.com Thu Mar 12 10:27:18 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Mar 12 10:15:31 2009 Subject: [Haskell-cafe] Request: warn about language extensions that are not used In-Reply-To: References: <814617240903110916w6b500a51n7bed0e669779fab4@mail.gmail.com> Message-ID: Thanks Conal. For people interested, here's the ticket. http://hackage.haskell.org/trac/ghc/ticket/3085 Martijn Van Steenbergen indirectly revealed a feature request to the feature request feature of the feature database :-) Okay, I'll stop the nonsense: it would be nice if the community could rate the popularity of a feature request, which Martijn now just did by adding a comment. On Thu, Mar 12, 2009 at 3:12 PM, Conal Elliott wrote: > Thanks Peter. I'd love to have this feature also. I go back every so > often and try removing each of the extensions listed in my LANGUAGE pragma. > Didn't occur to me that the compiler could be doing it for me. Regards, - > Conal > > 2009/3/11 Peter Verswyvelen > >> Okay, I submitted it as a GHC feature request. Thanks for the feedback. >> On Wed, Mar 11, 2009 at 5:16 PM, Creighton Hogg wrote: >> >>> 2009/3/11 Peter Verswyvelen : >>> > When I put >>> > {-# OPTIONS_GHC -Wall -Werror #-} >>> > in my source file, I don't get compiler (GHC) warnings about redundant >>> > language extensions that I enabled. >>> > It would be nice if the compiler gave warnings about this, since after >>> > refactoring, some language extensions might not be needed anymore, and >>> hence >>> > should be removed since fewer language extensions mean more stable and >>> > portable code no? >>> > What do you think? >>> >>> So you mean something like if you put {-# LANGUAGE >>> GeneralizedNewtypeDeriving #-} in a file, but never do newtype >>> deriving, it would warn you? >>> >>> I have no idea how hard that'd be to implement, but that sounds kind >>> of cool. Useful for both refactoring and when you've inherited old >>> code. >>> >>> Cheers, >>> C >>> >> >> >> _______________________________________________ >> 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/20090312/41149172/attachment.htm From tom.davie at gmail.com Thu Mar 12 10:28:04 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Mar 12 10:16:18 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: References: Message-ID: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> On 12 Mar 2009, at 15:16, Andrew Wagner wrote: > Can you expand on this a bit? I'm curious why you think this. For two reasons: Firstly, I often find that people use the Monadic interface when one of the less powerful ones is both powerful enough and more convenient, parsec is a wonderful example of this. When the applicative instance is used instead of the monadic one, programs rapidly become more readable, because they stop describing the order in which things should be parsed, and start describing the grammar of the language being parsed instead. Secondly, It seems relatively common now for beginners to be told about the IO monad, and start writing imperative code in it, and thinking that this is what Haskell programming is. I have no problem with people writing imperative code in Haskell, it's an excellent imperative language. However, beginners seeing this, and picking it up is usually counter productive ? they never learn how to write things in a functional way, and miss out on most of the benefits of doing so. Hope that clarifies what I meant :) Bob From ganesh.sittampalam at credit-suisse.com Thu Mar 12 10:29:05 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Thu Mar 12 10:18:27 2009 Subject: [Haskell-cafe] Request: warn about language extensions that are not used In-Reply-To: References: <814617240903110916w6b500a51n7bed0e669779fab4@mail.gmail.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABA904@ELON17P32001A.csfb.cs-group.com> As I understand it the current scheme is that you vote for a bug by adding yourself to the CC list. ________________________________ From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Peter Verswyvelen Sent: 12 March 2009 14:27 To: Conal Elliott Cc: haskell mailing list Subject: Re: [Haskell-cafe] Request: warn about language extensions that are not used Thanks Conal. For people interested, here's the ticket. http://hackage.haskell.org/trac/ghc/ticket/3085 Martijn Van Steenbergen indirectly revealed a feature request to the feature request feature of the feature database :-) Okay, I'll stop the nonsense: it would be nice if the community could rate the popularity of a feature request, which Martijn now just did by adding a comment. On Thu, Mar 12, 2009 at 3:12 PM, Conal Elliott wrote: Thanks Peter. I'd love to have this feature also. I go back every so often and try removing each of the extensions listed in my LANGUAGE pragma. Didn't occur to me that the compiler could be doing it for me. Regards, - Conal 2009/3/11 Peter Verswyvelen Okay, I submitted it as a GHC feature request. Thanks for the feedback. On Wed, Mar 11, 2009 at 5:16 PM, Creighton Hogg wrote: 2009/3/11 Peter Verswyvelen : > When I put > {-# OPTIONS_GHC -Wall -Werror #-} > in my source file, I don't get compiler (GHC) warnings about redundant > language extensions that I enabled. > It would be nice if the compiler gave warnings about this, since after > refactoring, some language extensions might not be needed anymore, and hence > should be removed since fewer language extensions mean more stable and > portable code no? > What do you think? So you mean something like if you put {-# LANGUAGE GeneralizedNewtypeDeriving #-} in a file, but never do newtype deriving, it would warn you? I have no idea how hard that'd be to implement, but that sounds kind of cool. Useful for both refactoring and when you've inherited old code. Cheers, C _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/c66d459f/attachment.htm From colin at colina.demon.co.uk Thu Mar 12 10:33:43 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Mar 12 10:22:00 2009 Subject: [Haskell-cafe] Abuse of the monad In-Reply-To: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> (Thomas Davie's message of "Thu\, 12 Mar 2009 15\:28\:04 +0100") References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> Message-ID: >>>>> "Thomas" == Thomas Davie writes: Thomas> On 12 Mar 2009, at 15:16, Andrew Wagner wrote: > Can you expand on this a bit? I'm curious why you think this. Thomas> For two reasons: Thomas> Firstly, I often find that people use the Monadic Thomas> interface when one of the less powerful ones is both Thomas> powerful enough and more convenient, parsec is a wonderful Thomas> example of this. When the applicative instance is used Thomas> instead of the monadic one, programs rapidly become more Thomas> readable, because they stop describing the order in which Thomas> things should be parsed, and start describing the grammar Thomas> of the language being parsed instead. That's interesting. I recently used parsec 3. I wrote using the monadic interface because I could understand (just about) how to do so. I was looking at the examples in RWH, and I could follow the explanation of the monadic interface much easier. Perhaps this was because RWH shows how to write using the monadic interface, and then shows how to convert this to the applicative interface. It's hard to follow a tutorial that shows you how to convert from something you aren't starting with. -- Colin Adams Preston Lancashire From martin.hofmann at uni-bamberg.de Thu Mar 12 10:37:54 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Thu Mar 12 10:25:41 2009 Subject: [Haskell-cafe] Dynamically typing TH.Exp at runtime In-Reply-To: <20090312100136.F145C32490C@www.haskell.org> References: <20090312100136.F145C32490C@www.haskell.org> Message-ID: <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> I am doing meta-programming at runtime. So my program gets a full Haskell declaration in expression quotation ([d|...|]) modifies it and returns the modified expression. Therefore, I need type information of this expression, and any subexpression, at _runtime_ ! For example: [d| reverse x1 = y1 |] - rewrites_to -> [d| reverse x2:xs = y2:ys |] - rewrites_to -> [d| reverse x:xs = reverse xs ++ [x] |] reverse :: [a] -> [a] implies x2,y2 :: a x1,y1,xs,ys :: [a] TH.reify is not applicable, because I need the information at runtime and I am in IO. I suppose Data.Dynamic does not work either, because [| xs|] :: ExpQ and not [a]. So it looks like I need my own type checker and inference and tag each subexpression with its type. If so, I can even omit TH and use my own data type for the abstract syntax tree. This annoys me a bit, because for me it seems that all I need is already there. Did anybody have similar problems, because I shouldn't be the only one doing dynamic typing in a static language? Is there a Haskell implementation of the paper "Typing Dynamic Typing" by Baars and Swierstra (http://people.cs.uu.nl/arthurb/dynamic.html ), so I can try out if this helps me? Any help, comments, and how-to-suggestions are highly welcome. Thanks a lot, Martin From tom.davie at gmail.com Thu Mar 12 10:37:40 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Mar 12 10:25:57 2009 Subject: [Haskell-cafe] Abuse of the monad In-Reply-To: References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> Message-ID: On 12 Mar 2009, at 15:33, Colin Paul Adams wrote: >>>>>> "Thomas" == Thomas Davie writes: > > Thomas> On 12 Mar 2009, at 15:16, Andrew Wagner wrote: > >> Can you expand on this a bit? I'm curious why you think this. > > Thomas> For two reasons: > > Thomas> Firstly, I often find that people use the Monadic > Thomas> interface when one of the less powerful ones is both > Thomas> powerful enough and more convenient, parsec is a wonderful > Thomas> example of this. When the applicative instance is used > Thomas> instead of the monadic one, programs rapidly become more > Thomas> readable, because they stop describing the order in which > Thomas> things should be parsed, and start describing the grammar > Thomas> of the language being parsed instead. > > That's interesting. > > I recently used parsec 3. I wrote using the monadic interface because > I could understand (just about) how to do so. I was looking at the > examples in RWH, and I could follow the explanation of the monadic > interface much easier. > Perhaps this was because RWH shows how to write using the monadic > interface, and then shows how to convert this to the applicative > interface. > It's hard to follow a tutorial that shows you how to convert from > something you aren't starting with. I suspect that this is an interesting corner case of both my two reasons ? firstly, Monads are too powerful here, and secondly, you perhaps found it easier to think about the operational aspects of the parser than to think about the denotation of what the parser should parse. Is that somewhere accurate? Bob From marlowsd at gmail.com Thu Mar 12 10:42:42 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Mar 12 10:31:01 2009 Subject: [Haskell-cafe] ThreadScope: Request for features for the performance tuning of parallel and concurrent Haskell programs In-Reply-To: <2E753E6C-E53E-4972-9A23-681B4A61A278@anu.edu.au> References: <2E753E6C-E53E-4972-9A23-681B4A61A278@anu.edu.au> Message-ID: <49B91F62.8030706@gmail.com> Ben Lippmeier wrote: > > On 12/03/2009, at 12:24 AM, Satnam Singh wrote: >> Before making the release I thought it would be an idea to ask people >> what other features people would find useful or performance tuning. So >> if you have any suggestions please do let us know! >> > > Is it available in a branch somewhere to try out? There are three parts to it: - some patches to GHC to generate the log files. The patches are not yet in, but I hope to get them in in the next couple of weeks. - a Haskell library for parsing the log files. This will be up on Hackage soon. You can use this to write your own analysis tools, visualisers, or whatever. - The ThreadScope viewer itself, which will also be up on Hackage as soon as its ready. So we fully intend to get this out there ASAP, although until GHC 6.12 is released you will need to use a GHC snapshot to generate the log files. Cheers, Simon From colin at colina.demon.co.uk Thu Mar 12 10:44:31 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Mar 12 10:32:50 2009 Subject: [Haskell-cafe] Abuse of the monad In-Reply-To: (Thomas Davie's message of "Thu\, 12 Mar 2009 15\:37\:40 +0100") References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> Message-ID: > That's interesting. > > I recently used parsec 3. I wrote using the monadic interface because > I could understand (just about) how to do so. I was looking at the > examples in RWH, and I could follow the explanation of the monadic > interface much easier. > Perhaps this was because RWH shows how to write using the monadic > interface, and then shows how to convert this to the applicative > interface. > It's hard to follow a tutorial that shows you how to convert from > something you aren't starting with. >>I suspect that this is an interesting corner case of both my two >>reasons ? firstly, Monads are too powerful here, and secondly, you >>perhaps found it easier to think about the operational aspects of the >>parser than to think about the denotation of what the parser should >>parse. >>Is that somewhere accurate? I don't know. -- Colin Adams Preston Lancashire From wagner.andrew at gmail.com Thu Mar 12 10:46:51 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Thu Mar 12 10:35:05 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> Message-ID: Hmm, perhaps what we need is another monad tutorial that.....err...never mind. Actually, I'd like to see more written about Applicatives. I think they just finally clicked with me when reading the Typeclassopedia, and seeing the intended way to use them. Before it was always like "ok...so, if I've got a function already in my functor, I could use this, but...why would I have that?" On Thu, Mar 12, 2009 at 10:28 AM, Thomas Davie wrote: > > On 12 Mar 2009, at 15:16, Andrew Wagner wrote: > > Can you expand on this a bit? I'm curious why you think this. >> > > For two reasons: > > Firstly, I often find that people use the Monadic interface when one of the > less powerful ones is both powerful enough and more convenient, parsec is a > wonderful example of this. When the applicative instance is used instead of > the monadic one, programs rapidly become more readable, because they stop > describing the order in which things should be parsed, and start describing > the grammar of the language being parsed instead. > > Secondly, It seems relatively common now for beginners to be told about the > IO monad, and start writing imperative code in it, and thinking that this is > what Haskell programming is. I have no problem with people writing > imperative code in Haskell, it's an excellent imperative language. However, > beginners seeing this, and picking it up is usually counter productive ? > they never learn how to write things in a functional way, and miss out on > most of the benefits of doing so. > > Hope that clarifies what I meant :) > > Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/3f1e63db/attachment.htm From jefferson.r.heard at gmail.com Thu Mar 12 10:51:03 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Mar 12 10:39:16 2009 Subject: [Haskell-cafe] Haxr doesn't compile from cabal (HTTP > 4000 breaks it) Message-ID: <4165d3a70903120751t35cd2c13ub70d236800d9caca@mail.gmail.com> The haxr cabal library dependencies seem to be off. I wonder, since haxr would benefit highly from the HTTP 4k series of performance improvements, is it trivial to make it compatible with the latest library? -- Jeff From conal at conal.net Thu Mar 12 11:25:10 2009 From: conal at conal.net (Conal Elliott) Date: Thu Mar 12 11:13:22 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> Message-ID: Thank you Bob! I'll throw in another 2 cents: Yes, *one* aspect of Haskell is that it's a power tool for imperative programming -- a clever way to keep plugging away at the old sequential von Neumann paradigm. C++++. I'd rather we strongly encourage Haskell-newbies toward shifting out of the imperative paradigm to thinking and programming *functionally*. It's a big shift, to make, and imperative-Haskell is a relatively easy substitute. - Conal On Thu, Mar 12, 2009 at 7:28 AM, Thomas Davie wrote: > > On 12 Mar 2009, at 15:16, Andrew Wagner wrote: > > Can you expand on this a bit? I'm curious why you think this. >> > > For two reasons: > > Firstly, I often find that people use the Monadic interface when one of the > less powerful ones is both powerful enough and more convenient, parsec is a > wonderful example of this. When the applicative instance is used instead of > the monadic one, programs rapidly become more readable, because they stop > describing the order in which things should be parsed, and start describing > the grammar of the language being parsed instead. > > Secondly, It seems relatively common now for beginners to be told about the > IO monad, and start writing imperative code in it, and thinking that this is > what Haskell programming is. I have no problem with people writing > imperative code in Haskell, it's an excellent imperative language. However, > beginners seeing this, and picking it up is usually counter productive ? > they never learn how to write things in a functional way, and miss out on > most of the benefits of doing so. > > Hope that clarifies what I meant :) > > > Bob_______________________________________________ > 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/20090312/10488bc5/attachment.htm From wagner.andrew at gmail.com Thu Mar 12 11:29:01 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Thu Mar 12 11:17:13 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> Message-ID: Conal,Do you think imperative Haskell can be a sort of "gateway drug" to "real" haskell? On Thu, Mar 12, 2009 at 11:25 AM, Conal Elliott wrote: > Thank you Bob! I'll throw in another 2 cents: > > Yes, *one* aspect of Haskell is that it's a power tool for imperative > programming -- a clever way to keep plugging away at the old sequential von > Neumann paradigm. C++++. > > I'd rather we strongly encourage Haskell-newbies toward shifting out of the > imperative paradigm to thinking and programming *functionally*. It's a big > shift, to make, and imperative-Haskell is a relatively easy substitute. > > - Conal > > On Thu, Mar 12, 2009 at 7:28 AM, Thomas Davie wrote: > >> >> On 12 Mar 2009, at 15:16, Andrew Wagner wrote: >> >> Can you expand on this a bit? I'm curious why you think this. >>> >> >> For two reasons: >> >> Firstly, I often find that people use the Monadic interface when one of >> the less powerful ones is both powerful enough and more convenient, parsec >> is a wonderful example of this. When the applicative instance is used >> instead of the monadic one, programs rapidly become more readable, because >> they stop describing the order in which things should be parsed, and start >> describing the grammar of the language being parsed instead. >> >> Secondly, It seems relatively common now for beginners to be told about >> the IO monad, and start writing imperative code in it, and thinking that >> this is what Haskell programming is. I have no problem with people writing >> imperative code in Haskell, it's an excellent imperative language. However, >> beginners seeing this, and picking it up is usually counter productive ? >> they never learn how to write things in a functional way, and miss out on >> most of the benefits of doing so. >> >> Hope that clarifies what I meant :) >> >> >> Bob_______________________________________________ >> 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/20090312/f29ea2f4/attachment.htm From jefferson.r.heard at gmail.com Thu Mar 12 11:29:26 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Mar 12 11:17:37 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> Message-ID: <4165d3a70903120829j3bc0d432l95fc3bd8ca1ab08@mail.gmail.com> Come to think of it, I've never seen an applicative tutorial of Parsec, only a monadic one. Does such a beast exist, and if so, maybe we could merge the two together, work the same example in both, and thus help the programmer make the shift from monadic to applicative, from order of parsing to describing the grammar. -- Jeff 2009/3/12 Conal Elliott : > Thank you Bob!? I'll throw in another 2 cents: > > Yes, *one* aspect of Haskell is that it's a power tool for imperative > programming -- a clever way to keep plugging away at the old sequential von > Neumann paradigm.? C++++. > > I'd rather we strongly encourage Haskell-newbies toward shifting out of the > imperative paradigm to thinking and programming *functionally*.? It's a big > shift, to make, and imperative-Haskell is a relatively easy substitute. > > ?? - Conal > > On Thu, Mar 12, 2009 at 7:28 AM, Thomas Davie wrote: >> >> On 12 Mar 2009, at 15:16, Andrew Wagner wrote: >> >>> Can you expand on this a bit? I'm curious why you think this. >> >> For two reasons: >> >> Firstly, I often find that people use the Monadic interface when one of >> the less powerful ones is both powerful enough and more convenient, parsec >> is a wonderful example of this. ?When the applicative instance is used >> instead of the monadic one, programs rapidly become more readable, because >> they stop describing the order in which things should be parsed, and start >> describing the grammar of the language being parsed instead. >> >> Secondly, It seems relatively common now for beginners to be told about >> the IO monad, and start writing imperative code in it, and thinking that >> this is what Haskell programming is. ?I have no problem with people writing >> imperative code in Haskell, it's an excellent imperative language. ?However, >> beginners seeing this, and picking it up is usually counter productive ? >> they never learn how to write things in a functional way, and miss out on >> most of the benefits of doing so. >> >> Hope that clarifies what I meant :) >> >> Bob_______________________________________________ >> 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 martijn at van.steenbergen.nl Thu Mar 12 11:36:39 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Mar 12 11:24:52 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: <4165d3a70903120829j3bc0d432l95fc3bd8ca1ab08@mail.gmail.com> References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> <4165d3a70903120829j3bc0d432l95fc3bd8ca1ab08@mail.gmail.com> Message-ID: <49B92C07.60805@van.steenbergen.nl> Jeff Heard wrote: > Come to think of it, I've never seen an applicative tutorial of > Parsec, only a monadic one. Does such a beast exist Here's something that comes close: http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-044.pdf It's not specific to Parsec; instead, a parser type is defined on the fly, based on Philip Wadler's list of successes. The applicative and monadic approaches are clearly separated. Martijn. From wagner.andrew at gmail.com Thu Mar 12 11:36:46 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Thu Mar 12 11:25:06 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: <4165d3a70903120829j3bc0d432l95fc3bd8ca1ab08@mail.gmail.com> References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> <4165d3a70903120829j3bc0d432l95fc3bd8ca1ab08@mail.gmail.com> Message-ID: I was thinking the same thing. If I remember correctly, RWH does a parser in an applicative style, but I'll have to look when I get home to be sure. If so, then maybe we could try doing the same thing in a monadic style, for comparison and contrast purposes. On Thu, Mar 12, 2009 at 11:29 AM, Jeff Heard wrote: > Come to think of it, I've never seen an applicative tutorial of > Parsec, only a monadic one. Does such a beast exist, and if so, maybe > we could merge the two together, work the same example in both, and > thus help the programmer make the shift from monadic to applicative, > from order of parsing to describing the grammar. > > -- Jeff > > 2009/3/12 Conal Elliott : > > Thank you Bob! I'll throw in another 2 cents: > > > > Yes, *one* aspect of Haskell is that it's a power tool for imperative > > programming -- a clever way to keep plugging away at the old sequential > von > > Neumann paradigm. C++++. > > > > I'd rather we strongly encourage Haskell-newbies toward shifting out of > the > > imperative paradigm to thinking and programming *functionally*. It's a > big > > shift, to make, and imperative-Haskell is a relatively easy substitute. > > > > - Conal > > > > On Thu, Mar 12, 2009 at 7:28 AM, Thomas Davie > wrote: > >> > >> On 12 Mar 2009, at 15:16, Andrew Wagner wrote: > >> > >>> Can you expand on this a bit? I'm curious why you think this. > >> > >> For two reasons: > >> > >> Firstly, I often find that people use the Monadic interface when one of > >> the less powerful ones is both powerful enough and more convenient, > parsec > >> is a wonderful example of this. When the applicative instance is used > >> instead of the monadic one, programs rapidly become more readable, > because > >> they stop describing the order in which things should be parsed, and > start > >> describing the grammar of the language being parsed instead. > >> > >> Secondly, It seems relatively common now for beginners to be told about > >> the IO monad, and start writing imperative code in it, and thinking that > >> this is what Haskell programming is. I have no problem with people > writing > >> imperative code in Haskell, it's an excellent imperative language. > However, > >> beginners seeing this, and picking it up is usually counter productive ? > >> they never learn how to write things in a functional way, and miss out > on > >> most of the benefits of doing so. > >> > >> Hope that clarifies what I meant :) > >> > >> Bob_______________________________________________ > >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/56f02721/attachment.htm From jefferson.r.heard at gmail.com Thu Mar 12 11:49:13 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Mar 12 11:37:25 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: <49B92C07.60805@van.steenbergen.nl> References: <3B8B3457-C0DE-4D17-BF60-B43EB8EF4371@gmail.com> <4165d3a70903120829j3bc0d432l95fc3bd8ca1ab08@mail.gmail.com> <49B92C07.60805@van.steenbergen.nl> Message-ID: <4165d3a70903120849s4743810ek10f3fac946907211@mail.gmail.com> Oh, I know it's not specific to parsec, it just seems like parsec's used enough and well understood enough that it would make a good tutorial. On Thu, Mar 12, 2009 at 11:36 AM, Martijn van Steenbergen wrote: > Jeff Heard wrote: >> >> Come to think of it, I've never seen an applicative tutorial of >> Parsec, only a monadic one. ?Does such a beast exist > > Here's something that comes close: > > http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-044.pdf > > It's not specific to Parsec; instead, a parser type is defined on the fly, > based on Philip Wadler's list of successes. The applicative and monadic > approaches are clearly separated. > > Martijn. > > From anton at appsolutions.com Thu Mar 12 12:25:25 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Thu Mar 12 12:13:43 2009 Subject: [Haskell-cafe] monadic logo In-Reply-To: <75cc17ac0903120704t17463a07q24c895aba2a0b38f@mail.gmail.com> References: <75cc17ac0903120704t17463a07q24c895aba2a0b38f@mail.gmail.com> Message-ID: <49B93775.8000404@appsolutions.com> Gregg Reynolds wrote: > What is distinctive about Haskell it's use of the monad. The > The Pythagorean monad symbol is wonderfully simple: > > http://en.wikipedia.org/wiki/Monad_(Greek_philosophy) It has the added benefit that if you put a pair of those on the chest of a suitably curvy cartoon character, you've got yourself one sexy mascot. > Hey, at least it isn't cute. De gustibus non est disputandum! From lemming at henning-thielemann.de Thu Mar 12 12:31:49 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Mar 12 12:20:07 2009 Subject: [Haskell-cafe] Haskell-Wiki Account registration Message-ID: How long will the Wiki account registration be disabled? Would it be possible to ask a question, that real Haskellers could easily answer, but a spambot cannot? E.g. "What's Haskell's surname?" From haskell at datakids.org Thu Mar 12 12:38:37 2009 From: haskell at datakids.org (Jamie) Date: Thu Mar 12 12:26:50 2009 Subject: [Haskell-cafe] "The Curse of Our Times" in different languages Message-ID: See Black-Scholes model/option formula being implemented in different languages including Haskell. http://www.espenhaug.com/black_scholes.html Jamie From dons at galois.com Thu Mar 12 12:37:46 2009 From: dons at galois.com (Don Stewart) Date: Thu Mar 12 12:27:09 2009 Subject: [Haskell-cafe] ThreadScope: Request for features for the performance tuning of parallel and concurrent Haskell programs In-Reply-To: <49B91F62.8030706@gmail.com> References: <2E753E6C-E53E-4972-9A23-681B4A61A278@anu.edu.au> <49B91F62.8030706@gmail.com> Message-ID: <20090312163746.GB10693@whirlpool.galois.com> marlowsd: > Ben Lippmeier wrote: > >> >> On 12/03/2009, at 12:24 AM, Satnam Singh wrote: >>> Before making the release I thought it would be an idea to ask people >>> what other features people would find useful or performance tuning. >>> So if you have any suggestions please do let us know! >>> >> >> Is it available in a branch somewhere to try out? > > There are three parts to it: > > - some patches to GHC to generate the log files. The patches are > not yet in, but I hope to get them in in the next couple of weeks. Just as a meta-point, it makes a *lot* of sense for the runtime to support proper logging -- it's practically a microkernel after all, so logging makes as much sense for GHC's rts as it does for regular kernels. Now we just need a /proc for the rts, so I can peek at GC stats live. > - a Haskell library for parsing the log files. This will be up > on Hackage soon. You can use this to write your own analysis > tools, visualisers, or whatever. > > - The ThreadScope viewer itself, which will also be up on Hackage > as soon as its ready. > > So we fully intend to get this out there ASAP, although until GHC 6.12 is > released you will need to use a GHC snapshot to generate the log files. Sweet. This should have many many applications for work projects ... "attach a viewer to a remote Haskell server to see what's it's up to"... "heartbeat monitoring of the rts" ... -- Don From dons at galois.com Thu Mar 12 12:41:32 2009 From: dons at galois.com (Don Stewart) Date: Thu Mar 12 12:30:38 2009 Subject: [Haskell-cafe] Re: Data.Binary patches? In-Reply-To: <6dbd4d000903112000h674c6c48p279e41188716036a@mail.gmail.com> References: <6dbd4d000903111954j11ff4931n2053aeb08b80c47b@mail.gmail.com> <6dbd4d000903112000h674c6c48p279e41188716036a@mail.gmail.com> Message-ID: <20090312164132.GC10693@whirlpool.galois.com> Send it to the maintainer... Explain what the patch is for, and why it should be applied. dbueno: > On Wed, Mar 11, 2009 at 20:54, Denis Bueno wrote: > > I've got a small patch for Data.Binary. ?Should I post it here, or is > > there some more appropriate forum? > > In case whoever reads this is a Data.Binary maintainer, the patch is > now attached, to save you some work. > > The .patch file is the output of darcs send -a --output=. > > Denis > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From martin.hofmann at uni-bamberg.de Thu Mar 12 12:47:26 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Thu Mar 12 12:35:19 2009 Subject: [Haskell-cafe] Dynamically typing TH.Exp at runtime In-Reply-To: References: <20090312100136.F145C32490C@www.haskell.org> <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <1236876446.6867.132.camel@ios.cogsys.wiai.uni-bamberg.de> This is what hint does, isn't it? However, this still leaves it to me to infer what type [|a|] in [| reverse (a:b:[]) = (b:a:[]) |] is. Thanks a lot anyway. Martin On Thu, 2009-03-12 at 12:59 -0200, Daniel Gor?n wrote: > would using ghc-as-a-library to type (strings with) haskell > expressions at runtime help? > > On Mar 12, 2009, at 12:37 PM, Martin Hofmann wrote: > > > I am doing meta-programming at runtime. So my program gets a full > > Haskell declaration in expression quotation ([d|...|]) modifies it and > > returns the modified expression. Therefore, I need type information of > > this expression, and any subexpression, at _runtime_ ! For example: > > > > [d| reverse x1 = y1 |] > > > > - rewrites_to -> > > > > [d| reverse x2:xs = y2:ys |] > > > > - rewrites_to -> > > > > [d| reverse x:xs = reverse xs ++ [x] |] > > > > reverse :: [a] -> [a] implies > > x2,y2 :: a > > x1,y1,xs,ys :: [a] > > > > TH.reify is not applicable, because I need the information at runtime > > and I am in IO. I suppose Data.Dynamic does not work either, because > > [| > > xs|] :: ExpQ and not [a]. > > > > So it looks like I need my own type checker and inference and tag each > > subexpression with its type. If so, I can even omit TH and use my own > > data type for the abstract syntax tree. This annoys me a bit, because > > for me it seems that all I need is already there. > > > > Did anybody have similar problems, because I shouldn't be the only one > > doing dynamic typing in a static language? Is there a Haskell > > implementation of the paper "Typing Dynamic Typing" by Baars and > > Swierstra (http://people.cs.uu.nl/arthurb/dynamic.html ), so I can try > > out if this helps me? > > > > Any help, comments, and how-to-suggestions are highly welcome. > > > > Thanks a lot, > > > > Martin > > > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe From rj248842 at hotmail.com Thu Mar 12 13:01:02 2009 From: rj248842 at hotmail.com (R J) Date: Thu Mar 12 12:49:17 2009 Subject: [Haskell-cafe] Hand calculation of Bird's definition of zip using foldr Message-ID: Can someone provide a complete hand calculation of zip [1,2,3] [4,5,6] using the following definition of zip, based on foldr: zip :: [a] -> [b] -> [(a, b)] zip = foldr f e where e ys = [] f x g [ ] = [] f x g (y : ys) = (x , y) : g ys foldr :: (a -> b -> b) -> b -> ([a] -> b) foldr _ e [] = e foldr f e (x : xs) = f x (foldr f e xs) This implementation of zip produces the expected result [(1, 4), (2, 5), (3, 6)], but I'm unable to do the hand calculation and don't understand why it works. Part of my problem is that "e" is defined as a function that takes one argument, I don't see how that fits in with the usual scheme for foldr, which, as I understand it, is: foldr f e [x1, x2, ...] = f x1 (f x2 (f x3 ...(f xn e)))... Thanks, as always, to all in this great community. _________________________________________________________________ Windows Live?: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/9b0c6eea/attachment.htm From miguelimo38 at yandex.ru Thu Mar 12 13:34:41 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Mar 12 13:23:05 2009 Subject: [Haskell-cafe] Hand calculation of Bird's definition of zip using foldr In-Reply-To: References: Message-ID: <18EF45D1-F2DA-4D5A-841A-B27459DD3F02@yandex.ru> zip [1,2,3] [4,5,6] = zip (1:2:3:[]) (4:5:6:[]) = foldr f e (1:2:3:[]) (4:5:6:[]) = f 1 (foldr f e (2:3:[])) (4:5:6:[]) = (1, 4) : foldr f e (2:3:[]) (5:6:[]) = (1, 4) : f 2 (foldr f e (3:[])) (5:6:[]) = (1, 4) : (2, 5) : foldr f e (3:[]) (6:[]) = (1, 4) : (2, 5) : f 3 (foldr f e []) (6:[]) = (1, 4) : (2, 5) : (3, 6) : foldr f e [] [] = (1, 4) : (2, 5) : (3, 6) : e [] = (1, 4) : (2, 5) : (3, 6) : [] = [(1, 4), (2, 5), (3, 6)] On 12 Mar 2009, at 20:01, R J wrote: > Can someone provide a complete hand calculation of zip [1,2,3] > [4,5,6] using the following definition of zip, based on foldr: > > zip :: [a] -> [b] -> [(a, b)] > zip = foldr f e > where > e ys = [] > f x g [ ] = [] > f x g (y : ys) = (x , y) : g ys > > > foldr :: (a -> b -> b) -> b -> ([a] -> b) > foldr _ e [] = e > foldr f e (x : xs) = f x (foldr f e xs) > > > This implementation of zip produces the expected result [(1, 4), (2, > 5), (3, 6)], but I'm unable to do the hand calculation and don't > understand why it works. Part of my problem is that "e" is defined > as a function that takes one argument, I don't see how that fits in > with the usual scheme for foldr, which, as I understand it, is: > > foldr f e [x1, x2, ...] = f x1 (f x2 (f x3 ...(f xn e)))... > > Thanks, as always, to all in this great community. > > > Windows Live?: Keep your life in sync. Check it > out._______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Thu Mar 12 14:00:28 2009 From: dons at galois.com (Don Stewart) Date: Thu Mar 12 13:51:35 2009 Subject: [Haskell-cafe] ThreadScope: Request for features for the performance tuning of parallel and concurrent Haskell programs In-Reply-To: <49B94DB7.7080009@centrum.cz> References: <2E753E6C-E53E-4972-9A23-681B4A61A278@anu.edu.au> <49B91F62.8030706@gmail.com> <20090312163746.GB10693@whirlpool.galois.com> <49B94DB7.7080009@centrum.cz> Message-ID: <20090312180028.GG10693@whirlpool.galois.com> karel.gardas: > Don Stewart wrote: > > marlowsd: > >> Ben Lippmeier wrote: > >> > >>> On 12/03/2009, at 12:24 AM, Satnam Singh wrote: > >>>> Before making the release I thought it would be an idea to ask people > >>>> what other features people would find useful or performance tuning. > >>>> So if you have any suggestions please do let us know! > >>>> > >>> Is it available in a branch somewhere to try out? > >> There are three parts to it: > >> > >> - some patches to GHC to generate the log files. The patches are > >> not yet in, but I hope to get them in in the next couple of weeks. > > > > Just as a meta-point, it makes a *lot* of sense for the runtime to > > support proper logging -- it's practically a microkernel after all, so > > logging makes as much sense for GHC's rts as it does for regular > > kernels. > > > > Now we just need a /proc for the rts, so I can peek at GC stats live. > > Seeing this thread and discussion direction I cannot resist to > temptation to ask: is anybody going to write rts DTrace[1] provider? I think this is clear next step in the investigations. -- Don From matt at immute.net Thu Mar 12 16:32:23 2009 From: matt at immute.net (Matt Hellige) Date: Thu Mar 12 16:20:34 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: References: Message-ID: <5959041b0903121332x27f2f7e8ka0692f12131b7c39@mail.gmail.com> Looks like it may be defined in the package applicative-extras: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/applicative-extras But I'm not positive about that, and the docs are... sparse. Matt 2009/3/12 Peter Verswyvelen : > I think. Or is it defined in some other package? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From tphyahoo at gmail.com Thu Mar 12 16:36:28 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Mar 12 16:24:40 2009 Subject: [Haskell-cafe] Does anybody dislike implicit params as much as I do? Message-ID: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> http://blog.patch-tag.com/2009/03/09/implicitparams-are-evil-thoughts-on-adapting-gitit/ I understand there are arguments for using IPs, but after this experience, the ImplicitParams extension is a "code smell" for me. From noteed at gmail.com Thu Mar 12 16:54:14 2009 From: noteed at gmail.com (minh thu) Date: Thu Mar 12 16:42:25 2009 Subject: [Haskell-cafe] Does anybody dislike implicit params as much as I do? In-Reply-To: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> References: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> Message-ID: <40a414c20903121354lad2848fyf8a0868b3af75c92@mail.gmail.com> 2009/3/12 Thomas Hartman : > http://blog.patch-tag.com/2009/03/09/implicitparams-are-evil-thoughts-on-adapting-gitit/ > > I understand there are arguments for using IPs, but after this > experience, the ImplicitParams extension is a "code smell" for me. I think you state the obvious for many haskellers, so no, you're not alone :) Thu From martijn at van.steenbergen.nl Thu Mar 12 17:00:49 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Mar 12 16:49:00 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> References: <49B5AD46.2020502@gmail.com> <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> Message-ID: <49B97801.9010208@van.steenbergen.nl> Deniz Dogan wrote: > Then of course, > there's the downside that there's no connection to the language itself > in any way. I usually go for names that don't have to do anything with the application itself: GroteTrap (translates to GreatBustard), Yogurt, Custard... saves me from having to think of "appropriate" names. :-P Martijn. From ryani.spam at gmail.com Thu Mar 12 17:05:53 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Mar 12 16:54:06 2009 Subject: [Haskell-cafe] Hand calculation of Bird's definition of zip using foldr In-Reply-To: References: Message-ID: <2f9b2d30903121405v2fc1163an1030783a1497197d@mail.gmail.com> 2009/3/12 R J : > Part of my problem is that "e" is defined as a function that takes > one argument, I don't see how that fits in with the usual scheme for foldr, > which, as I understand it, is: > > foldr f e [x1, x2, ...] = f x1 (f x2 (f x3 ...(f xn e)))... It's pretty easy, actually. Lets rewrite the type signatures a bit: > foldr :: (a -> b -> b) -> b -> ([a] -> b) > zip :: [x] -> [y] -> [(x,y)] > zip = foldr f e where > e _ = [] > f _ _ [] = [] > f x g (y:ys) = (x,y) : g ys So, from the signature for foldr, we can derive: > f :: (a -> b -> b) > e :: b > zip :: [a] -> b And from the two type signatures for zip, we derive: > b ~ [y] -> [(x,y)] > a ~ x (~ is type equality) This gives > e :: [y] -> [(x,y)] > f :: x -> ([y] -> [(x,y)]) -> ([y] -> [(x,y)]) or, removing the extra parenthesis > f :: x -> ([y] -> [(x,y)]) -> [y] -> [(x,y)] that is, f takes *three* arguments, the second of which is a function of type [y] ->[(x,y)] What happens is that the *partially applied* f is getting chained through the fold; so you get zip [1,2,3] ['a','b','c'] = foldr f e [1,2,3] ['a','b','c'] = f 1 (f 2 (f 3 e)) ['a', 'b', 'c'] Then, in the first application of f, "g" is (f 2 (f 3 e)): = (1, 'a') : (f 2 (f 3 e)) ['b','c'] Now, there are two termination conditions; if the first list ends, we reach "e", which eats the remainder of the second list, returning []. In fact, e is the only total function of its type (forall x y. [y] -> [(x,y)]). If the second list ends, then f sees that and doesn't call g; that is, the rest of the foldr is unevaluated and unused! foldr f e [1,2,3] [] => f 1 (foldr f e [2,3]) [] => [] -- ryan From dan.doel at gmail.com Thu Mar 12 17:13:20 2009 From: dan.doel at gmail.com (Dan Doel) Date: Thu Mar 12 17:01:39 2009 Subject: [Haskell-cafe] Does anybody dislike implicit params as much as I do? In-Reply-To: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> References: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> Message-ID: <200903121713.21182.dan.doel@gmail.com> On Thursday 12 March 2009 4:36:28 pm Thomas Hartman wrote: > http://blog.patch-tag.com/2009/03/09/implicitparams-are-evil-thoughts-on-ad >apting-gitit/ > > I understand there are arguments for using IPs, but after this > experience, the ImplicitParams extension is a "code smell" for me. Implicit parameters are a (sort of) impure version of the reader monad. Of course, the 'effects' are still indicated in the type to a degree, but it's similar in a way to other languages which have impure IO (for example), except that reader is a lot less evil. :) The main thing they buy you, of course, is programming in a nice, normal, applicative style, instead of having to fool with monadic style (of course, they also give you multiple such variables, with names no less, that can be combined in a more dynamic fashion than Reader. To mimic all that (without passing around ST-like references), would probably require, off the top of my head, both indexed monads and extensible records. But I digress :)). Perhaps with applicative functor combinators, that gap can be lessened a bit. Incidentally, your example looks as follows with Reader: type ParamsHandler = Reader Params Handler withMessages :: [String] -> ParamsHandler -> ParamsHandler withMessages msgs val = local (\params -> params { pMessages = msgs ++ pMessages params }) val It'd be even nicer with lenses for updating the params. :) -- Dan From vogt.adam at gmail.com Thu Mar 12 17:23:46 2009 From: vogt.adam at gmail.com (Adam Vogt) Date: Thu Mar 12 17:11:26 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: <20090303041311.GL27223@knuth.cs.hmc.edu> References: <20090303041311.GL27223@knuth.cs.hmc.edu> Message-ID: <20090312212346.GA7447@smuckers.uwaterloo.ca> This seems to be in ghc for those reasons: http://www.haskell.org/haskellwiki/Quasiquotation * On Monday, March 02 2009, Andrew Hunter wrote: >Several times now I've had to define an EDSL for working with >(vaguely) numeric expressions. For stuff like 2*X+Y, this is easy, >looking pretty much like: > >> data Expr = Const Integer | Plus Expr Expr | Times Expr Expr >> >> instance Num Expr where >> fromInterger = Const >> (+) = Plus >> (*) = Times > >&c. This lets me get a perfectly nice AST, which is what I want. >When I want to be able to express and work with inequalities and >equalities, this breaks. Suppose I want to write 2*X + Y < 3. I >either have to: > >a) Hide Prelude.(<) and define a simple < that builds the AST term I want. >b) Come up with a new symbol for it that doesn't look totally awful. > >Neither of these work decently well. Hiding Eq and Ord operators, >which is what I effectively have to do for a), is pretty much a >nonstarter--we'll have to use them too much for that to be practical. > >On the other hand, b) works...but is about as ugly as it gets. We >have lots and lots of symbols that are already taken for important >purposes that are syntactically "near" <,<=,==, and the like: << and >>> and >>= for monads, >>> for arrows, etc. There...are not good >choices that I know of for the symbols that don't defeat the purpose >of making a nice clean EDSL for expressions; I might as well use 3*X + >Y `lessthan` 3, which is just not cool. > >Does anyone know of a good solution, here? Are there good >substitutions for all the six operators that are important >(<,>,>=,<=,==,/=), that are close enough to be pretty-looking but not >used for other important modules? > >Better yet, though a little harder, is there a nice type trick I'm not >thinking of? This works for Num methods but not for Ord methods >because: > >(+) :: (Num a) => a -> a -> a >(<) :: (Ord a) => a -> a -> Bool > >i.e. the return type of comparisons is totally fixed. I don't suppose >there's a good way to...well, I don't know what the *right* answer is, >but maybe define a new typeclass with a more flexible type for < that >lets both standard types return Bool and my expressions return Expr? >Any good solution would be appreciated. > >Thanks, >AHH >_______________________________________________ >Haskell-Cafe mailing list >Haskell-Cafe@haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe From v.dijk.bas at gmail.com Thu Mar 12 17:30:01 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Mar 12 17:18:13 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: References: Message-ID: 2009/3/12 Peter Verswyvelen : > I think. Or is it defined in some other package? There's an existing ticket about this: http://hackage.haskell.org/trac/ghc/ticket/2316 Note that the ticket links to some old threads on libraries@haskell.org about the issue. regards, Bas From stefanschmidt42 at googlemail.com Thu Mar 12 17:44:40 2009 From: stefanschmidt42 at googlemail.com (Stefan Schmidt) Date: Thu Mar 12 17:39:57 2009 Subject: [Haskell-cafe] How to compare PortNumbers or Bug in Network.Socket? Message-ID: <49B98248.5000806@googlemail.com> Hello, I want to compare two PortNumber-Values from the Network.Socket module and I think I've experienced some unexpected behavior of the derived ordering methods. I'm using the ghc-6.10.1 and the network library 2.2.0.1 on a x86 32-Bit machine. The following program creates two pairs of PortNumber values and compares them with each other. module Main(main) where import Network.Socket -- Block A p1 :: PortNumber p1 = fromIntegral 9000 p2 :: PortNumber p2 = fromIntegral 10000 -- Block B pp1 :: PortNumber pp1 = PortNum 9000 pp2 :: PortNumber pp2 = PortNum 10000 main :: IO () main = do putStrLn $ "A - " ++ (show $ p1 > p2) putStrLn $ "B - " ++ (show $ pp1 > pp2) On my machine, I get the result: A - True A - False At the first glance, it seemed to me, that there is a bug in the fromIntegral Implementation. But after I looked into the code, I saw that fromIntegral calls the system function "htons" to change the byte order from my machine to the network byte order, which on my machine is different. Because of this the values 9000 and 10000 are transferred, so that their ordering changes. Block B preservers this ordering, because the Constructor PortNum does not call htons, but since the byte order is wrong, I cannot use pp1 and pp2 to address port 9000 and 10000. As a work around, I could convert two PortNumbers back to Int-Values before comparing them, but I think the ordering functions for the PortNumber-Type do not work as expected. Or am I wrong? Stefan Schmidt From bos at serpentine.com Thu Mar 12 17:56:55 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu Mar 12 17:45:07 2009 Subject: [Haskell-cafe] How to compare PortNumbers or Bug in Network.Socket? In-Reply-To: <49B98248.5000806@googlemail.com> References: <49B98248.5000806@googlemail.com> Message-ID: On Thu, Mar 12, 2009 at 2:44 PM, Stefan Schmidt < stefanschmidt42@googlemail.com> wrote: > As a work around, I could convert two PortNumbers back to Int-Values before > comparing them, but I think the ordering functions for the PortNumber-Type > do not work as expected. Or am I wrong? > You're right. Arguably the port numbers shouldn't have their endianness switched until the need actually arises (passed into bind or the like). However, it's also arguably the case that you shouldn't care about port number ordering. That smells dodgy to me. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/e97d3e7a/attachment.htm From marcin.kosiba at gmail.com Thu Mar 12 18:01:14 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Thu Mar 12 17:49:38 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions Message-ID: <200903122301.20922.marcin.kosiba@gmail.com> Hi, I'm doing a bit of research into mobility models and I'm currently exploring implementation language choices for the simulator (yes, sadly it needs to be a custom one). I've been using Haskell here and there for some small tasks, and thought I should consider it as an implementation language for the simulator. While I already have an working implementation in Haskell, there is one thing that I would like to express in a more elegant way, but just can't figure out. The simulation algorithm requires expressing the node's mobility so that it is "stateless". The mobility model algorithm's type should be something like: mobility_model :: WorldState -> NodeState -> OtherInput -> (Action, NodeState) where Action can alter WorldState and the second NodeState is an altered input NodeState. I perform a form of speculative execution on mobility_model so sometimes I need to backtrack to a previous world and node state. This is all fairly simple stuff, and was just an introduction. What I do now is store an enum in NodeState and implement mobility_model as one big case statement. Yes, this is very imperative of me, I know. What I'd like to do is to express mobility_model, so that the code would look like: mobility_model world node input = do do_calculus emit_action if something then emit_action else emit_action do_calculus emit_action mobility_model world node input but I'd like to be able to alter world and node state before continuing from emit_action. I've tried to get this working by using the idea from http://www.haskell.org/pipermail/haskell/2005-April/015684.html but couldn't get the state-altering behavior I was looking for. I've also taken a look at http://monadicheadaches.blogspot.com/2008/01/python-25s-iterators-in-haskell-sort-of.html, the unified concurrency model and Control.Coroutine, but couldn't get the behavior I was going for. Thanks! Marcin Kosiba -------------- 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/20090312/bdb07048/attachment.bin From noteed at gmail.com Thu Mar 12 18:21:30 2009 From: noteed at gmail.com (minh thu) Date: Thu Mar 12 18:09:42 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions In-Reply-To: <200903122301.20922.marcin.kosiba@gmail.com> References: <200903122301.20922.marcin.kosiba@gmail.com> Message-ID: <40a414c20903121521l3000701fna7dce6aa1d4097d9@mail.gmail.com> 2009/3/12 Marcin Kosiba : > Hi, > ? ? ? ?I'm doing a bit of research into mobility models and I'm currently exploring > implementation language choices for the simulator (yes, sadly it needs to be > a custom one). > ? ? ? ?I've been using Haskell here and there for some small tasks, and thought I > should consider it as an implementation language for the simulator. > ? ? ? ?While I already have an working implementation in Haskell, there is one thing > that I would like to express in a more elegant way, but just can't figure > out. The simulation algorithm requires expressing the node's mobility so that > it is "stateless". The mobility model algorithm's type should be something > like: > mobility_model :: WorldState -> NodeState -> OtherInput -> (Action, NodeState) > > where Action can alter WorldState and the second NodeState is an altered input > NodeState. I perform a form of speculative execution on mobility_model so > sometimes I need to backtrack to a previous world and node state. > ? ? ? ?This is all fairly simple stuff, and was just an introduction. What I do now > is store an enum in NodeState and implement mobility_model as one big case > statement. Yes, this is very imperative of me, I know. What I'd like to do is > to express mobility_model, so that the code would look like: > > mobility_model world node input = do > ? ?do_calculus > ? ?emit_action > ? ?if something > ? ? ?then emit_action > ? ? ?else emit_action > ? ?do_calculus > ? ?emit_action > ? ?mobility_model world node input Hi, It seems you can use http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State-Lazy.html Just have a look at the exemple : tick :: State Int Int tick = do n <- get put (n+1) return n your code would become something like mobility_model :: OtherInput -> State (WorldState,NodeState) () mobility_model input = do world <- gets fst node <- gets snd .... let (world',node') = ... put (world',node') HTH, Thu From flippa at flippac.org Thu Mar 12 18:24:41 2009 From: flippa at flippac.org (Philippa Cowderoy) Date: Thu Mar 12 18:12:55 2009 Subject: [Haskell-cafe] How to compare PortNumbers or Bug in Network.Socket? In-Reply-To: References: <49B98248.5000806@googlemail.com> Message-ID: <1236896681.27446.21.camel@flippa-eee> On Thu, 2009-03-12 at 14:56 -0700, Bryan O'Sullivan wrote: > However, it's also arguably the case that you shouldn't care about port number ordering. That smells dodgy to me. > Port ranges aren't that uncommon. -- Philippa Cowderoy From stefanschmidt42 at googlemail.com Thu Mar 12 18:32:37 2009 From: stefanschmidt42 at googlemail.com (Stefan Schmidt) Date: Thu Mar 12 18:27:57 2009 Subject: [Haskell-cafe] How to compare PortNumbers or Bug in Network.Socket? In-Reply-To: <1236896681.27446.21.camel@flippa-eee> References: <49B98248.5000806@googlemail.com> <1236896681.27446.21.camel@flippa-eee> Message-ID: <49B98D85.1070504@googlemail.com> Philippa Cowderoy wrote: > On Thu, 2009-03-12 at 14:56 -0700, Bryan O'Sullivan wrote: >> However, it's also arguably the case that you shouldn't care about port number ordering. That smells dodgy to me. > Port ranges aren't that uncommon. That's exactly were I need the comparison. I'm writing a program which takes a range of port numbers and tries to open a socket with the first available port number. The whole thing is part of a distributed system and I cannot specify just a single port number because I could already been taken. Stefan From marcin.kosiba at gmail.com Thu Mar 12 19:01:56 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Thu Mar 12 18:50:29 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions Message-ID: <200903130001.56943.marcin.kosiba@gmail.com> On Thursday 12 March 2009, you wrote: > 2009/3/12 Marcin Kosiba : > > Hi, > > ? ? ? ?I'm doing a bit of research into mobility models and I'm currently > > exploring implementation language choices for the simulator > > (*snip*) > > The simulation algorithm requires expressing > > the node's mobility so that it is "stateless". The mobility model > > algorithm's type should be something like: > > mobility_model :: WorldState -> NodeState -> OtherInput -> (Action, > > NodeState) > > > > where Action can alter WorldState and the second NodeState is an altered > > input NodeState. I perform a form of speculative execution on > > mobility_model so sometimes I need to backtrack to a previous world and > > node state. This is all fairly simple stuff, and was just an > > introduction. What I do now is store an enum in NodeState and implement > > mobility_model as one big case statement. Yes, this is very imperative of > > me, I know. What I'd like to do is to express mobility_model, so that the > > code would look like: > > > > mobility_model world node input = do > > ? ?do_calculus > > ? ?emit_action > > ? ?if something > > ? ? ?then emit_action > > ? ? ?else emit_action > > ? ?do_calculus > > ? ?emit_action > > ? ?mobility_model world node input > > Hi, > > It seems you can use > http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Mon >ad-State-Lazy.html Just have a look at the exemple : > > tick :: State Int Int > tick = do n <- get > put (n+1) > return n > > your code would become something like > mobility_model :: OtherInput -> State (WorldState,NodeState) () > mobility_model input = do > world <- gets fst > node <- gets snd > .... > let (world',node') = ... > put (world',node') ok, that solves part of the problem. what this doesn't solve is that somewhere between these lines (which corespond to emit_action in my example) > let (world',node') = ... > put (world',node') I need to return a value and an Action and NodeState to the simulation algorithm. and then, after the simulation algorithm calculates a new WorldState it will want the mobility_model to where it left off, but with a new WorldState. I hope I'm clear about what I wish to achieve: each emit_action should return a value (Action, NodeState) and maybe a function mobility_model_cont which I then could call with the new WorldState to continue from where emit_action returned. Thanks, Marcin Kosiba -------------- 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/20090313/011128b3/attachment.bin From tphyahoo at gmail.com Thu Mar 12 19:17:28 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Mar 12 19:05:40 2009 Subject: [Haskell-cafe] Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? Message-ID: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> Is there something like subRegex... something like =~ s/.../.../ in perl... for haskell pcre Regexen? I mean, subRegex from Text.Regex of course: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat Thanks for any advice, thomas. From heikki.aitakangas at cs.helsinki.fi Thu Mar 12 19:24:06 2009 From: heikki.aitakangas at cs.helsinki.fi (Heikki Aitakangas) Date: Thu Mar 12 19:12:18 2009 Subject: [Haskell-cafe] Combining haddock documentation from multiple packages Message-ID: <49B99996.6020308@cs.helsinki.fi> Is it possible to generate a "unified" documentation tree similar to http://www.haskell.org/ghc/docs/latest/html/libraries/index.html from packages installed via cabal from hackage? And if so, how does one go about doing it? -- Heikki Aitakangas From haskell at list.mightyreason.com Thu Mar 12 20:19:00 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Thu Mar 12 20:07:22 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> Message-ID: <49B9A674.4020708@list.mightyreason.com> Thomas Hartman wrote: > Is there something like subRegex... something like =~ s/.../.../ in > perl... for haskell pcre Regexen? > > I mean, subRegex from Text.Regex of course: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat > > Thanks for any advice, > > thomas. Short answer: No. This is a FAQ. The usual answer to your follow up "Why not?" is that the design space is rather huge. Rather than justify this statement, I will point at the complicated module: http://hackage.haskell.org/packages/archive/split/0.1.1/doc/html/Data-List-Split.html The above module is "a wide range of strategies for splitting lists", which is a much simpler problem than your subRegex request, and only works on lists. A subRegex library should also work on bytestrings (and Seq). At the cost of writing your own routine you get exactly what you want in a screen or less of code, see http://hackage.haskell.org/packages/archive/regex-compat/0.92/doc/html/src/Text-Regex.html#subRegex for "subRegex" which is 30 lines of code. Cheers, Chris From ok at cs.otago.ac.nz Thu Mar 12 21:38:29 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Mar 12 21:26:43 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: References: <49B5AD46.2020502@gmail.com> Message-ID: On 12 Mar 2009, at 11:08 pm, Satnam Singh wrote: > I agree that looking for a mascot that is inspired by "laziness" is > a bad idea from a P.R. perspective (I am tired of people walking out > the room when I give Haskell talks to general audiences and explain > lazy evaluation). Perhaps we should call it "Just-In-Time evaluation. As for mascots, let's take a photo of Simon Peyton Jones, shrink him to hobbit size, give him furry feet, and announce that "here is one of the warm fuzzy things we have in mind when we use monads". (:-) From DekuDekuplex at Yahoo.com Thu Mar 12 22:17:53 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu Mar 12 22:06:20 2009 Subject: [Haskell-cafe] Re: Against cuteness References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> Message-ID: <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> On Thu, 12 Mar 2009 09:11:15 -0500, Gregg Reynolds wrote: >I don't think so. Bad design will lose them (and many others), but >good design and cuteness are two different things. It's also possible for a good design to be cute, too. >> You can still distinguish yourself from O'Reilly without losing the >> cuteness factor with a logo like one of the following: >> > >We must have vastly different ideas of cute. I don't consider those >examples cute. How about this as a criterion: if it makes 13-year >old Japanese girls squeal "kawaiiii!" then it's too cute. Also if it >involves the color pink. What's wrong with the color pink (not that I prefer it personally, but just wondering)? You're also assuming that all 13-year old Japanese girls "squeal 'kawaiiii!'" in response to the same stimuli. I know for a fact that this isn't true (I recently saw a study asking Japanese girls to rate different mascots for cuteness, and the poll fell roughly 50-50, as a matter of fact). Which 13-year old Japanese girls are you referring to? -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From deniz.a.m.dogan at gmail.com Thu Mar 12 22:22:41 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Mar 12 22:10:52 2009 Subject: [Haskell-cafe] Re: Against cuteness In-Reply-To: <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> Message-ID: <7b501d5c0903121922j627ded44wbaa17a5ee7885046@mail.gmail.com> 2009/3/13 Benjamin L. Russell : > On Thu, 12 Mar 2009 09:11:15 -0500, Gregg Reynolds > wrote: [snip] Why even bother discussing whether a potential mascot should be cute or not? You guys should come up with new ideas instead of simply stating what you *don't* want. :) Deniz From DekuDekuplex at Yahoo.com Thu Mar 12 22:34:08 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu Mar 12 22:22:34 2009 Subject: [Haskell-cafe] Re: Haskell-Wiki Account registration References: Message-ID: On Thu, 12 Mar 2009 17:31:49 +0100 (CET), Henning Thielemann wrote: > >How long will the Wiki account registration be disabled? Would it be >possible to ask a question, that real Haskellers could easily answer, but >a spambot cannot? E.g. "What's Haskell's surname?" Indeed. Disabling Wiki account registration indefinitely, and not replacing it by at least some form of automatic registration, risks allowing outsiders to think that the HaskellWiki is somehow run by some "clique," which I'm sure is not the case. Automating the process removes most of the risk of this misimpression. Why not ask new users to identify letters in a random bitmapped image of a string, as is commonly done? Then any new user who still registers and starts submitting spam can be tracked and moderated. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From mark.spezzano at chariot.net.au Thu Mar 12 22:54:39 2009 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Thu Mar 12 22:43:00 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? Message-ID: <000001c9a387$0eab4e70$2c01eb50$@spezzano@chariot.net.au> Hi, I was wondering what the best way to implement Natural number would be. Is there a package which already does this? Here are some options: 1. Don’t bother. Just use Integer. 2. Use the type data Natural = Zero | Succ !Natural 3. Use the following definition taken from the Gentle Introduction to Haskell 98 newtype Natural = MakeNatural Integer toNatural ::Integer-> Integer toNatural x | x < 0 = error “Can’t create negative naturals!” | otherwise = MakeNatural x fromNatural :: Natural -> Integer fromNatural (MakeNatural i) = i and then... instance Num Natural where fromInteger = toNAtural x + y = toNatural (fromNatural x + fromNatural y) x – y = etc.. x * y = etc... Which method is best? So far, I’ve been picking option #1 – just leaving things as they are and using Integer to keep things simple. I’ve got that feeling that [2] would be fast and [3] would be slow. Comment appreciated on the merits of each. Cheers, Mark Spezzano No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.12/1998 - Release Date: 12/03/2009 6:23 PM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/696d19b7/attachment.htm From alexander.dunlap at gmail.com Thu Mar 12 23:01:57 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Thu Mar 12 22:50:07 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <2816604275516129323@unknownmsgid> References: <2816604275516129323@unknownmsgid> Message-ID: <57526e770903122001w4093677ex244db35198686852@mail.gmail.com> 2009/3/12 Mark Spezzano : > Hi, > > > > I was wondering what the best way to implement Natural number would be. Is > there a package which already does this? > > > > Here are some options: > > > > 1.? Don?t bother. Just use Integer. > > 2.? Use the type > > data Natural = Zero | Succ !Natural > > 3.? Use the following definition taken from the Gentle Introduction to > Haskell 98 > > newtype Natural = MakeNatural Integer > > toNatural ::Integer-> Integer > > toNatural x | x < 0 = error ?Can?t create negative naturals!? > > ? ?????????? | otherwise = MakeNatural x > > fromNatural :: Natural -> Integer > > fromNatural (MakeNatural i) = i > > > > and then... > > > > instance Num Natural where > > ? fromInteger = toNAtural > > ? x + y?????? = toNatural (fromNatural x + fromNatural y) > > ? x ? y ??????= etc.. > > ? x * y?????? = etc... > > > > Which method is best? So far, I?ve been picking option #1 ? just leaving > things as they are and using Integer to keep things simple. > > > > I?ve got that feeling that [2] would be fast and [3] would be slow. Comment > appreciated on the merits of each. > > > > Cheers, > > > > Mark Spezzano > I would tend to use option (1) unless there's a compelling reason not to. Since naturals aren't closed under subtraction, you would in practice probably have just as many non-total functions as you would with the regular Int{,eger} type. Also, a lot of functions just take Integers so it would be more of a pain to use. In terms of speed, I think that [3] would be reasonably fast (unless you do a ton of subtraction with bounds-checking) and [2] would probably be quite slow, because you don't get the speed-boost from doing computations right on the processor. Alex From jfredett at gmail.com Thu Mar 12 23:03:50 2009 From: jfredett at gmail.com (Joe Fredette) Date: Thu Mar 12 22:52:03 2009 Subject: [Haskell-cafe] Re: Haskell-Wiki Account registration In-Reply-To: References: Message-ID: <49B9CD16.4070803@gmail.com> As long as one is implementing a CAPTCHA, the "reCAPTCHA" [1] is my humble suggestion, I have no idea how the haskellwiki is implemented or how easy this is to implement, but I imagine it couldn't be _that_ hard. /Joe [1] http://recaptcha.net/ Benjamin L.Russell wrote: > On Thu, 12 Mar 2009 17:31:49 +0100 (CET), Henning Thielemann > wrote: > > >> How long will the Wiki account registration be disabled? Would it be >> possible to ask a question, that real Haskellers could easily answer, but >> a spambot cannot? E.g. "What's Haskell's surname?" >> > > Indeed. Disabling Wiki account registration indefinitely, and not > replacing it by at least some form of automatic registration, risks > allowing outsiders to think that the HaskellWiki is somehow run by > some "clique," which I'm sure is not the case. Automating the process > removes most of the risk of this misimpression. > > Why not ask new users to identify letters in a random bitmapped image > of a string, as is commonly done? Then any new user who still > registers and starts submitting spam can be tracked and moderated. > > -- Benjamin L. Russell > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/bd7aa71a/jfredett.vcf From DekuDekuplex at Yahoo.com Thu Mar 12 23:29:23 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu Mar 12 23:17:48 2009 Subject: [Haskell-cafe] Re: Against cuteness References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> <7b501d5c0903121922j627ded44wbaa17a5ee7885046@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009 03:22:41 +0100, Deniz Dogan wrote: >2009/3/13 Benjamin L. Russell : >> On Thu, 12 Mar 2009 09:11:15 -0500, Gregg Reynolds >> wrote: > >[snip] > >Why even bother discussing whether a potential mascot should be cute >or not? You guys should come up with new ideas instead of simply >stating what you *don't* want. :) Good point. Okay, here's a suggestion: Consider the following logo: Silver red monad.png http://commons.wikimedia.org/wiki/File:Silver_red_monad.png This logo "[s]ignifies balance between consumption and production," and is the "Official Symbol of Technocracy - http://www.technocracy.org/." The above-mentioned logo is essentially a silver-red variation of the Yin-Yang symbol without the dots on both ends. Then consider the background of the following Yin-Yang symbol: Yin-Yang Symbol (on a swirling orange-gold background) http://thumbs.dreamstime.com/thumb_236/1202779093o0VB6w.jpg Given that the representation of the Pythagorean monad can already be considered as a portion of the Yin-Yang symbol (see http://en.wikipedia.org/wiki/Monad_(Greek_philosophy)), why not take the background for the above-mentioned Yin-Yang symbol, superimpose the silver-red monad, and then simply superimpose representations of the Pythagorean monad as gradiated halos where there are dots in a traditional Yin-Yang symbol? We would then have a silver-red monad that closely resembles a Yin-Yang symbol, except that the dots would each be surrounded by a gradiated halo representing a monad, on a wavy orange-gold background: essentially, a pair of Pythagorean monads in a silver-red monad on a distinctive background. This symbol would represent the three-way balance between purity (symbolized by the red), laziness (symbolized by the silver), and monads (symbolized by the dots surrounded by halos). I don't have time to craft the image right now, but I may be able to come up with something after lunch. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From aslatter at gmail.com Thu Mar 12 23:45:54 2009 From: aslatter at gmail.com (Antoine Latter) Date: Thu Mar 12 23:34:05 2009 Subject: [Haskell-cafe] How to compare PortNumbers or Bug in Network.Socket? In-Reply-To: <49B98D85.1070504@googlemail.com> References: <49B98248.5000806@googlemail.com> <1236896681.27446.21.camel@flippa-eee> <49B98D85.1070504@googlemail.com> Message-ID: <694519c50903122045u3cfa54e4v36bef7a4d0e0fd8e@mail.gmail.com> On Thu, Mar 12, 2009 at 5:32 PM, Stefan Schmidt wrote: > Philippa Cowderoy wrote: >> >> On Thu, 2009-03-12 at 14:56 -0700, Bryan O'Sullivan wrote: >>> >>> However, it's also arguably the case that you shouldn't care about port >>> number ordering. That smells dodgy to me. >> >> Port ranges aren't that uncommon. > > That's exactly were I need the comparison. I'm writing a program which takes > a range of port numbers and tries to open a socket with the first available > port number. The whole thing is part of a distributed system and I cannot > specify just a single port number because I could already been taken. > > Stefan So the Ord instance is wrong for the PortNumber type? Well, maybe not wrong. But not as useful as it could be. Antoine From allbery at ece.cmu.edu Thu Mar 12 23:53:47 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Mar 12 23:42:11 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <000001c9a387$0eab4e70$2c01eb50$@spezzano@chariot.net.au> References: <000001c9a387$0eab4e70$2c01eb50$@spezzano@chariot.net.au> Message-ID: <7FC20B04-4745-40D9-973C-9CD237BD29AD@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/3ab70fa4/PGP.bin From dbueno at gmail.com Fri Mar 13 00:09:57 2009 From: dbueno at gmail.com (Denis Bueno) Date: Thu Mar 12 23:58:07 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: References: Message-ID: <6dbd4d000903122109xc86c01dt11c1cc0d4914698f@mail.gmail.com> 2009/3/12 Peter Verswyvelen : > I think. Or is it defined in some other package? Note that you can get an Applicative instance for "free" by using "WrapMonad" in Control.Applicative. For example, just today I was writing a quickcheck Arbitrary instance, and the Gen monad doesn't have an Applicative instance. No problem: > instance Gen MyDataType where > arbitrary = MyDataConstructor <$> arbitrary <*> arbitrary becomes > instance Gen MyDataType where > arbitrary = unWrapMonad (MyDataConstructor <$> WrapMonad arbitrary <*> WrapMonad arbitrary) This works because every monad induces an Applicative instance in a way I've ingested just enough wine to forget. =] Denis From lists at qseep.net Fri Mar 13 00:10:07 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Thu Mar 12 23:58:21 2009 Subject: [Haskell-cafe] ANNOUNCE: Vintage BASIC 1.0 Message-ID: <670e468e0903122110kf68bf0dt2a00a8a3287c3537@mail.gmail.com> I am pleased to announce the initial release of Vintage BASIC, an interpreter for microcomputer-era BASIC. Fully unit-tested, it faithfully implements the common elements of the language. On the web site, you can find 102 games from the classic book BASIC Computer Games, all of which run flawlessly. Have fun! This is a standalone interpreter, operating on text files. Although not an embedding, like Lennart Augustsson's clever implementation, it does use a custom BASIC monad in order to execute the code. A unique feature of this implementation is that control structures such as FOR are implemented using resumable exceptions: FOR is a handler and NEXT throws an exception. A Developer's Guide is included with the source. This is my first public release of open source software. I have been working on this project since 2003. Home page: http://www.vintage-basic.net Also available on Hackageand patch-tag.com . Please e-mail me at lyle@vintage-basic.net with any questions/comments. - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/aab30090/attachment-0001.htm From miguelimo38 at yandex.ru Fri Mar 13 00:17:54 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Mar 13 00:07:38 2009 Subject: [Haskell-cafe] Does anybody dislike implicit params as much as I do? In-Reply-To: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> References: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> Message-ID: There is an old joke in Russia: - I don't like cats. - You just don't know how to cook them. Well, maybe, you don't know how to cook implicit parameters? Anyway, what about type classes - aren't they a sort of implicit parameters? On 12 Mar 2009, at 23:36, Thomas Hartman wrote: > http://blog.patch-tag.com/2009/03/09/implicitparams-are-evil-thoughts-on-adapting-gitit/ > > I understand there are arguments for using IPs, but after this > experience, the ImplicitParams extension is a "code smell" for me. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lists at qseep.net Fri Mar 13 00:22:08 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Fri Mar 13 00:10:18 2009 Subject: [Haskell-cafe] Distributing Linux binaries In-Reply-To: <87iqmgo1h0.fsf@malde.org> References: <670e468e0903091325s6104c528xca30b6dcfa8775b@mail.gmail.com> <87iqmgo1h0.fsf@malde.org> Message-ID: <670e468e0903122122s573f46efjb62dd99cb72cae69@mail.gmail.com> Thanks, folks. I have decided for now just to release a tarball with an executable and some docs, that can be expanded where the user deems appropriate. I'll try a static link if people are having problems with it. - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/febea0b5/attachment.htm From jfredett at gmail.com Fri Mar 13 00:30:59 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri Mar 13 00:19:10 2009 Subject: [Haskell-cafe] ANNOUNCE: Vintage BASIC 1.0 In-Reply-To: <670e468e0903122110kf68bf0dt2a00a8a3287c3537@mail.gmail.com> References: <670e468e0903122110kf68bf0dt2a00a8a3287c3537@mail.gmail.com> Message-ID: <49B9E183.8010208@gmail.com> Well, there goes any productivity I might have had on my spring break... Hurrah for old BASIC games! Lyle Kopnicky wrote: > I am pleased to announce the initial release of Vintage BASIC, an > interpreter for microcomputer-era BASIC. Fully unit-tested, it > faithfully implements the common elements of the language. On the web > site, you can find 102 games from the classic book BASIC Computer > Games, all of which run flawlessly. Have fun! > > This is a standalone interpreter, operating on text files. Although > not an embedding, like Lennart Augustsson's clever implementation, it > does use a custom BASIC monad in order to execute the code. A unique > feature of this implementation is that control structures such as FOR > are implemented using resumable exceptions: FOR is a handler and NEXT > throws an exception. A Developer's Guide is included with the source. > > This is my first public release of open source software. I have been > working on this project since 2003. > > Home page: http://www.vintage-basic.net > > Also available on Hackage > > and patch-tag.com . > > Please e-mail me at lyle@vintage-basic.net > with any questions/comments. > > - Lyle > ------------------------------------------------------------------------ > > _______________________________________________ > 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: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/4c55728e/jfredett.vcf From oleg at okmij.org Fri Mar 13 00:33:09 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Fri Mar 13 00:23:50 2009 Subject: [Haskell-cafe] Typing Dynamic Typing [Was: Dynamically typing TH.Exp at runtime] Message-ID: <20090313043309.79F2DABC6@Adric.metnet.fnmoc.navy.mil> Martin Hofmann asked: > Is there a Haskell implementation of the paper "Typing Dynamic Typing" > by Baars and Swierstra There is a different implementation but in the same spirit http://okmij.org/ftp/tagless-final/IncopeTypecheck.hs http://okmij.org/ftp/Computation/tagless-typed.html#tc-final The first difference between IncopeTypecheck and Baars and Swierstra's one is in the type representation and safe coercions. IncopeTypecheck uses Typeable, and so it needs to define reflection from a type rep to a value of that type. The projection function of Typeable requires a value of a specific type rather than a typerep. The main difference is treating environments and weakening. Baars and Swierstra treat an Identifier, at compile time, as a projection function \env->t. Here env is the run-time env represented as a nested tuple. `Closing the Stage' paper relies on the same idea. To be able to collect those projection functions into a regular list, they wrap them into a Dynamic. IncopeTypecheck, in contrast, represents compile-time variables as functions \x->x, which are weakened as they are embedded into a reacher environment. The functions are wrapped into Dynamic, as this is the result of typechecking. The type environment Gamma in IncopeTypecheck contains only TypeRep but no Dynamics! Here a few examples to illustrate the difference between Baars and Swierstra and IncopeTypecheck: Source expression: Add (Int 2) (Int 3) Baars and Swierstra: \env -> (\_ -> 2) env + (_ -> 3) env IncopeTypecheck: add (int 1) (int 2) Source expression: (Lam "x" Int (x + (Int 1))) Baars and Swierstra: \env -> \x -> (\env -> (\(x,_) ->x) env + (\_ -> 1) env) (x,env) IncopeTypecheck: \x -> (\x -> x) x `add` (\_ -> int 1) x (of course, in IncopeTypecheck, instead of (\x -> ...) there should be lam (\x -> ...) and instead of meta-language application there should be app. I drop them for clarity). For deeply nested functions, IncopeTypecheck probably has to do more redices as it repeatedly applies coercions. Since the environment is known, I could have built the weakening in one step rather than as a sequence of weakening into a progressively richer environment. Each step into this sequence includes an administrative redex. The sequential weakening was easier to implement though. From noteed at gmail.com Fri Mar 13 02:24:05 2009 From: noteed at gmail.com (minh thu) Date: Fri Mar 13 02:12:16 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions In-Reply-To: <200903130001.56943.marcin.kosiba@gmail.com> References: <200903130001.56943.marcin.kosiba@gmail.com> Message-ID: <40a414c20903122324s188359d1gc2dde0dce247d7b4@mail.gmail.com> 2009/3/13 Marcin Kosiba : > On Thursday 12 March 2009, you wrote: >> 2009/3/12 Marcin Kosiba : >> > Hi, >> > ? ? ? ?I'm doing a bit of research into mobility models and I'm currently >> > exploring implementation language choices for the simulator >> > (*snip*) >> > The simulation algorithm requires expressing >> > the node's mobility so that it is "stateless". The mobility model >> > algorithm's type should be something like: >> > mobility_model :: WorldState -> NodeState -> OtherInput -> (Action, >> > NodeState) >> > >> > where Action can alter WorldState and the second NodeState is an altered >> > input NodeState. I perform a form of speculative execution on >> > mobility_model so sometimes I need to backtrack to a previous world and >> > node state. This is all fairly simple stuff, and was just an >> > introduction. What I do now is store an enum in NodeState and implement >> > mobility_model as one big case statement. Yes, this is very imperative of >> > me, I know. What I'd like to do is to express mobility_model, so that the >> > code would look like: >> > >> > mobility_model world node input = do >> > ? ?do_calculus >> > ? ?emit_action >> > ? ?if something >> > ? ? ?then emit_action >> > ? ? ?else emit_action >> > ? ?do_calculus >> > ? ?emit_action >> > ? ?mobility_model world node input >> >> Hi, >> >> It seems you can use >> http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Mon >>ad-State-Lazy.html Just have a look at the exemple : >> >> ?tick :: State Int Int >> ?tick = do n <- get >> ? ? ? ? ? ?put (n+1) >> ? ? ? ? ? ?return n >> >> your code would become something like >> mobility_model :: OtherInput -> State (WorldState,NodeState) () >> mobility_model input = do >> ? world <- gets fst >> ? node <- gets snd >> ? .... >> ? let (world',node') = ... >> ? put (world',node') > > ok, that solves part of the problem. what this doesn't solve is that somewhere > between these lines (which corespond to emit_action in my example) >> ? let (world',node') = ... >> ? put (world',node') > I need to return a value and an Action and NodeState to the simulation > algorithm. and then, after the simulation algorithm calculates a new > WorldState it will want the mobility_model to where it left off, but with a > new WorldState. > > I hope I'm clear about what I wish to achieve: each emit_action should return > a value (Action, NodeState) and maybe a function mobility_model_cont which I > then could call with the new WorldState to continue from where emit_action > returned. I'm not entirely sure ... but I think it doesn't matter that much :) Here is why. This was just an exemple : mobility_model :: OtherInput -> State (WorldState,NodeState) () You could also have mobility_model :: OtherInput -> NodeState -> State WorldState (NodeState,Action) or whatever. In fact, the State monad makes it easy to thread (in this context, it means 'pass around') an argument to many functions, providing a nice syntax reminiscent of imperative language. But it lets you completely free of what is passed around. It depends on what you want to be explicitely passed by argument, and what you want to pass in the state of the monad (that is, what you want to appear, inside the monad only, as some global variable). So in your code, if you often need to pass a WorldState to a function which should return a modified WorldState, it makes sense to put WorldState inside the state monad. But, maybe, if there is just a few functions which act on NodeState, it has not to be part of the state carried by the state monad. I'm not entirely sure of what is a problem to you : is it the use of the State monad, or something else ? If it can help you to formulate your question you can post some code (or past it to http://hpaste.org/)... Cheers, Thu From bos at serpentine.com Fri Mar 13 02:54:27 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Mar 13 02:42:37 2009 Subject: [Haskell-cafe] How to compare PortNumbers or Bug in Network.Socket? In-Reply-To: <694519c50903122045u3cfa54e4v36bef7a4d0e0fd8e@mail.gmail.com> References: <49B98248.5000806@googlemail.com> <1236896681.27446.21.camel@flippa-eee> <49B98D85.1070504@googlemail.com> <694519c50903122045u3cfa54e4v36bef7a4d0e0fd8e@mail.gmail.com> Message-ID: On Thu, Mar 12, 2009 at 8:45 PM, Antoine Latter wrote: > So the Ord instance is wrong for the PortNumber type? Well, maybe not > wrong. It's out and out wrong. You get different results on machines of different endianness. Now, this begs the question of why not just simply use an unwrapped Word16 instead :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090312/926fe53f/attachment.htm From martin.hofmann at uni-bamberg.de Fri Mar 13 04:03:22 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Fri Mar 13 03:51:06 2009 Subject: [Haskell-cafe] Dynamically typing TH.Exp at runtime In-Reply-To: References: <20090312100136.F145C32490C@www.haskell.org> <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> <1236876446.6867.132.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <1236931402.6409.24.camel@ios.cogsys.wiai.uni-bamberg.de> Sorry, maybe it I didn't made it clear enough. > Perhaps I'm misunderstanding something, but since one can infer types > in GHCI, that implies one can infer types in the GHC API; since Hint > wraps the GHC API, that implies one can infer types in Hint, doesn't > it? And indeed, there are functions to infer the type of a String; > iirc I've even used them myself in mueval. > That's true, inferring the type of a string is not the problem. However, I am not only interested in the top-level type, but also in the type of any arbitrary subexpression. Consider for example following recursive definition: foo [] = [] foo (x:xs) = (:)(x+1)(foo xs) Typing only the first rule one would says its type is '[a] -> [a]'. However, the second rule specialises the type to 'Num a => [a] -> [a]'. So, if I am interested in the type of the 'x' in the pattern of the second rule, I need to be aware of its binding on the right-hand side. Consequently the type of 'x' is 'Num a'. AFAIK, I need Hendley-Milner type inference for that (please correct me if I am wrong) and I was wondering if I really need to implement it by myself, when it is already somewhere inside GHC. Thanks, Martin From g9ks157k at acme.softbase.org Fri Mar 13 04:04:40 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Mar 13 03:52:51 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: <49B97801.9010208@van.steenbergen.nl> References: <7b501d5c0903120453q7d1b5afdv1bd56e04b53e302@mail.gmail.com> <49B97801.9010208@van.steenbergen.nl> Message-ID: <200903130904.40287.g9ks157k@acme.softbase.org> Am Donnerstag, 12. M?rz 2009 22:00 schrieb Martijn van Steenbergen: > Deniz Dogan wrote: > > Then of course, > > there's the downside that there's no connection to the language itself > > in any way. > > I usually go for names that don't have to do anything with the > application itself: GroteTrap (translates to GreatBustard), Yogurt, > Custard... saves me from having to think of "appropriate" names. :-P This is basically how I chose the name ?Grapefruit? for ?my? FRP library. Okay, it refers to Fruit (a FRP GUI library) but the only further meaning of ?Grapefruit? is that I find Grapefruits to be tasty. :-) Often people choose meaningful names and convert them to acronyms, noone can pronounce. Best wishes, Wolfgang From martijn at van.steenbergen.nl Fri Mar 13 04:09:51 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Mar 13 03:58:01 2009 Subject: [Haskell-cafe] Combining haddock documentation from multiple packages In-Reply-To: <49B99996.6020308@cs.helsinki.fi> References: <49B99996.6020308@cs.helsinki.fi> Message-ID: <49BA14CF.3000604@van.steenbergen.nl> Hi Heikki, Heikki Aitakangas wrote: > Is it possible to generate a "unified" documentation tree similar to > http://www.haskell.org/ghc/docs/latest/html/libraries/index.html from > packages installed via cabal from hackage? And if so, how does one go > about doing it? This question was asked recently. See: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/53531 Martijn. From sebf at informatik.uni-kiel.de Fri Mar 13 04:11:44 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Fri Mar 13 04:00:01 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <000001c9a387$0eab4e70$2c01eb50$@spezzano@chariot.net.au> References: <000001c9a387$0eab4e70$2c01eb50$@spezzano@chariot.net.au> Message-ID: <760F4DE5-A477-457F-BCD6-A46A7F37C33A@informatik.uni-kiel.de> Hi Mark, On Mar 13, 2009, at 3:54 AM, Mark Spezzano wrote: > I was wondering what the best way to implement Natural number would > be. Is there a package which already does this? there are two packages on Hackage that implement natural numbers using algebraic datatypes: 'numbers' has a module Data.Number.Natural that implements them in "unary" notation (zero and successor), 'nat' has Data.Number.Nat that uses a binary encoding. Cheers, Sebastian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/f32e708f/attachment.htm From g9ks157k at acme.softbase.org Fri Mar 13 04:12:24 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Mar 13 04:00:35 2009 Subject: [Haskell-cafe] Re: Against cuteness In-Reply-To: References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <7b501d5c0903121922j627ded44wbaa17a5ee7885046@mail.gmail.com> Message-ID: <200903130912.24322.g9ks157k@acme.softbase.org> Am Freitag, 13. M?rz 2009 04:29 schrieb Benjamin L.Russell: > Consider the following logo: > > Silver red monad.png > http://commons.wikimedia.org/wiki/File:Silver_red_monad.png Can?t we choose something which is not connected to certain worldviews? Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Mar 13 04:14:07 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Mar 13 04:02:19 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: <6dbd4d000903122109xc86c01dt11c1cc0d4914698f@mail.gmail.com> References: <6dbd4d000903122109xc86c01dt11c1cc0d4914698f@mail.gmail.com> Message-ID: <200903130914.07367.g9ks157k@acme.softbase.org> Am Freitag, 13. M?rz 2009 05:09 schrieb Denis Bueno: > This works because every monad induces an Applicative instance in a > way I've ingested just enough wine to forget. =] pure = return (<*>) = ap Best wishes, Wolfgang From roma at ro-che.info Fri Mar 13 04:21:05 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Fri Mar 13 04:09:54 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <57526e770903122001w4093677ex244db35198686852@mail.gmail.com> References: <2816604275516129323@unknownmsgid> <57526e770903122001w4093677ex244db35198686852@mail.gmail.com> Message-ID: <20090313082105.GA14652@flit> * Alexander Dunlap [2009-03-12 20:01:57-0700] > Also, a lot of functions just take > Integers so it would be more of a pain to use. AFAIK there are very few fuctions that take Integers. Many functions take instances of Integral, but it's not a problem to make your own type such an instance. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From g9ks157k at acme.softbase.org Fri Mar 13 04:23:03 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Mar 13 04:11:15 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <57526e770903122001w4093677ex244db35198686852@mail.gmail.com> References: <2816604275516129323@unknownmsgid> <57526e770903122001w4093677ex244db35198686852@mail.gmail.com> Message-ID: <200903130923.04042.g9ks157k@acme.softbase.org> Am Freitag, 13. M?rz 2009 04:01 schrieb Alexander Dunlap: > > 2.? Use the type > > > > data Natural = Zero | Succ !Natural > > [?] > > In terms of speed, I think that [3] would be reasonably fast (unless > you do a ton of subtraction with bounds-checking) and [2] would > probably be quite slow, because you don't get the speed-boost from > doing computations right on the processor. Not only that but also because operations like addition now take at least linear time. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Mar 13 04:25:48 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Mar 13 04:13:59 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <7FC20B04-4745-40D9-973C-9CD237BD29AD@ece.cmu.edu> References: <000001c9a387$0eab4e70$2c01eb50$@spezzano@chariot.net.au> <7FC20B04-4745-40D9-973C-9CD237BD29AD@ece.cmu.edu> Message-ID: <200903130925.48311.g9ks157k@acme.softbase.org> Am Freitag, 13. M?rz 2009 04:53 schrieb Brandon S. Allbery KF8NH: > On 2009 Mar 12, at 22:54, Mark Spezzano wrote: > > I was wondering what the best way to implement Natural number would > > be. Is there a package which already does this? > > type-level on Hackage. I think, the original poster wanted value-level naturals, not type-level naturals. > > 2. Use the type > > data Natural = Zero | Succ !Natural > > One of the reasons people use type-level naturals is to get laziness; > you've made this strict. Is there a reason? Do you really mean type-level naturals? The following is a definition of value-level naturals: data Natural = Zero | Succ Natural Type-level naturals would be defined like this: data Zero data Succ nat Best wishes, Wolfgang From marcin.kosiba at gmail.com Fri Mar 13 04:34:28 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Fri Mar 13 04:22:41 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions Message-ID: <200903130934.28466.marcin.kosiba@gmail.com> On Friday 13 March 2009, you wrote: > 2009/3/13 Marcin Kosiba : > > On Thursday 12 March 2009, you wrote: > >> 2009/3/12 Marcin Kosiba : > >> > Hi, > >> > ? ? ? ?I'm doing a bit of research into mobility models and I'm > >> > currently exploring implementation language choices for the simulator > >> > (*snip*) > >> > The simulation algorithm requires expressing > >> > the node's mobility so that it is "stateless". The mobility model > >> > algorithm's type should be something like: > >> > mobility_model :: WorldState -> NodeState -> OtherInput -> (Action, > >> > NodeState) > >> > > >> > where Action can alter WorldState and the second NodeState is an > >> > altered input NodeState. I perform a form of speculative execution on > >> > mobility_model so sometimes I need to backtrack to a previous world > >> > and node state. This is all fairly simple stuff, and was just an > >> > introduction. What I do now is store an enum in NodeState and > >> > implement mobility_model as one big case statement. Yes, this is very > >> > imperative of me, I know. What I'd like to do is to express > >> > mobility_model, so that the code would look like: > >> > > >> > mobility_model world node input = do > >> > ? ?do_calculus > >> > ? ?emit_action > >> > ? ?if something > >> > ? ? ?then emit_action > >> > ? ? ?else emit_action > >> > ? ?do_calculus > >> > ? ?emit_action > >> > ? ?mobility_model world node input > >> > >> Hi, > >> > >> It seems you can use > >> http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control- > >>Mon ad-State-Lazy.html Just have a look at the exemple : > >> > >> ?tick :: State Int Int > >> ?tick = do n <- get > >> ? ? ? ? ? ?put (n+1) > >> ? ? ? ? ? ?return n > >> > >> your code would become something like > >> mobility_model :: OtherInput -> State (WorldState,NodeState) () > >> mobility_model input = do > >> ? world <- gets fst > >> ? node <- gets snd > >> ? .... > >> ? let (world',node') = ... > >> ? put (world',node') > > > > ok, that solves part of the problem. what this doesn't solve is that > > somewhere between these lines (which corespond to emit_action in my > > example) > > > >> ? let (world',node') = ... > >> ? put (world',node') > > > > I need to return a value and an Action and NodeState to the simulation > > algorithm. and then, after the simulation algorithm calculates a new > > WorldState it will want the mobility_model to where it left off, but with > > a new WorldState. > > > > I hope I'm clear about what I wish to achieve: each emit_action should > > return a value (Action, NodeState) and maybe a function > > mobility_model_cont which I then could call with the new WorldState to > > continue from where emit_action returned. > > I'm not entirely sure ... but I think it doesn't matter that much :) > Here is why. > > This was just an exemple : > mobility_model :: OtherInput -> State (WorldState,NodeState) () > > You could also have > mobility_model :: OtherInput -> NodeState -> State WorldState > (NodeState,Action) > or whatever. > > In fact, the State monad makes it easy to thread (in this context, it > means 'pass around') an argument to many functions, providing a nice > syntax reminiscent of imperative language. But it lets you completely > free of what is passed around. It depends on what you want to be > explicitely passed by argument, and what you want to pass in the state > of the monad (that is, what you want to appear, inside the monad only, > as some global variable). > > So in your code, if you often need to pass a WorldState to a function > which should return a modified WorldState, it makes sense to put > WorldState inside the state monad. But, maybe, if there is just a few > functions which act on NodeState, it has not to be part of the state > carried by the state monad. > > I'm not entirely sure of what is a problem to you : is it the use of > the State monad, or something else ? > If it can help you to formulate your question you can post some code > (or past it to http://hpaste.org/)... Threading the state is not the problem. Maybe this will help: what I have now: fsm world state = case state of first -> do_stuff_one (move_up, succ state) second -> do_stuff_two (move_left, succ state) third -> do_stuff_three (move_right, first) what I'd want to have is to say: fsm world state = do do_stuff_one yield move_up do_stuff_two yield move_left do_stuff_three yield move_right fsm world state and have it "translated" to: fsm world state = do_stuff_one (move_up, \world' state' -> do_stuff_two (move_left, \world'' state'' -> do_stuff_three (move_right, fsm world'' state'') Thanks! Marcin Kosiba -------------- 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/20090313/1b7c15d9/attachment.bin From g9ks157k at acme.softbase.org Fri Mar 13 04:37:48 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Mar 13 04:25:59 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <20090313082105.GA14652@flit> References: <2816604275516129323@unknownmsgid> <57526e770903122001w4093677ex244db35198686852@mail.gmail.com> <20090313082105.GA14652@flit> Message-ID: <200903130937.49012.g9ks157k@acme.softbase.org> Am Freitag, 13. M?rz 2009 09:21 schrieb Roman Cheplyaka: > * Alexander Dunlap [2009-03-12 20:01:57-0700] > > > Also, a lot of functions just take > > Integers so it would be more of a pain to use. > > AFAIK there are very few fuctions that take Integers. Many functions > take instances of Integral, but it's not a problem to make your own type > such an instance. I?d say that it is a problem. Class instances should satisfy certain laws. (Although these laws are often not stated explicitely, they are assumed to hold by users of the class and they should hold to make the instance sensible.) In the case of Num, I would expect num + negate num to equal num. This wouldn?t hold for a Natural instance of Num. Best wishes, Wolfgang From noteed at gmail.com Fri Mar 13 05:09:13 2009 From: noteed at gmail.com (minh thu) Date: Fri Mar 13 04:57:22 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions In-Reply-To: <200903130934.28466.marcin.kosiba@gmail.com> References: <200903130934.28466.marcin.kosiba@gmail.com> Message-ID: <40a414c20903130209pa3e5bc1r98d3f3b61f2661e0@mail.gmail.com> 2009/3/13 Marcin Kosiba : > On Friday 13 March 2009, you wrote: >> 2009/3/13 Marcin Kosiba : >> > On Thursday 12 March 2009, you wrote: >> >> 2009/3/12 Marcin Kosiba : >> >> > Hi, >> >> > I'm doing a bit of research into mobility models and I'm >> >> > currently exploring implementation language choices for the simulator >> >> > (*snip*) >> >> > The simulation algorithm requires expressing >> >> > the node's mobility so that it is "stateless". The mobility model >> >> > algorithm's type should be something like: >> >> > mobility_model :: WorldState -> NodeState -> OtherInput -> (Action, >> >> > NodeState) >> >> > >> >> > where Action can alter WorldState and the second NodeState is an >> >> > altered input NodeState. I perform a form of speculative execution on >> >> > mobility_model so sometimes I need to backtrack to a previous world >> >> > and node state. This is all fairly simple stuff, and was just an >> >> > introduction. What I do now is store an enum in NodeState and >> >> > implement mobility_model as one big case statement. Yes, this is very >> >> > imperative of me, I know. What I'd like to do is to express >> >> > mobility_model, so that the code would look like: >> >> > >> >> > mobility_model world node input = do >> >> > do_calculus >> >> > emit_action >> >> > if something >> >> > then emit_action >> >> > else emit_action >> >> > do_calculus >> >> > emit_action >> >> > mobility_model world node input >> >> >> >> Hi, >> >> >> >> It seems you can use >> >> http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control- >> >>Mon ad-State-Lazy.html Just have a look at the exemple : >> >> >> >> tick :: State Int Int >> >> tick = do n <- get >> >> put (n+1) >> >> return n >> >> >> >> your code would become something like >> >> mobility_model :: OtherInput -> State (WorldState,NodeState) () >> >> mobility_model input = do >> >> world <- gets fst >> >> node <- gets snd >> >> .... >> >> let (world',node') = ... >> >> put (world',node') >> > >> > ok, that solves part of the problem. what this doesn't solve is that >> > somewhere between these lines (which corespond to emit_action in my >> > example) >> > >> >> let (world',node') = ... >> >> put (world',node') >> > >> > I need to return a value and an Action and NodeState to the simulation >> > algorithm. and then, after the simulation algorithm calculates a new >> > WorldState it will want the mobility_model to where it left off, but with >> > a new WorldState. >> > >> > I hope I'm clear about what I wish to achieve: each emit_action should >> > return a value (Action, NodeState) and maybe a function >> > mobility_model_cont which I then could call with the new WorldState to >> > continue from where emit_action returned. >> >> I'm not entirely sure ... but I think it doesn't matter that much :) >> Here is why. >> >> This was just an exemple : >> mobility_model :: OtherInput -> State (WorldState,NodeState) () >> >> You could also have >> mobility_model :: OtherInput -> NodeState -> State WorldState >> (NodeState,Action) >> or whatever. >> >> In fact, the State monad makes it easy to thread (in this context, it >> means 'pass around') an argument to many functions, providing a nice >> syntax reminiscent of imperative language. But it lets you completely >> free of what is passed around. It depends on what you want to be >> explicitely passed by argument, and what you want to pass in the state >> of the monad (that is, what you want to appear, inside the monad only, >> as some global variable). >> >> So in your code, if you often need to pass a WorldState to a function >> which should return a modified WorldState, it makes sense to put >> WorldState inside the state monad. But, maybe, if there is just a few >> functions which act on NodeState, it has not to be part of the state >> carried by the state monad. >> >> I'm not entirely sure of what is a problem to you : is it the use of >> the State monad, or something else ? >> If it can help you to formulate your question you can post some code >> (or past it to http://hpaste.org/)... > > Threading the state is not the problem. Maybe this will help: > what I have now: > > fsm world state = case state of > first -> > do_stuff_one > (move_up, succ state) > second -> > do_stuff_two > (move_left, succ state) > third -> > do_stuff_three > (move_right, first) > > what I'd want to have is to say: > fsm world state = do > do_stuff_one > yield move_up > do_stuff_two > yield move_left > do_stuff_three > yield move_right > fsm world state > > and have it "translated" to: > > fsm world state = > do_stuff_one > (move_up, \world' state' -> > do_stuff_two > (move_left, \world'' state'' -> > do_stuff_three > (move_right, fsm world'' state'') > Sorry, I never used continuations or coroutines in Haskell. But, if your goal is to be less imperative, I'm not sure using 'yield' is what you want. If what you do is well expressed by a fsm, maybe you should stick to it. Thu From jules at jellybean.co.uk Fri Mar 13 06:37:33 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Mar 13 06:25:46 2009 Subject: [Haskell-cafe] Does anybody dislike implicit params as much as I do? In-Reply-To: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> References: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> Message-ID: <49BA376D.8000803@jellybean.co.uk> Thomas Hartman wrote: > http://blog.patch-tag.com/2009/03/09/implicitparams-are-evil-thoughts-on-adapting-gitit/ > > I understand there are arguments for using IPs, but after this > experience, the ImplicitParams extension is a "code smell" for me. It's not just you. Implicit parameters are a scourge on the language. I think there are also some subtle annoyances with how they make apparently 'safe' program rearrangements unsafe, by pushing around "let ?foo = bar in ..." bindings. From martin.hofmann at uni-bamberg.de Fri Mar 13 07:03:44 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Fri Mar 13 06:51:29 2009 Subject: [Haskell-cafe] Re: Typing Dynamic Typing [Was: Dynamically typing TH.Exp at runtime] In-Reply-To: <20090313043309.79F2DABC6@Adric.metnet.fnmoc.navy.mil> References: <20090313043309.79F2DABC6@Adric.metnet.fnmoc.navy.mil> Message-ID: <1236942224.6147.19.camel@ios.cogsys.wiai.uni-bamberg.de> Thanks a lot for the detailed answer. I must admit, I haven't understood it completely yet, so please excuse for probably naive questions. As far as I see from the language defined in Incope.hs, there is only support for the defined primitive functions (add, mult, if_, etc.). Using additional functions, I would need to extend it, right? Also considering Haskell as underlying language using TH as AST is not possible, because it is polymorphic? Thanks, Martin From agocorona at gmail.com Fri Mar 13 07:09:51 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri Mar 13 06:58:01 2009 Subject: Fwd: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: References: <20090303041311.GL27223@knuth.cs.hmc.edu> <20090312212346.GA7447@smuckers.uwaterloo.ca> Message-ID: ---------- Forwarded message ---------- From: Alberto G. Corona Date: 2009/3/13 Subject: Re: [Haskell-cafe] DSLs with {in,}equalities To: Adam Vogt You need an expression evaluator: with (+) (Const a) (Const b)= Const (a+b) (*) (Const a) (Const b)= Const (a*b) eval :: Exp -> Integer eval (Const i)= i eval ( Plus e1 e2)= eval e1 + eval e2 .. eval( Mul .... and instance Ord Expr where (<) expr1 expr2 = eval expr1 < eval expr2 by the way: simplify expr= Const (eval expr) ...................................... 2009/3/13 Alberto G. Corona > Sorry(Const a) < (Const b) = a < b > > also > > (*) (Const a) (Const b)= Const (a*b) > > > 2009/3/13 Alberto G. Corona > > >(<) :: (Ord a) => a -> a -> Bool >> >> what?s the problem? >> >> make your Expr an instance of Ord. >> >> By the way >> >> > instance Num Expr where >> > fromInterger = Const >> > (+) = Plus >> > (*) = Times >> >> does not work. you have not defined (+) and (*) for Const Integer. >> >> (+) (Const a) (Const b)= Const (a+b) >> >> With this you have an evaluator. >> >> In the same way: >> >> (Const a) < (Const b) = Const (a < b) >> >> >> >> >> 2009/3/12 Adam Vogt >> >> This seems to be in ghc for those reasons: >>> http://www.haskell.org/haskellwiki/Quasiquotation >>> >>> * On Monday, March 02 2009, Andrew Hunter wrote: >>> >>> >Several times now I've had to define an EDSL for working with >>> >(vaguely) numeric expressions. For stuff like 2*X+Y, this is easy, >>> >looking pretty much like: >>> > >>> >> data Expr = Const Integer | Plus Expr Expr | Times Expr Expr >>> >> >>> >> instance Num Expr where >>> >> fromInterger = Const >>> >> (+) = Plus >>> >> (*) = Times >>> > >>> >&c. This lets me get a perfectly nice AST, which is what I want. >>> >When I want to be able to express and work with inequalities and >>> >equalities, this breaks. Suppose I want to write 2*X + Y < 3. I >>> >either have to: >>> > >>> >a) Hide Prelude.(<) and define a simple < that builds the AST term I >>> want. >>> >b) Come up with a new symbol for it that doesn't look totally awful. >>> > >>> >Neither of these work decently well. Hiding Eq and Ord operators, >>> >which is what I effectively have to do for a), is pretty much a >>> >nonstarter--we'll have to use them too much for that to be practical. >>> > >>> >On the other hand, b) works...but is about as ugly as it gets. We >>> >have lots and lots of symbols that are already taken for important >>> >purposes that are syntactically "near" <,<=,==, and the like: << and >>> >>> and >>= for monads, >>> for arrows, etc. There...are not good >>> >choices that I know of for the symbols that don't defeat the purpose >>> >of making a nice clean EDSL for expressions; I might as well use 3*X + >>> >Y `lessthan` 3, which is just not cool. >>> > >>> >Does anyone know of a good solution, here? Are there good >>> >substitutions for all the six operators that are important >>> >(<,>,>=,<=,==,/=), that are close enough to be pretty-looking but not >>> >used for other important modules? >>> > >>> >Better yet, though a little harder, is there a nice type trick I'm not >>> >thinking of? This works for Num methods but not for Ord methods >>> >because: >>> > >>> >(+) :: (Num a) => a -> a -> a >>> >(<) :: (Ord a) => a -> a -> Bool >>> > >>> >i.e. the return type of comparisons is totally fixed. I don't suppose >>> >there's a good way to...well, I don't know what the *right* answer is, >>> >but maybe define a new typeclass with a more flexible type for < that >>> >lets both standard types return Bool and my expressions return Expr? >>> >Any good solution would be appreciated. >>> > >>> >Thanks, >>> >AHH >>> >_______________________________________________ >>> >Haskell-Cafe mailing list >>> >Haskell-Cafe@haskell.org >>> >http://www.haskell.org/mailman/listinfo/haskell-cafe >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/4e5aacb8/attachment.htm From ganesh.sittampalam at credit-suisse.com Fri Mar 13 07:15:23 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Fri Mar 13 07:04:19 2009 Subject: [Haskell-cafe] Does anybody dislike implicit params as much asI do? In-Reply-To: <49BA376D.8000803@jellybean.co.uk> References: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> <49BA376D.8000803@jellybean.co.uk> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABA90E@ELON17P32001A.csfb.cs-group.com> Jules Bean wrote: > Thomas Hartman wrote: >> http://blog.patch-tag.com/2009/03/09/implicitparams-are-evil-thoughts- >> on-adapting-gitit/ >> >> I understand there are arguments for using IPs, but after this >> experience, the ImplicitParams extension is a "code smell" for me. > > It's not just you. Implicit parameters are a scourge on the language. I think they have a useful place in propagating semi-global configuration information without imposing huge syntactic overhead. I think using them like in the code referred to in the URL above, where their values are frequently changed down the call stack, is dangerous. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From barsoap at web.de Fri Mar 13 07:29:25 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Mar 13 07:18:00 2009 Subject: [Haskell-cafe] Re: Against cuteness References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> <7b501d5c0903121922j627ded44wbaa17a5ee7885046@mail.gmail.com> Message-ID: <20090313122925.7735d779@solaris> Benjamin L.Russell wrote: > balance > Stop right there. Any further word about what the Taiji means would only make you look even more clueless. Take a scale if you want a symbol for balance[1]. OTOH, laziness(yin) and strictness(yang) make a far better pair of unified opposites than the schemeish eval and apply (which's outer essences are both yang, changing to yin only by means of what they execute[2]). Still, you wouldn't represent the Maybe monad with >>=, now would you? Instantiating a symbol for a general principle to whatever you like constitutes pocketing. Anyway, I think it's too late for logo submissions. Personally, I just love the lambda-bind, it's truly haskellish, sleek, appropriately cryptic and lends itself well to ascii-art. What about a chicken holding a curry dispenser? In any case, I don't think a sloth is a bad choice as a mascot: It's most likely the most efficient animal on earth, and seeing it, you're bound to be mystified how it manages to get anything done. Water overcomes stone: Shapeless, it requires no opening: The benefit of taking no action. Yet benefit without action, And experience without abstraction, Are practiced by very few. [1] Or the vector equilibrium (note the word "libra" in there): http://www.angelfire.com/mt/marksomers/91.html It's also the reason why cutting a pizza into anything else but six pieces is an abomination to geometry.[2] [2] While I'm at it: The tips of the pinky, index finger, and thumb form a tetrahedron together with the center of mass in your palm while holding such a piece. What do you make of that? [3] And are therefore better explained in terms of hodge and podge -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From agocorona at gmail.com Fri Mar 13 07:36:19 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri Mar 13 07:24:30 2009 Subject: [Haskell-cafe] DSLs with {in,}equalities In-Reply-To: References: <20090303041311.GL27223@knuth.cs.hmc.edu> <20090312212346.GA7447@smuckers.uwaterloo.ca> Message-ID: even at the level of expressions you can be sure that inequalities hold. So you can create an instance of Ord. for example: (Sum x z) < y | x== y && z>0 = True | .... here x and y can be expressions and == can have its own rules with this you can compute symbolically, because you don?t need to reduce the expression to a numerical value. It?s a matter of finding rules. 2009/3/13 Alberto G. Corona > >(<) :: (Ord a) => a -> a -> Bool > > what?s the problem? > > make your Expr an instance of Ord. > > By the way > > > instance Num Expr where > > fromInterger = Const > > (+) = Plus > > (*) = Times > > does not work. you have not defined (+) and (*) for Const Integer. > > (+) (Const a) (Const b)= Const (a+b) > > With this you have an evaluator. > > In the same way: > > (Const a) < (Const b) = Const (a < b) > > > > > 2009/3/12 Adam Vogt > > This seems to be in ghc for those reasons: >> http://www.haskell.org/haskellwiki/Quasiquotation >> >> * On Monday, March 02 2009, Andrew Hunter wrote: >> >> >Several times now I've had to define an EDSL for working with >> >(vaguely) numeric expressions. For stuff like 2*X+Y, this is easy, >> >looking pretty much like: >> > >> >> data Expr = Const Integer | Plus Expr Expr | Times Expr Expr >> >> >> >> instance Num Expr where >> >> fromInterger = Const >> >> (+) = Plus >> >> (*) = Times >> > >> >&c. This lets me get a perfectly nice AST, which is what I want. >> >When I want to be able to express and work with inequalities and >> >equalities, this breaks. Suppose I want to write 2*X + Y < 3. I >> >either have to: >> > >> >a) Hide Prelude.(<) and define a simple < that builds the AST term I >> want. >> >b) Come up with a new symbol for it that doesn't look totally awful. >> > >> >Neither of these work decently well. Hiding Eq and Ord operators, >> >which is what I effectively have to do for a), is pretty much a >> >nonstarter--we'll have to use them too much for that to be practical. >> > >> >On the other hand, b) works...but is about as ugly as it gets. We >> >have lots and lots of symbols that are already taken for important >> >purposes that are syntactically "near" <,<=,==, and the like: << and >> >>> and >>= for monads, >>> for arrows, etc. There...are not good >> >choices that I know of for the symbols that don't defeat the purpose >> >of making a nice clean EDSL for expressions; I might as well use 3*X + >> >Y `lessthan` 3, which is just not cool. >> > >> >Does anyone know of a good solution, here? Are there good >> >substitutions for all the six operators that are important >> >(<,>,>=,<=,==,/=), that are close enough to be pretty-looking but not >> >used for other important modules? >> > >> >Better yet, though a little harder, is there a nice type trick I'm not >> >thinking of? This works for Num methods but not for Ord methods >> >because: >> > >> >(+) :: (Num a) => a -> a -> a >> >(<) :: (Ord a) => a -> a -> Bool >> > >> >i.e. the return type of comparisons is totally fixed. I don't suppose >> >there's a good way to...well, I don't know what the *right* answer is, >> >but maybe define a new typeclass with a more flexible type for < that >> >lets both standard types return Bool and my expressions return Expr? >> >Any good solution would be appreciated. >> > >> >Thanks, >> >AHH >> >_______________________________________________ >> >Haskell-Cafe mailing list >> >Haskell-Cafe@haskell.org >> >http://www.haskell.org/mailman/listinfo/haskell-cafe >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/3f8e5da1/attachment-0001.htm From dev at mobileink.com Fri Mar 13 08:26:20 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Fri Mar 13 08:14:29 2009 Subject: [Haskell-cafe] Re: Against cuteness In-Reply-To: <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> Message-ID: <75cc17ac0903130526h372ceee3q6aef62fc4bfaf128@mail.gmail.com> On Thu, Mar 12, 2009 at 9:17 PM, Benjamin L. Russell wrote: > On Thu, 12 Mar 2009 09:11:15 -0500, Gregg Reynolds > wrote: > >>I don't think so. ?Bad design will lose them (and many others), but >>good design and cuteness are two different things. > > It's also possible for a good design to be cute, too. > De cutibus non est disputandem. Personally I think something interesting could be done with Thoth (nice open svg image at http://en.wikipedia.org/wiki/Thoth): God of reading/writing, math. When conflated with Hermes, also of boundaries, thieves and scoundrels, etc. Then there's Haskell B. Curry himself; notice the resemblance (http://www.haskell.org/bio.html) with J. R. "Bob" Dobbs (http://en.wikipedia.org/wiki/J._R._%22Bob%22_Dobbs). An artist could "comicize" an image of Curry. Then it's only a short step to actual cultdom - why stop with a mere web community when you can legally establish a religious cult and actually ordain Ministers? (http://www.subgenius.com/scatalog/membership.htm). -g From sjurberengal at gmail.com Fri Mar 13 08:29:43 2009 From: sjurberengal at gmail.com (Sjur =?iso-8859-1?q?Gj=F8stein_Karevoll?=) Date: Fri Mar 13 08:18:33 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: References: Message-ID: <200903131329.44161.sjurberengal@gmail.com> I've unconciously conditioned myself to think about rabbits with nukes each time I think about monads. "Warm fuzzy things" "launching the missiles" indeed. On Friday 13 March 2009 02.38.29 Richard O'Keefe wrote: > On 12 Mar 2009, at 11:08 pm, Satnam Singh wrote: > > I agree that looking for a mascot that is inspired by "laziness" is > > a bad idea from a P.R. perspective (I am tired of people walking out > > the room when I give Haskell talks to general audiences and explain > > lazy evaluation). > > Perhaps we should call it "Just-In-Time evaluation. > > As for mascots, let's take a photo of Simon Peyton Jones, > shrink him to hobbit size, give him furry feet, and announce > that "here is one of the warm fuzzy things we have in mind > when we use monads". (:-) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjur Gj?stein Karevoll sjurberengal@gmail.com From martijn at van.steenbergen.nl Fri Mar 13 08:30:27 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Mar 13 08:18:46 2009 Subject: [Haskell-cafe] Applicative combinators from Parsec Message-ID: <49BA51E3.6020904@van.steenbergen.nl> Hello, Looking at Parsec 3 I see: > chainr1 :: (Stream s m t) => ParsecT s u m a -> > ParsecT s u m (a -> a -> a) -> ParsecT s u m a > chainr1 p op = scan where > scan = do x <- p; rest x > rest x = (do f <- op; y <- scan; return (f x y)) <|> return x > But if I remove the type signature and let GHC infer it for me, I get a much more generic type: > chainr1 :: (Alternative m, Monad m) => m a -> m (a -> a -> a) -> m a But we don't really need m to be a monad since we're only doing applicative operations, so after some rewriting we get: > chainr1 :: Alternative f => f a -> f (a -> a -> a) -> f a > chainr1 p op = scan where > scan = flip id <$> p <*> rest > rest = (flip <$> op <*> scan) <|> pure id Would it be a good idea to: 1) make the Parsec combinators as generic as possible and 2) move the really generic applicative ones to Control.Applicative? Thanks, Martijn. From DekuDekuplex at Yahoo.com Fri Mar 13 09:23:46 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Mar 13 09:12:16 2009 Subject: [Haskell-cafe] Re: Against cuteness References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> <7b501d5c0903121922j627ded44wbaa17a5ee7885046@mail.gmail.com> <20090313122925.7735d779@solaris> Message-ID: <46nkr4lmln0ks2vvom336r1kk136mgdd1m@4ax.com> On Fri, 13 Mar 2009 12:29:25 +0100, Achim Schneider wrote: >Benjamin L.Russell wrote: > >> balance >> >Stop right there. Any further word about what the Taiji means would >only make you look even more clueless. Take a scale if you want a >symbol for balance[1]. Granted, I'm no expert on Taoism, so I am not qualified to comment on the meaning of the Taiji. Rather, I was merely trying to assign meaning to a symbol that resembled the Taiji, but not to interpret the Taiji itself. >OTOH, laziness(yin) and strictness(yang) make a far better pair of >unified opposites than the schemeish eval and apply (which's outer >essences are both yang, changing to yin only by means of what they >execute[2]). Indeed. But strictness would not characterize Haskell, would it? >Still, you wouldn't represent the Maybe monad with >>=, now would you? >Instantiating a symbol for a general principle to whatever you like >constitutes pocketing. Indeed. The symbol would need to be modified and distinguished appropriately. >Anyway, I think it's too late for logo submissions. Personally, I just >love the lambda-bind, it's truly haskellish, sleek, appropriately >cryptic and lends itself well to ascii-art. Agreed. >What about a chicken holding a curry dispenser? In any case, I don't >think a sloth is a bad choice as a mascot: It's most likely the most >efficient animal on earth, and seeing it, you're bound to be mystified >how it manages to get anything done. It's indeed efficient, but also slow; while Schemers are accused of knowing the value of everything, but the cost of nothing, a sloth mascot could cause Haskellers to become accused of knowing the efficiency of everything, but the speed of nothing, no? >Water overcomes stone: >Shapeless, it requires no opening: >The benefit of taking no action. > >Yet benefit without action, >And experience without abstraction, >Are practiced by very few. Nice poem. Did you write it yourself, or can you document the source? -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From asandroq at gmail.com Fri Mar 13 09:38:27 2009 From: asandroq at gmail.com (Alex Queiroz) Date: Fri Mar 13 09:26:36 2009 Subject: [Haskell-cafe] Re: Against cuteness In-Reply-To: <46nkr4lmln0ks2vvom336r1kk136mgdd1m@4ax.com> References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> <7b501d5c0903121922j627ded44wbaa17a5ee7885046@mail.gmail.com> <20090313122925.7735d779@solaris> <46nkr4lmln0ks2vvom336r1kk136mgdd1m@4ax.com> Message-ID: <54e12800903130638m1e3f8deepfcb26b868c9604ba@mail.gmail.com> Hallo, On Fri, Mar 13, 2009 at 1:23 PM, Benjamin L. Russell wrote: > On Fri, 13 Mar 2009 12:29:25 +0100, Achim Schneider > >>Water overcomes stone: >>Shapeless, it requires no opening: >>The benefit of taking no action. >> >>Yet benefit without action, >>And experience without abstraction, >>Are practiced by very few. > > Nice poem. Did you write it yourself, or can you document the source? > If I remember correctly, this is from the Daodejing. Cheers, -- -alex http://www.ventonegro.org/ From andy at adradh.org.uk Fri Mar 13 09:57:20 2009 From: andy at adradh.org.uk (andy morris) Date: Fri Mar 13 09:45:30 2009 Subject: [Haskell-cafe] Applicative combinators from Parsec In-Reply-To: <49BA51E3.6020904@van.steenbergen.nl> References: <49BA51E3.6020904@van.steenbergen.nl> Message-ID: 2009/3/13 Martijn van Steenbergen : > Hello, > > Looking at Parsec 3 I see: > >> chainr1 :: (Stream s m t) => ParsecT s u m a -> >> ? ? ? ? ? ParsecT s u m (a -> a -> a) -> ParsecT s u m a >> chainr1 p op = scan where >> ?scan = do x <- p; rest x >> ?rest x = (do f <- op; y <- scan; return (f x y)) <|> return x >> > > But if I remove the type signature and let GHC infer it for me, I get a much > more generic type: > >> chainr1 :: (Alternative m, Monad m) => m a -> m (a -> a -> a) -> m a > > But we don't really need m to be a monad since we're only doing applicative > operations, so after some rewriting we get: > >> chainr1 :: Alternative f => f a -> f (a -> a -> a) -> f a >> chainr1 p op = scan where >> ?scan = flip id <$> p <*> rest >> ?rest = (flip <$> op <*> scan) <|> pure id > > Would it be a good idea to: > 1) make the Parsec combinators as generic as possible and > 2) move the really generic applicative ones to Control.Applicative? > > Thanks, > > Martijn. This reminds me of something similar I find a bit annoying: There are some functions like (<|>) which are defined separately in Text.Parsec and Control.Applicative, meaning that you have to hide one of the sets. Would it be better perhaps to just have Parsec reexport the existing functions from Applicative, or something like that? (Currently the functions in Parsec have the more specific type as Martijn says, but if they're generalised then I don't really see why they need to be duplicated.) From manlio_perillo at libero.it Fri Mar 13 10:04:45 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 09:53:10 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090310194030.GB1077@whirlpool.galois.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> Message-ID: <49BA67FD.9080303@libero.it> Don Stewart ha scritto: > [...] >> I think uvector only works with certain types that can be >> unboxed, while storablevector works with all types that >> instantiate Foreign.Storable.Storable. I don't know about >> vector. From the description of vector, I have the > One of the nice feature of uvector is the support for UArr (a :*: b). An UArr (a :*: b) can be easily (with fstU and sndU) transformed in UArr a and UArr b. uvector package also suppors Complex and Rational, however the support for these type is "hard written", using a UAProd class, and requires some boiler plate code (IMHO). I find StorableVector implementation much more simple; I would like to see it in the Haskell Platform. As for Data.Parallel, uvector and vector, it seems there is some code duplication. Both Data.Parallel and uvector, make us of a strict pair type. Such a type is also implemented in the strict package [1]. The authors are the same, so I don't understand the reason of code replication. There is also replication in the definition of the Stream data type. [1] there seems to be an error in the documentation: http://hackage.haskell.org/packages/archive/strict/0.3.2/doc/html/Data-Strict-Tuple.html In the description, there is: "Same as regular Haskell pairs, but (x :*: _|_) = (_|_ :*: y) = _|_" but in the synopsis, the data constructor is :!:, not :*:. Regards Manlio Perillo From vandijk.roel at gmail.com Fri Mar 13 10:06:58 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Fri Mar 13 09:55:08 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot In-Reply-To: <200903131329.44161.sjurberengal@gmail.com> References: <200903131329.44161.sjurberengal@gmail.com> Message-ID: What about the "Rabbit of Caerbannog"[1]. Looks cute on first sight, but upon further investigation turns out to be a vicious killer. Useful to quench any rumors of Haskell being a toy language. "You just need to look a bit closer". [1] http://en.wikipedia.org/wiki/Rabbit_of_Caerbannog On Fri, Mar 13, 2009 at 1:29 PM, Sjur Gj?stein Karevoll wrote: > I've unconciously conditioned myself to think about rabbits with nukes each > time I think about monads. "Warm fuzzy things" "launching the missiles" > indeed. From martijn at van.steenbergen.nl Fri Mar 13 10:18:15 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Mar 13 10:06:25 2009 Subject: [Haskell-cafe] Pointless functors Message-ID: <49BA6B27.7000504@van.steenbergen.nl> Bonjour caf?, Are there any functors f for which no point/pure/return :: a -> f a exists? Thank you, Martijn. From manlio_perillo at libero.it Fri Mar 13 10:21:41 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 10:10:02 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090310214835.GH1077@whirlpool.galois.com> References: <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> <20090310211207.GF1077@whirlpool.galois.com> <732086550.20090311001540@gmail.com> <20090310214835.GH1077@whirlpool.galois.com> Message-ID: <49BA6BF5.8090906@libero.it> Don Stewart ha scritto: > bulat.ziganshin: >> Hello Don, >> >> Wednesday, March 11, 2009, 12:12:07 AM, you wrote: >> >>> Right, so my point stands: there's no difference now. If you can write a >>> Storable instance, you can write a UA et al instance. >> yes, if there is some class provided for this and not just hard-coded >> 4 or so base types > > That's right. For example (supporting even pairs): > > instance (RealFloat a, UA a) => UA (Complex a) where > > newtype UArr (Complex a) = UAComplex (UArr (a :*: a)) > newtype MUArr (Complex a) s = MUAComplex (MUArr (a :*: a) s) > You also have to add instance for UIO: instance (RealFloat a, UIO a) => UIO (Complex a) where hPutU h (UAComplex arr) = hPutU h arr hGetU h = do arr <- hGetU h return (UAComplex arr) With Storable, this should not be required; you just have to write an instance for the Storable class. Regards Manlio From perikov at gmail.com Fri Mar 13 10:22:24 2009 From: perikov at gmail.com (Pavel Perikov) Date: Fri Mar 13 10:10:39 2009 Subject: [Haskell-cafe] Vim support for cabal Message-ID: Hi caf? ! I googled for some kind of vim support for cabal but found nothing. I mean syntax highlighting of .cabal and probably integration with haskellmode. Did anyone hear about such thing? Pavel From barsoap at web.de Fri Mar 13 10:22:16 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Mar 13 10:10:53 2009 Subject: [Haskell-cafe] Re: Against cuteness References: <75cc17ac0903110317t34c27e64q13e1ba1b468bf7b@mail.gmail.com> <75cc17ac0903120711i6131103byf971272e88a85577@mail.gmail.com> <2agjr453fub923lj4h30ikg2o85q0ljphe@4ax.com> <7b501d5c0903121922j627ded44wbaa17a5ee7885046@mail.gmail.com> <20090313122925.7735d779@solaris> <46nkr4lmln0ks2vvom336r1kk136mgdd1m@4ax.com> Message-ID: <20090313152216.7907bf90@solaris> Benjamin L.Russell wrote: > >OTOH, laziness(yin) and strictness(yang) make a far better pair of > >unified opposites than the schemeish eval and apply (which's outer > >essences are both yang, changing to yin only by means of what they > >execute[2]). > > Indeed. But strictness would not characterize Haskell, would it? > Not by itself, no. But Haskell, as a language that's neither strict nor lazy, but non-strict (and can therefore combine eagerness and laziness) is closer to the Tao of execution than any "purely strict" or "purely lazy" language. One, after all, cannot be without the other: Both are not separate, but distinguished only by our perception. > >What about a chicken holding a curry dispenser? In any case, I don't > >think a sloth is a bad choice as a mascot: It's most likely the most > >efficient animal on earth, and seeing it, you're bound to be > >mystified how it manages to get anything done. > > It's indeed efficient, but also slow; while Schemers are accused of > knowing the value of everything, but the cost of nothing, a sloth > mascot could cause Haskellers to become accused of knowing the > efficiency of everything, but the speed of nothing, no? > I'd say we know the necessity of everything, but the schedule of nothing. ...the point I'm trying to make here is that the appearance of swiftness is not everything: A tight loop executing nop's may seem busy, but won't tell you much interesting stuff. Imagine a cute sloth peeking out of a PC case, together with "Lazy bum is executeing ur prugram, but only half of it" > >Water overcomes stone: > >Shapeless, it requires no opening: > >The benefit of taking no action. > > > >Yet benefit without action, > >And experience without abstraction, > >Are practiced by very few. > > Nice poem. Did you write it yourself, or can you document the source? > It's out of the Tao te Ching, by, allegedly, Lao Tzu. It hints at Wuwei[1], or, from another angle, Kant's Categorical Imperative. [1]http://en.wikipedia.org/wiki/Wu_wei -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From barsoap at web.de Fri Mar 13 10:24:57 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Mar 13 10:18:17 2009 Subject: [Haskell-cafe] Re: Sugestion for a Haskell mascot References: <200903131329.44161.sjurberengal@gmail.com> Message-ID: <20090313152457.75a2b6aa@solaris> Roel van Dijk wrote: > What about the "Rabbit of Caerbannog"[1]. Looks cute on first sight, > but upon further investigation turns out to be a vicious killer. > Useful to quench any rumors of Haskell being a toy language. "You just > need to look a bit closer". > > > [1] http://en.wikipedia.org/wiki/Rabbit_of_Caerbannog > Is that, in some way, connected to those cute christmas critters Erik [afair] thought of that keep creeping the hell out of everyone in Imaginationland? (I guess I watched too much Southpark) -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From ross at soi.city.ac.uk Fri Mar 13 10:32:23 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Mar 13 10:20:34 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <49BA6B27.7000504@van.steenbergen.nl> References: <49BA6B27.7000504@van.steenbergen.nl> Message-ID: <20090313143223.GA4824@soi.city.ac.uk> On Fri, Mar 13, 2009 at 03:18:15PM +0100, Martijn van Steenbergen wrote: > Are there any functors f for which no point/pure/return :: a -> f a exists? No. Choose an arbitrary element shape :: f () and define point x = fmap (const x) shape From ekirpichov at gmail.com Fri Mar 13 10:35:31 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri Mar 13 10:23:41 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <20090313143223.GA4824@soi.city.ac.uk> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> Message-ID: <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> 'An arbitrary element' means 'undefined will suffice' point x = fmap (const x) undefined 2009/3/13 Ross Paterson : > On Fri, Mar 13, 2009 at 03:18:15PM +0100, Martijn van Steenbergen wrote: >> Are there any functors f for which no point/pure/return :: a -> f a exists? > > No. ?Choose an arbitrary element shape :: f () and define > > ? ? ? ?point x = fmap (const x) shape > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From manlio_perillo at libero.it Fri Mar 13 10:41:34 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 10:29:59 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <49BA67FD.9080303@libero.it> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <49BA67FD.9080303@libero.it> Message-ID: <49BA709E.7020802@libero.it> Manlio Perillo ha scritto: > [...] > uvector package also suppors Complex and Rational, however the support > for these type is "hard written", using a UAProd class, and requires > some boiler plate code (IMHO). > Correction: UAProd is not a class, sorry. It is the UA constructor overloaded for a:*:b, and Complex and Rational just reuse this specialization. > [...] Manlio From conor at strictlypositive.org Fri Mar 13 11:08:35 2009 From: conor at strictlypositive.org (Conor McBride) Date: Fri Mar 13 10:56:51 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <20090313143223.GA4824@soi.city.ac.uk> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> Message-ID: <1D1613AA-8607-46A3-AB2A-362F5828A83D@strictlypositive.org> On 13 Mar 2009, at 14:32, Ross Paterson wrote: > On Fri, Mar 13, 2009 at 03:18:15PM +0100, Martijn van Steenbergen > wrote: >> Are there any functors f for which no point/pure/return :: a -> f a >> exists? > > No. Choose an arbitrary element shape :: f () and define > > point x = fmap (const x) shape Correspondingly, consider the functor Const Void. Cheers Conor From allbery at ece.cmu.edu Fri Mar 13 11:09:47 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Mar 13 10:57:58 2009 Subject: [Haskell-cafe] Dynamically typing TH.Exp at runtime In-Reply-To: <1236931402.6409.24.camel@ios.cogsys.wiai.uni-bamberg.de> References: <20090312100136.F145C32490C@www.haskell.org> <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> <1236876446.6867.132.camel@ios.cogsys.wiai.uni-bamberg.de> <1236931402.6409.24.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <1768C9DF-FB23-44BD-AD35-C2CC73A95B24@ece.cmu.edu> On 2009 Mar 13, at 4:03, Martin Hofmann wrote: > That's true, inferring the type of a string is not the problem. > However, > I am not only interested in the top-level type, but also in the type > of > any arbitrary subexpression. Consider for example following recursive > definition: I'm pretty sure you can pull a typed AST out of ghc-api and query the type of any node. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/52beb69c/PGP.bin From byorgey at seas.upenn.edu Fri Mar 13 11:10:26 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Fri Mar 13 10:58:35 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <20090313143223.GA4824@soi.city.ac.uk> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> Message-ID: <20090313151026.GA6192@seas.upenn.edu> On Fri, Mar 13, 2009 at 02:32:23PM +0000, Ross Paterson wrote: > On Fri, Mar 13, 2009 at 03:18:15PM +0100, Martijn van Steenbergen wrote: > > Are there any functors f for which no point/pure/return :: a -> f a exists? > > No. Choose an arbitrary element shape :: f () and define > > point x = fmap (const x) shape But since f may be polymorphic in some other types, it may not be possible to choose such an arbitrary shape. For example, ((,) w) is a Functor but it is not possible to define a function point :: a -> (w,a) without (1) using undefined for the value of type w, or (2) putting some sort of constraint on w which lets us choose a canonical value of type w, such as Monoid. -Brent From lists at qseep.net Fri Mar 13 11:10:40 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Fri Mar 13 10:58:51 2009 Subject: [Haskell-cafe] ANNOUNCE: Vintage BASIC 1.0 In-Reply-To: <200903130931.32211.jeltsch@informatik.tu-cottbus.de> References: <670e468e0903122110kf68bf0dt2a00a8a3287c3537@mail.gmail.com> <200903130931.32211.jeltsch@informatik.tu-cottbus.de> Message-ID: <670e468e0903130810k5f233e0bs54cdbffb2bc15af3@mail.gmail.com> On Fri, Mar 13, 2009 at 1:31 AM, Wolfgang Jeltsch < jeltsch@informatik.tu-cottbus.de> wrote: > When running the executable, nothing happens. The executable should show a > usage message instead. Where are the BASIC programs? I think, you have to > grab them from the source. They should be installed, too. > Thanks for your feedback, and for checking out Vintage BASIC! I will add a usage message, as you suggested. Currently the usage is only described in the User's Guide. There are no options; you just give it the name of one or more BASIC source files. (Naturally this extends to doing nothing when supplied with zero source files.) The BASIC games are at http://www.vintage-basic.net/games.html. There is a tarball of all the games (bcg.tar.gz) as well. These are separated from the Vintage BASIC distribution for legal reasons. Vintage BASIC is copyrighted by me under a BSD license. The games were written by many authors and compiled into a book copyrighted by Creative Computing. I have secured permission from the editor to post the games. I do not wish to imply that they are covered by the same license as the interpreter. If anyone has any suggestions as to how to make the process simpler, I'd be happy to hear it. Thanks, Lyle P.S. I need to get my other e-mail account subscribed to this list.... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/178a3af9/attachment.htm From martijn at van.steenbergen.nl Fri Mar 13 11:11:57 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Mar 13 11:00:06 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> Message-ID: <49BA77BD.6000709@van.steenbergen.nl> Eugene Kirpichov wrote: > 'An arbitrary element' means 'undefined will suffice' > > point x = fmap (const x) undefined Prelude> fmap (const True) undefined :: [Bool] *** Exception: Prelude.undefined Or is that not what you mean? Martijn. From byorgey at seas.upenn.edu Fri Mar 13 11:12:18 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Fri Mar 13 11:00:27 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> Message-ID: <20090313151218.GB6192@seas.upenn.edu> On Fri, Mar 13, 2009 at 05:35:31PM +0300, Eugene Kirpichov wrote: > 'An arbitrary element' means 'undefined will suffice' > > point x = fmap (const x) undefined This is false. Prelude> fmap (const 1) [()] [1] Prelude> fmap (const 1) undefined *** Exception: Prelude.undefined -Brent From allbery at ece.cmu.edu Fri Mar 13 11:15:27 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Mar 13 11:03:39 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <200903130925.48311.g9ks157k@acme.softbase.org> References: <000001c9a387$0eab4e70$2c01eb50$@spezzano@chariot.net.au> <7FC20B04-4745-40D9-973C-9CD237BD29AD@ece.cmu.edu> <200903130925.48311.g9ks157k@acme.softbase.org> Message-ID: <80544BD4-B7D5-4043-831C-28EAB5B28E3B@ece.cmu.edu> On 2009 Mar 13, at 4:25, Wolfgang Jeltsch wrote: > Am Freitag, 13. M?rz 2009 04:53 schrieb Brandon S. Allbery KF8NH: >> On 2009 Mar 12, at 22:54, Mark Spezzano wrote: >>> I was wondering what the best way to implement Natural number would >>> be. Is there a package which already does this? >> >> type-level on Hackage. > > I think, the original poster wanted value-level naturals, not type- > level > naturals. My (possibly incorrect) understanding was that value-level naturals required runtime range checks, whereas type-level naturals allowed you to validate them at compile time. I thought I'd mentioned that in my response, contrasting type-level naturals with value-level newtypes and other implementations. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/d772a030/PGP.bin From allbery at ece.cmu.edu Fri Mar 13 11:20:52 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Mar 13 11:09:06 2009 Subject: [Haskell-cafe] Applicative combinators from Parsec In-Reply-To: References: <49BA51E3.6020904@van.steenbergen.nl> Message-ID: <4D26E640-AC99-495D-8ACB-4370CF640D98@ece.cmu.edu> On 2009 Mar 13, at 9:57, andy morris wrote: > (Currently the functions in Parsec have the more specific type as > Martijn says, but if they're generalised then I don't really see why > they need to be duplicated.) Possibly so Parsec has decent performance on Haskell compilers that don't do {-# SPECIALIZE #-}? -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090313/06e4dc7d/PGP.bin From greenrd at greenrd.org Thu Mar 12 22:30:47 2009 From: greenrd at greenrd.org (Robin Green) Date: Fri Mar 13 11:12:21 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> Message-ID: <20090313023047.342695f6@greenrd.org> For most functors, that is equivalent to point x = undefined But by that logic, everything is a member of every typeclass... -- Robin On Fri, 13 Mar 2009 17:35:31 +0300 Eugene Kirpichov wrote: > 'An arbitrary element' means 'undefined will suffice' > > point x = fmap (const x) undefined > > > 2009/3/13 Ross Paterson : > > On Fri, Mar 13, 2009 at 03:18:15PM +0100, Martijn van Steenbergen > > wrote: > >> Are there any functors f for which no point/pure/return :: a -> f > >> a exists? > > > > No. ?Choose an arbitrary element shape :: f () and define > > > > ? ? ? ?point x = fmap (const x) shape > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > From greenrd at greenrd.org Thu Mar 12 22:43:39 2009 From: greenrd at greenrd.org (Robin Green) Date: Fri Mar 13 11:25:13 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <20090313143223.GA4824@soi.city.ac.uk> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> Message-ID: <20090313024339.01aba271@greenrd.org> On Fri, 13 Mar 2009 14:32:23 +0000 Ross Paterson wrote: > On Fri, Mar 13, 2009 at 03:18:15PM +0100, Martijn van Steenbergen > wrote: > > Are there any functors f for which no point/pure/return :: a -> f a > > exists? > > No. Choose an arbitrary element shape :: f () and define > > point x = fmap (const x) shape This suggests a fun way to define a monad for a functor F: -- Does nothing, has no effect, and returns () noOp :: F () noOp = ... instance Monad F where return x = fmap (const x) noOp (<<=) f x = ... I think noOp would be a nice addition to the Monad class, as well. -- Robin From ekirpichov at gmail.com Fri Mar 13 11:45:43 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri Mar 13 11:33:53 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <20090313151218.GB6192@seas.upenn.edu> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> <20090313151218.GB6192@seas.upenn.edu> Message-ID: <5e0214850903130845waeb9396ma7750288f7b0f3a8@mail.gmail.com> Well, yes; then, that means that "an arbitrary element" is also false: you can't just take an arbitrary element and hope that works well. Then the original question must be reformulated: - Are there any functors for which there exists at least one non-bottom value of type 'f a' for some a, but there does not exist a function point :: a -> f a such that (a != _|_) => (point a != _|_). 2009/3/13 Brent Yorgey : > On Fri, Mar 13, 2009 at 05:35:31PM +0300, Eugene Kirpichov wrote: >> 'An arbitrary element' means 'undefined will suffice' >> >> point x = fmap (const x) undefined > > This is false. > > ?Prelude> fmap (const 1) [()] > ?[1] > ?Prelude> fmap (const 1) undefined > ?*** Exception: Prelude.undefined > > -Brent > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From frodo at theshire.org Fri Mar 13 11:50:21 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Mar 13 11:38:29 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions In-Reply-To: <200903130934.28466.marcin.kosiba@gmail.com> References: <200903130934.28466.marcin.kosiba@gmail.com> Message-ID: 2009/3/13 Marcin Kosiba : > ... > Threading the state is not the problem. Maybe this will help: > what I have now: > > fsm world state = case state of > ?first -> > ? ?do_stuff_one > ? ?(move_up, succ state) > ?second -> > ? ?do_stuff_two > ? ?(move_left, succ state) > ?third -> > ? ? do_stuff_three > ? ? (move_right, first) > > what I'd want to have is to say: > fsm world state = do > ?do_stuff_one > ?yield move_up > ?do_stuff_two > ?yield move_left > ?do_stuff_three > ?yield move_right > ?fsm world state > > and have it "translated" to: > > fsm world state = > ?do_stuff_one > ?(move_up, \world' state' -> > ? ?do_stuff_two > ? ? ?(move_left, \world'' state'' -> > ? ? ? ? do_stuff_three > ? ? ? ? ? (move_right, fsm world'' state'') Hi, I've not fully understood your exact problem but I think you might have a look to Continuations and Delimited Continuations. Both can help you solve the problem with implementing a yield statement. You can have a look at one of my (rather) old blog's posts about how to implement yield/send statements a-la-python: http://monadicheadaches.blogspot.com/2008/01/python-25s-iterators-in-haskell-sort-of.html Notice that blogspot messed up with code blocks so indentation looks bad and some character is even missing. Bye, Cristiano From dan.doel at gmail.com Fri Mar 13 11:50:14 2009 From: dan.doel at gmail.com (Dan Doel) Date: Fri Mar 13 11:38:41 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <20090313023047.342695f6@greenrd.org> References: <49BA6B27.7000504@van.steenbergen.nl> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> <20090313023047.342695f6@greenrd.org> Message-ID: <200903131150.15496.dan.doel@gmail.com> On Thursday 12 March 2009 10:30:47 pm Robin Green wrote: > For most functors, that is equivalent to > > point x = undefined > > But by that logic, everything is a member of every typeclass... There are some cases where expected laws will prevent that. For instance, If you try to make a monad like: instance Monad m where return = undefined m >>= f = undefined Then it will fail the law: m >>= return = m unless the only possible value of m is undefined (that is, m a is uninhabited except for bottom). In the case of pointed functors, the point is supposed to be a natural transformation from the identity functor to the functor in question, so: fmap f . point = point . f which always works with 'point = undefined' as long as 'fmap f' is strict (which it's basically required to be, since it must satisfy fmap id = id, and id is strict). Of course, the fact that it satisfies the relevant law doesn't make it less worthless as an instance. To make things less trivial, one might restrict himself to definitions that would work in a total language, and then it's easy to come up with examples of functors that aren't pointed. For instance, one can write the following in Agda: data Void (a : Set) : Set where -- empty mapVoid : {a b : Set} -> (a -> b) -> Void a -> Void b mapVoid f () -- empty function pointVoid : {a : Set} -> a -> Void a pointVoid = ? -- can't be written -- Dan From ross at soi.city.ac.uk Fri Mar 13 11:57:18 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Mar 13 11:45:29 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <49BA77BD.6000709@van.steenbergen.nl> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> <49BA77BD.6000709@van.steenbergen.nl> Message-ID: <20090313155718.GB4824@soi.city.ac.uk> On Fri, Mar 13, 2009 at 04:11:57PM +0100, Martijn van Steenbergen wrote: > Eugene Kirpichov wrote: >> 'An arbitrary element' means 'undefined will suffice' >> >> point x = fmap (const x) undefined > > Prelude> fmap (const True) undefined :: [Bool] > *** Exception: Prelude.undefined > > Or is that not what you mean? OK, an arbitrary maximal element. From martin.hofmann at uni-bamberg.de Fri Mar 13 12:03:11 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Fri Mar 13 11:51:01 2009 Subject: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime] In-Reply-To: <1768C9DF-FB23-44BD-AD35-C2CC73A95B24@ece.cmu.edu> References: <20090312100136.F145C32490C@www.haskell.org> <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> <1236876446.6867.132.camel@ios.cogsys.wiai.uni-bamberg.de> <1236931402.6409.24.camel@ios.cogsys.wiai.uni-bamberg.de> <1768C9DF-FB23-44BD-AD35-C2CC73A95B24@ece.cmu.edu> Message-ID: <1236960191.6147.41.camel@ios.cogsys.wiai.uni-bamberg.de> Brandon S. Allbery KF8NH wrote: > I'm pretty sure you can pull a typed AST out of ghc-api and query the > type of any node. Thanks. I am relieved to hear that. Could anybody tell me, where to start in the ghc-api? It's pretty hard, when you don't know where to look. Hoogle doesn't know anything about it. I found following DT describing the core language, but as far as I see, there are no type in there either. http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/CoreSyn.html#t %3AExpr Thanks a lot, Martin From haskell at brecknell.org Fri Mar 13 12:12:45 2009 From: haskell at brecknell.org (Matthew Brecknell) Date: Fri Mar 13 12:01:03 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> Message-ID: <1236960765.9513.201.camel@localhost> Ross Paterson wrote: > No. Choose an arbitrary element shape :: f () and define > point x = fmap (const x) shape Interesting. Is the arbitrariness of the shape some sort of evidence that Pointed is not really a very useful class in its own right? Certainly, the shape does matter if you plan to progress to non-trivial Applicative or Monad instances. For example, the non-determinism monad requires shape = [()], while the ZipList applicative functor requires shape = repeat (). Eugene Kirpichov wrote: > 'An arbitrary element' means 'undefined will suffice' > point x = fmap (const x) undefined Well, that would rather limit the possible Applicative instances. :-) (Consider the Applicative law: fmap g x = pure g <*> x) Brent Yorgey wrote: > Prelude> fmap (const 1) [()] > [1] > Prelude> fmap (const 1) undefined > *** Exception: Prelude.undefined True, but as far as I can tell, that doesn't violate any laws of the Pointed class. To put it crudely, if [] is as good as [()], then how is undefined any worse? From jonathanccast at fastmail.fm Fri Mar 13 12:12:56 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Mar 13 12:06:20 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <1236960765.9513.201.camel@localhost> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> <1236960765.9513.201.camel@localhost> Message-ID: <1236960776.6813.15.camel@jcchost> On Sat, 2009-03-14 at 02:12 +1000, Matthew Brecknell wrote: > Ross Paterson wrote: > > No. Choose an arbitrary element shape :: f () and define > > point x = fmap (const x) shape > > Interesting. Is the arbitrariness of the shape some sort of evidence > that Pointed is not really a very useful class in its own right? A simpler bit of evidence is that the only law I can think of for point (in its own right) is fmap f . point = point . f which we get free anyway. jcc From ross at soi.city.ac.uk Fri Mar 13 12:28:01 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Mar 13 12:16:12 2009 Subject: [Haskell-cafe] Pointless functors In-Reply-To: <1236960765.9513.201.camel@localhost> References: <49BA6B27.7000504@van.steenbergen.nl> <20090313143223.GA4824@soi.city.ac.uk> <5e0214850903130735w56941fa5h71ce35184d014f57@mail.gmail.com> <1236960765.9513.201.camel@localhost> Message-ID: <20090313162801.GC4824@soi.city.ac.uk> On Sat, Mar 14, 2009 at 02:12:45AM +1000, Matthew Brecknell wrote: > Ross Paterson wrote: > > No. Choose an arbitrary element shape :: f () and define > > point x = fmap (const x) shape > > Interesting. Is the arbitrariness of the shape some sort of evidence > that Pointed is not really a very useful class in its own right? Not useless, but equivalent to class Functor f => Pointed f where unit :: f () Naturality of point does the rest. But not all definitions of unit are equally useful. From dons at galois.com Fri Mar 13 12:34:52 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 13 12:23:54 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <49BA6BF5.8090906@libero.it> References: <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> <20090310211207.GF1077@whirlpool.galois.com> <732086550.20090311001540@gmail.com> <20090310214835.GH1077@whirlpool.galois.com> <49BA6BF5.8090906@libero.it> Message-ID: <20090313163452.GB15913@whirlpool.galois.com> manlio_perillo: > Don Stewart ha scritto: >> bulat.ziganshin: >>> Hello Don, >>> >>> Wednesday, March 11, 2009, 12:12:07 AM, you wrote: >>> >>>> Right, so my point stands: there's no difference now. If you can write a >>>> Storable instance, you can write a UA et al instance. >>> yes, if there is some class provided for this and not just hard-coded >>> 4 or so base types >> >> That's right. For example (supporting even pairs): >> >> instance (RealFloat a, UA a) => UA (Complex a) where >> >> newtype UArr (Complex a) = UAComplex (UArr (a :*: a)) >> newtype MUArr (Complex a) s = MUAComplex (MUArr (a :*: a) s) >> > > You also have to add instance for UIO: > > instance (RealFloat a, UIO a) => UIO (Complex a) where > hPutU h (UAComplex arr) = hPutU h arr > hGetU h = do arr <- hGetU h > return (UAComplex arr) > > > With Storable, this should not be required; you just have to write an > instance for the Storable class. > Though you get no IO operations with Storable... UIO is entirely separate. From heikki.aitakangas at cs.helsinki.fi Thu Mar 12 19:06:25 2009 From: heikki.aitakangas at cs.helsinki.fi (Heikki Aitakangas) Date: Fri Mar 13 12:24:43 2009 Subject: [Haskell-cafe] Combining haddock documentation from multiple packages Message-ID: <49B99571.2030107@cs.helsinki.fi> Is it possible to generate a "unified" documentation tree similar to http://www.haskell.org/ghc/docs/latest/html/libraries/index.html from packages installed via cabal from hackage? And if so, how does one go about doing it? -- Heikki Aitakangas From marcin.kosiba at gmail.com Fri Mar 13 12:38:11 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Fri Mar 13 12:26:31 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions In-Reply-To: References: <200903130934.28466.marcin.kosiba@gmail.com> Message-ID: <200903131738.14126.marcin.kosiba@gmail.com> On Friday 13 March 2009, Cristiano Paris wrote: > 2009/3/13 Marcin Kosiba : > > ... > > Threading the state is not the problem. Maybe this will help: > > what I have now: > > > > fsm world state = case state of > > ?first -> > > ? ?do_stuff_one > > ? ?(move_up, succ state) > > ?second -> > > ? ?do_stuff_two > > ? ?(move_left, succ state) > > ?third -> > > ? ? do_stuff_three > > ? ? (move_right, first) > > > > what I'd want to have is to say: > > fsm world state = do > > ?do_stuff_one > > ?yield move_up > > ?do_stuff_two > > ?yield move_left > > ?do_stuff_three > > ?yield move_right > > ?fsm world state > > > > and have it "translated" to: > > > > fsm world state = > > ?do_stuff_one > > ?(move_up, \world' state' -> > > ? ?do_stuff_two > > ? ? ?(move_left, \world'' state'' -> > > ? ? ? ? do_stuff_three > > ? ? ? ? ? (move_right, fsm world'' state'') > > Hi, > > I've not fully understood your exact problem but I think you might > have a look to Continuations and Delimited Continuations. > > Both can help you solve the problem with implementing a yield > statement. You can have a look at one of my (rather) old blog's posts > about how to implement yield/send statements a-la-python: > > http://monadicheadaches.blogspot.com/2008/01/python-25s-iterators-in-haskel >l-sort-of.html > > Notice that blogspot messed up with code blocks so indentation looks > bad and some character is even missing. Hi, I've already checked those out. I tried using your yield implementation and while it works, I couldn't get it to work with the state monad. So while: data RecPair a b = Nil | RP (b, a -> RecPair a b) yield x = Cont $ \k -> RP (x, k) got me half-way to my goal, I couldn't figure out how to make something like: yield' = do state <- get state' <- yield state put state' Thanks! Marcin Kosiba -------------- 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/20090313/bd881942/attachment.bin From matthijs at stdin.nl Fri Mar 13 12:51:07 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Fri Mar 13 12:39:18 2009 Subject: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime] In-Reply-To: <1236960191.6147.41.camel@ios.cogsys.wiai.uni-bamberg.de> References: <20090312100136.F145C32490C@www.haskell.org> <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> <1236876446.6867.132.camel@ios.cogsys.wiai.uni-bamberg.de> <1236931402.6409.24.camel@ios.cogsys.wiai.uni-bamberg.de> <1768C9DF-FB23-44BD-AD35-C2CC73A95B24@ece.cmu.edu> <1236960191.6147.41.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <20090313165107.GE25888@katherina.student.utwente.nl> Hi Martin, > Could anybody tell me, where to start in the ghc-api? It's pretty hard, > when you don't know where to look. Hoogle doesn't know anything about > it. I found following DT describing the core language, but as far as I > see, there are no type in there either. I've been working on parsing core in the past few months. For an example, look here: http://git.stderr.nl/gitweb?p=matthijs/projects/fhdl.git;a=blob;f=Translator.hs;h=8072f85925ad1238 The loadModule and findBind functions are interesting. As for iterating the AST, have a look at Flatten.hs. Good luck, any questions are welcome! Gr. Matthijs -------------- 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/20090313/4acd107f/attachment.bin From manlio_perillo at libero.it Fri Mar 13 12:55:30 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 12:43:47 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090313163452.GB15913@whirlpool.galois.com> References: <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> <20090310211207.GF1077@whirlpool.galois.com> <732086550.20090311001540@gmail.com> <20090310214835.GH1077@whirlpool.galois.com> <49BA6BF5.8090906@libero.it> <20090313163452.GB15913@whirlpool.galois.com> Message-ID: <49BA9002.4020908@libero.it> Don Stewart ha scritto: > [...] >> You also have to add instance for UIO: >> >> instance (RealFloat a, UIO a) => UIO (Complex a) where >> hPutU h (UAComplex arr) = hPutU h arr >> hGetU h = do arr <- hGetU h >> return (UAComplex arr) >> >> >> With Storable, this should not be required; you just have to write an >> instance for the Storable class. >> > > Though you get no IO operations with Storable... UIO is entirely > separate. > Yes, but using Storable and Foreign.Ptr, IO is rather simple. From storablevector package: -- | Outputs a 'Vector' to the specified 'Handle'. hPut :: (Storable a) => Handle -> Vector a -> IO () hPut h v = if null v then return () else let (fptr, s, l) = toForeignPtr v in withForeignPtr fptr $ \ ptr -> let ptrS = advancePtr ptr s ptrE = advancePtr ptrS l -- use advancePtr and minusPtr in order to respect -- alignment in hPutBuf h ptrS (minusPtr ptrE ptrS) -- | Read a 'Vector' directly from the specified 'Handle'. This -- is far more efficient than reading the characters into a list -- and then using 'pack'. -- hGet :: (Storable a) => Handle -> Int -> IO (Vector a) hGet _ 0 = return empty hGet h i = createAndTrim i $ \p -> let elemType :: Ptr a -> a elemType _ = undefined sizeOfElem = sizeOf (elemType p) in fmap (flip div sizeOfElem) $ hGetBuf h p (i * sizeOfElem) Regards Manlio From manlio_perillo at libero.it Fri Mar 13 13:08:58 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 12:57:14 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> Message-ID: <49BA932A.1040302@libero.it> Bryan O'Sullivan ha scritto: > [...] > text is not mature, and is based on the same modern fusion framework as > uvector and vector. It uses unpinned arrays, but provides functions for > dealing with foreign code. What is the reason why you have decided to use unpinned arrays (ByteArray#) instead of pinned arrays (Foreign.Ptr)? > [...] Thanks Manlio From dons at galois.com Fri Mar 13 13:08:57 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 13 12:57:57 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <49BA932A.1040302@libero.it> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <49BA932A.1040302@libero.it> Message-ID: <20090313170857.GF15913@whirlpool.galois.com> manlio_perillo: > Bryan O'Sullivan ha scritto: >> [...] >> text is not mature, and is based on the same modern fusion framework as >> uvector and vector. It uses unpinned arrays, but provides functions for >> dealing with foreign code. > > What is the reason why you have decided to use unpinned arrays > (ByteArray#) instead of pinned arrays (Foreign.Ptr)? They prevent heap fragmentation (and in general are faster). -- Don From dons at galois.com Fri Mar 13 13:24:36 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 13 13:13:36 2009 Subject: [Haskell-cafe] Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> Message-ID: <20090313172436.GH15913@whirlpool.galois.com> tphyahoo: > Is there something like subRegex... something like =~ s/.../.../ in > perl... for haskell pcre Regexen? > > I mean, subRegex from Text.Regex of course: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat > > Thanks for any advice, Basically, we should have it. From dave at zednenem.com Fri Mar 13 13:26:15 2009 From: dave at zednenem.com (David Menendez) Date: Fri Mar 13 13:14:25 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions In-Reply-To: <200903130934.28466.marcin.kosiba@gmail.com> References: <200903130934.28466.marcin.kosiba@gmail.com> Message-ID: <49a77b7a0903131026w676408aai8eb7577945d95fe@mail.gmail.com> 2009/3/13 Marcin Kosiba : > > Threading the state is not the problem. Maybe this will help: > what I have now: > > fsm world state = case state of > ?first -> > ? ?do_stuff_one > ? ?(move_up, succ state) > ?second -> > ? ?do_stuff_two > ? ?(move_left, succ state) > ?third -> > ? ? do_stuff_three > ? ? (move_right, first) > > what I'd want to have is to say: > fsm world state = do > ?do_stuff_one > ?yield move_up > ?do_stuff_two > ?yield move_left > ?do_stuff_three > ?yield move_right > ?fsm world state > > and have it "translated" to: > > fsm world state = > ?do_stuff_one > ?(move_up, \world' state' -> > ? ?do_stuff_two > ? ? ?(move_left, \world'' state'' -> > ? ? ? ? do_stuff_three > ? ? ? ? ? (move_right, fsm world'' state'') Do you really need yield? Most of the time, you should be able to implement move_up and the rest directly using bits of the run function. But assuming you do need yield, you probably want a resumption monad. Here's a variant of an implementation I've worked with recently. data Thunk r m a = Val a | Suspend r (m (Thunk r m a)) newtype Suspend r m a = C { unC :: forall b. (a -> m (Thunk r m a)) -> m (Thunk r m a) } instance Monad (Suspend r m) where return a = C (\k -> k a) m >>= f = C (\k -> unC m (\a -> unC (f a) k)) instance MonadTrans (Suspend r) where lift m = C (\k -> m >>= k) suspend :: Monad m => r -> Suspend r m () suspend r = C (\k -> return $ Suspend r (k ())) run :: Monad m => Suspend r m a -> m (Thunk r m a) run m = unC m (return . Val) These laws should give an idea of how it works: run (return a) = return (Val a) run (lift m >>= f) = m >>= \a -> run (f a) run (suspend r >> m) = return (Suspend r (run m)) There's also a function that undoes run, although you shouldn't need it. enter :: Monad m => Thunk r m a -> Suspend r m a enter (Val a) = return a enter (Suspend r m) = suspend r >> lift m >>= enter -- Dave Menendez From bulat.ziganshin at gmail.com Fri Mar 13 13:30:44 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Mar 13 13:19:05 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <20090313170857.GF15913@whirlpool.galois.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <49BA932A.1040302@libero.it> <20090313170857.GF15913@whirlpool.galois.com> Message-ID: <1029275363.20090313203044@gmail.com> Hello Don, Friday, March 13, 2009, 8:08:57 PM, you wrote: >> What is the reason why you have decided to use unpinned arrays >> (ByteArray#) instead of pinned arrays (Foreign.Ptr)? > They prevent heap fragmentation (and in general are faster). you probably mean faster alloc/gc operations, everything else should be the same -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From andy at adradh.org.uk Fri Mar 13 14:44:06 2009 From: andy at adradh.org.uk (andy morris) Date: Fri Mar 13 14:32:17 2009 Subject: [Haskell-cafe] Vim support for cabal In-Reply-To: References: Message-ID: 2009/3/13 Pavel Perikov : > Hi caf? ! > > I googled for some kind of vim support for ?cabal but found nothing. I mean > syntax highlighting of .cabal and probably integration with haskellmode. Did > anyone hear about such thing? > > Pavel I've been wanting something like this as well, so you inspired me to finally get round to writing it. :D I've stuck it on Patch-tag, so: darcs get http://patch-tag.com/publicrepos/cabal-vim Nothing special at the moment; it just highlights field names and does some basic autoindenting. If you (or someone else on the list) have any suggestions, then just say (or send a patch if you want :) ) I might add to it over the weekend as well (highlighting of compiler names in the 'tested-on' field, that sort of thing), so perhaps check back in a few days. From manlio_perillo at libero.it Fri Mar 13 16:18:19 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 16:06:35 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types Message-ID: <49BABF8B.4030304@libero.it> Hi. I'm sure this is a know bug, but I can't find details with Google. The offending code is here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2362 When I execute the program I get: uio: readChunkBU: can't read What's the problem? I'm using uvector from: http://code.haskell.org/~dons/code/uvector/ Thanks Manlio Perillo From daniel.is.fischer at web.de Fri Mar 13 16:46:42 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Mar 13 16:34:51 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <49BABF8B.4030304@libero.it> References: <49BABF8B.4030304@libero.it> Message-ID: <200903132146.42922.daniel.is.fischer@web.de> Am Freitag, 13. M?rz 2009 21:18 schrieb Manlio Perillo: > Hi. > > I'm sure this is a know bug, but I can't find details with Google. > > The offending code is here: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2362 > > When I execute the program I get: > uio: readChunkBU: can't read > > What's the problem? > > > I'm using uvector from: > http://code.haskell.org/~dons/code/uvector/ > > > > Thanks Manlio Perillo > Worked with uvector-0.1.0.1: $ ghc --make readUArr.hs [1 of 1] Compiling Main ( readUArr.hs, readUArr.o ) Linking readUArr ... $ ./readUArr 2 But not with uvector-0.2 $ ./readUArr readUArr: readChunkBU: can't read From pumpkingod at gmail.com Fri Mar 13 17:03:52 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri Mar 13 16:52:00 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <200903132146.42922.daniel.is.fischer@web.de> References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> Message-ID: As far as I know, the reason for this is that the UIO instance for productions writes the two "rows" out sequentially to file, but doesn't include any means to determine the length of the two halves when it's loading up again. When you try to read the production back in, it tries to read in two arrays, but the first array read consumes all the input leaving the second with nothing. Having said that, I'm not sure why it used to work. I remember testing this on the version in hackage and finding the same issue. Cheers, Dan On Fri, Mar 13, 2009 at 4:46 PM, Daniel Fischer wrote: > Am Freitag, 13. M?rz 2009 21:18 schrieb Manlio Perillo: >> Hi. >> >> I'm sure this is a know bug, but I can't find details with Google. >> >> The offending code is here: >> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2362 >> >> When I execute the program I get: >> ? ?uio: readChunkBU: can't read >> >> What's the problem? >> >> >> I'm using uvector from: >> http://code.haskell.org/~dons/code/uvector/ >> >> >> >> Thanks ? Manlio Perillo >> > > Worked with uvector-0.1.0.1: > > $ ghc --make readUArr.hs > [1 of 1] Compiling Main ? ? ? ? ? ? ( readUArr.hs, readUArr.o ) > Linking readUArr ... > $ ./readUArr > 2 > > But not with uvector-0.2 > $ ./readUArr > readUArr: readChunkBU: can't read > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Fri Mar 13 17:08:13 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 13 16:57:13 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> Message-ID: <20090313210813.GV15913@whirlpool.galois.com> UIO's also only a truly alpha idea as a proxy for bytestring/Binary support. Patches welcome. pumpkingod: > As far as I know, the reason for this is that the UIO instance for > productions writes the two "rows" out sequentially to file, but > doesn't include any means to determine the length of the two halves > when it's loading up again. When you try to read the production back > in, it tries to read in two arrays, but the first array read consumes > all the input leaving the second with nothing. > > Having said that, I'm not sure why it used to work. I remember testing > this on the version in hackage and finding the same issue. > > Cheers, > Dan > > On Fri, Mar 13, 2009 at 4:46 PM, Daniel Fischer > wrote: > > Am Freitag, 13. M?rz 2009 21:18 schrieb Manlio Perillo: > >> Hi. > >> > >> I'm sure this is a know bug, but I can't find details with Google. > >> > >> The offending code is here: > >> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2362 > >> > >> When I execute the program I get: > >> ? ?uio: readChunkBU: can't read > >> > >> What's the problem? > >> > >> > >> I'm using uvector from: > >> http://code.haskell.org/~dons/code/uvector/ > >> > >> > >> > >> Thanks ? Manlio Perillo > >> > > > > Worked with uvector-0.1.0.1: > > > > $ ghc --make readUArr.hs > > [1 of 1] Compiling Main ? ? ? ? ? ? ( readUArr.hs, readUArr.o ) > > Linking readUArr ... > > $ ./readUArr > > 2 > > > > But not with uvector-0.2 > > $ ./readUArr > > readUArr: readChunkBU: can't read > > _______________________________________________ > > 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 frodo at theshire.org Fri Mar 13 17:54:32 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Mar 13 17:42:41 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions In-Reply-To: <200903131738.14126.marcin.kosiba@gmail.com> References: <200903130934.28466.marcin.kosiba@gmail.com> <200903131738.14126.marcin.kosiba@gmail.com> Message-ID: 2009/3/13 Marcin Kosiba : > Hi, > ? ? ? ?I've already checked those out. I tried using your yield implementation and > while it works, I couldn't get it to work with the state monad. > ? ? ? ?So while: > data RecPair a b = Nil | RP (b, a -> RecPair a b) > yield x = Cont $ \k -> RP (x, k) > > ? ? ? ?got me half-way to my goal, I couldn't figure out how to make something like: > > yield' = do > ?state <- get > ?state' <- yield state > ?put state' Basically, the yield is built upon the Cont monad which has a transformer counter part, ContT. You could try and re-implement the yield under ContT instead of just Cont then you can stack ContT on top of State (or StateT if you need more monads) and have a state (i.e. get/put) and the yield. Hope this helps. Cristiano From manlio_perillo at libero.it Fri Mar 13 18:13:24 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 18:01:37 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> Message-ID: <49BADA84.8080208@libero.it> Daniel Peebles ha scritto: > As far as I know, the reason for this is that the UIO instance for > productions writes the two "rows" out sequentially to file, but > doesn't include any means to determine the length of the two halves > when it's loading up again. When you try to read the production back > in, it tries to read in two arrays, but the first array read consumes > all the input leaving the second with nothing. > Ok, thanks. For now, I think that the simple solution is to not use UArr (a:*:b), but (UArr a, UArr b). Or I should just switch to Data.Array.Unboxed. The operations I need with the array are only: - sum of elements - binary search - serialization/deserialization - sorting (but right now I sort the list before creating the array) with a very big data set. For my problem, is uvector the best solution? What about storablevector or cvector, instead? Regards Manlio From dons at galois.com Fri Mar 13 18:27:56 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 13 18:16:59 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <49BADA84.8080208@libero.it> References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BADA84.8080208@libero.it> Message-ID: <20090313222756.GX15913@whirlpool.galois.com> >> As far as I know, the reason for this is that the UIO instance for >> productions writes the two "rows" out sequentially to file, but >> doesn't include any means to determine the length of the two halves >> when it's loading up again. When you try to read the production back >> in, it tries to read in two arrays, but the first array read consumes >> all the input leaving the second with nothing. >> > > Ok, thanks. > > For now, I think that the simple solution is to not use UArr (a:*:b), but > (UArr a, UArr b). Just newtype your own UIO instance, if you need a different instance... -- Don From manlio_perillo at libero.it Fri Mar 13 18:50:54 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 18:39:08 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <200903132146.42922.daniel.is.fischer@web.de> References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> Message-ID: <49BAE34E.6000305@libero.it> Daniel Fischer ha scritto: > [...] > Worked with uvector-0.1.0.1: > > [...] > But not with uvector-0.2 > [...] The main difference is that in uvector 0.2, hPutBU does not write in the file the length of the array; hGetBU simply use the file size. let elemSize = sizeBU 1 (undefined :: e) n <- fmap ((`div`elemSize) . fromInteger) $ hFileSize h So, the problem seems to be here. This simply don't support having two arrays written in the same file, and sizeBU belongs to the UAE class, whose instances are only declared for builtin types. So, the patch is: "just revert this change". Regards Manlio From dons at galois.com Fri Mar 13 18:53:53 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 13 18:42:52 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <49BAE34E.6000305@libero.it> References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> Message-ID: <20090313225353.GC15913@whirlpool.galois.com> manlio_perillo: > Daniel Fischer ha scritto: >> [...] >> Worked with uvector-0.1.0.1: >> >> [...] >> But not with uvector-0.2 > > [...] > > The main difference is that in uvector 0.2, hPutBU does not write in the > file the length of the array; hGetBU simply use the file size. > > let elemSize = sizeBU 1 (undefined :: e) > n <- fmap ((`div`elemSize) . fromInteger) $ hFileSize h > > > So, the problem seems to be here. > This simply don't support having two arrays written in the same file, > and sizeBU belongs to the UAE class, whose instances are only declared > for builtin types. > > > So, the patch is: "just revert this change". Or... use your own UIO instance. That's why it's a type class! Anyway, for the background on this: Tue Nov 18 08:44:46 PST 2008 Malcolm Wallace * Use hFileSize to determine arraysize, rather than encoding it in the file. "Here is a patch to the uvector library that fixes hGetBU and hPutBU to use the filesize to determine arraysize, rather than encoding it within the file. I guess the disadvantages are that now only one array can live in a file, and the given Handle must indeed be a file, not a socket Handle. But the advantage is that one can read packed raw datafiles obtained externally." Still, again, I'd point out that uvector is alpha, APIs can and will change. -- Don From manlio_perillo at libero.it Fri Mar 13 19:15:45 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Mar 13 19:04:05 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <20090313225353.GC15913@whirlpool.galois.com> References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> Message-ID: <49BAE921.6080705@libero.it> Don Stewart ha scritto: > [...] >> >> So, the patch is: "just revert this change". > > Or... use your own UIO instance. That's why it's a type class! > Why should I rewrite the UIO instance, if one already exists? > Anyway, for the background on this: > > Tue Nov 18 08:44:46 PST 2008 Malcolm Wallace > * Use hFileSize to determine arraysize, rather than encoding it in the > file. > > "Here is a patch to the uvector library that fixes hGetBU and hPutBU to > use the filesize to determine arraysize, rather than encoding it within > the file. I guess the disadvantages are that now only one array can > live in a file, and the given Handle must indeed be a file, not a socket > Handle. But the advantage is that one can read packed raw datafiles > obtained externally." > > Still, again, I'd point out that uvector is alpha, APIs can and will > change. > Ok, with API changes. But they *should not* break normal package usage. That patch simply introduced a bug in uvector. If you think that the patch is useful, then the patch should also include a modification to the UIO instance for a:*:b. Regards Manlio From daniel.is.fischer at web.de Fri Mar 13 19:18:59 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Mar 13 19:07:16 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <20090313225353.GC15913@whirlpool.galois.com> References: <49BABF8B.4030304@libero.it> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> Message-ID: <200903140018.59645.daniel.is.fischer@web.de> Am Freitag, 13. M?rz 2009 23:53 schrieb Don Stewart: > manlio_perillo: > > Daniel Fischer ha scritto: > >> [...] > >> Worked with uvector-0.1.0.1: > >> > >> [...] > >> But not with uvector-0.2 > >> > > > [...] > > > > The main difference is that in uvector 0.2, hPutBU does not write in the > > file the length of the array; hGetBU simply use the file size. > > > > let elemSize = sizeBU 1 (undefined :: e) > > n <- fmap ((`div`elemSize) . fromInteger) $ hFileSize h > > > > > > So, the problem seems to be here. > > This simply don't support having two arrays written in the same file, > > and sizeBU belongs to the UAE class, whose instances are only declared > > for builtin types. > > > > > > So, the patch is: "just revert this change". > > Or... use your own UIO instance. That's why it's a type class! > > Anyway, for the background on this: > > Tue Nov 18 08:44:46 PST 2008 Malcolm Wallace > * Use hFileSize to determine arraysize, rather than encoding it in > the file. > > "Here is a patch to the uvector library that fixes hGetBU and hPutBU to > use the filesize to determine arraysize, rather than encoding it within > the file. I guess the disadvantages are that now only one array can > live in a file, and the given Handle must indeed be a file, not a > socket Handle. But the advantage is that one can read packed raw datafiles > obtained externally." > > Still, again, I'd point out that uvector is alpha, APIs can and will > change. > > -- Don Though I don't really know whether what I did is sane, I can offer a few patches which seem to work. Check for sanity before applying :) hunk ./Data/Array/Vector/Prim/BUArr.hs 85 - hPutBU, hGetBU + hPutBU, hGetBU, hGetLengthBU hunk ./Data/Array/Vector/Prim/BUArr.hs 864 +hGetLengthBU :: forall e. UAE e => Int -> Handle -> IO (BUArr e) +hGetLengthBU numEntries h = + do + marr@(MBUArr _ marr#) <- stToIO (newMBU numEntries) + let bytes = sizeBU numEntries (undefined :: e) + wantReadableHandle "hGetBU" h $ + \handle@Handle__{ haFD=fd, haBuffer=ref, haIsStream=is_stream } -> do + buf@Buffer { bufBuf = raw, bufWPtr = w, bufRPtr = r } <- readIORef ref + let copied = bytes `min` (w - r) + remaining = bytes - copied + newr = r + copied + newbuf | newr == w = buf{ bufRPtr = 0, bufWPtr = 0 } + | otherwise = buf{ bufRPtr = newr } + --memcpy_ba_baoff marr# raw (fromIntegral r) (fromIntegral copied) + memcpy_ba_baoff marr# raw (fromIntegral r) (fromIntegral copied) + writeIORef ref newbuf + readChunkBU fd is_stream marr# copied remaining + stToIO (unsafeFreezeAllMBU marr) + hunk ./Data/Array/Vector/UArr.hs 59 - BUArr, MBUArr, UAE, - lengthBU, indexBU, sliceBU, hGetBU, hPutBU, + BUArr, MBUArr, UAE(..), + lengthBU, indexBU, sliceBU, hGetBU, hGetLengthBU, hPutBU, hunk ./Data/Array/Vector/UArr.hs 867 + hGetLengthU :: Int -> Handle -> IO (UArr a) hunk ./Data/Array/Vector/UArr.hs 875 +primGetLengthU :: UPrim a => Int -> Handle -> IO (UArr a) +primGetLengthU n = liftM mkUAPrim . hGetLengthBU n + hunk ./Data/Array/Vector/UArr.hs 880 -instance UIO Bool where hPutU = primPutU; hGetU = primGetU -instance UIO Char where hPutU = primPutU; hGetU = primGetU -instance UIO Int where hPutU = primPutU; hGetU = primGetU -instance UIO Word where hPutU = primPutU; hGetU = primGetU -instance UIO Float where hPutU = primPutU; hGetU = primGetU -instance UIO Double where hPutU = primPutU; hGetU = primGetU +instance UIO Bool where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Char where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Int where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Word where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Float where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Double where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU hunk ./Data/Array/Vector/UArr.hs 887 -instance UIO Word8 where hPutU = primPutU; hGetU = primGetU -instance UIO Word16 where hPutU = primPutU; hGetU = primGetU -instance UIO Word32 where hPutU = primPutU; hGetU = primGetU -instance UIO Word64 where hPutU = primPutU; hGetU = primGetU +instance UIO Word8 where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Word16 where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Word32 where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Word64 where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU hunk ./Data/Array/Vector/UArr.hs 892 -instance UIO Int8 where hPutU = primPutU; hGetU = primGetU -instance UIO Int16 where hPutU = primPutU; hGetU = primGetU -instance UIO Int32 where hPutU = primPutU; hGetU = primGetU -instance UIO Int64 where hPutU = primPutU; hGetU = primGetU +instance UIO Int8 where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Int16 where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Int32 where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU +instance UIO Int64 where hPutU = primPutU; hGetU = primGetU; hGetLengthU = primGetLengthU hunk ./Data/Array/Vector/UArr.hs 899 -instance (UIO a, UIO b) => UIO (a :*: b) where +instance (UAE a, UAE b, UIO a, UIO b) => UIO (a :*: b) where hunk ./Data/Array/Vector/UArr.hs 902 - hGetU h = do xs <- hGetU h - ys <- hGetU h + hGetU h = do let elemSize = sizeBU 1 (undefined :: a) + sizeBU 1 (undefined :: b) + n <- fmap ((`div` elemSize) . fromInteger) $ hFileSize h + xs <- hGetLengthU n h + ys <- hGetLengthU n h + return (UAProd xs ys) + hGetLengthU n h = do xs <- hGetLengthU n h + ys <- hGetLengthU n h hunk ./Data/Array/Vector/UArr.hs 914 -instance (RealFloat a, UIO a) => UIO (Complex a) where +instance (RealFloat a, UAE a, UIO a) => UIO (Complex a) where hunk ./Data/Array/Vector/UArr.hs 918 + hGetLengthU n h = do arr <- hGetLengthU n h + return (UAComplex arr) hunk ./Data/Array/Vector/UArr.hs 921 -instance (Integral a, UIO a) => UIO (Ratio a) where +instance (Integral a, UAE a, UIO a) => UIO (Ratio a) where hunk ./Data/Array/Vector/UArr.hs 925 + hGetLengthU n h = do arr <- hGetLengthU n h + return (UARatio arr) From dons at galois.com Fri Mar 13 19:21:15 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 13 19:10:14 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <49BAE921.6080705@libero.it> References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> <49BAE921.6080705@libero.it> Message-ID: <20090313232115.GF15913@whirlpool.galois.com> manlio_perillo: > Don Stewart ha scritto: >> [...] >>> >>> So, the patch is: "just revert this change". >> >> Or... use your own UIO instance. That's why it's a type class! >> > > Why should I rewrite the UIO instance, if one already exists? Oh, because you want different serialization semantics to the (arbitrary) defaults. -- Don From pumpkingod at gmail.com Fri Mar 13 19:33:26 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri Mar 13 19:21:34 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <20090313232115.GF15913@whirlpool.galois.com> References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> <49BAE921.6080705@libero.it> <20090313232115.GF15913@whirlpool.galois.com> Message-ID: The main issue seems to be that although the semantics of UIO may be arbitrary, Wallace's patch actually broke deserialization for any production-based UArr, and I'm not sure the benefits are worthwhile (loading a file someone else sent you) given that endianness is already not taken into account when loading (so the chances of someone giving you a raw binary file that happens to contain values of the correct endianness is rather low, it seems). On a related note, having a (more) complete testsuite might help prevent patches like this from breaking existing functionality. Maybe a way to resolve the issue is to use the file size and break it according to the size of the two halves of the production? This avoids prefixing array length, but allows the productions to still work. Either way, I'm in the process of writing a Binary instance, so maybe we can get the best of both worlds eventually. Thanks, Dan On Fri, Mar 13, 2009 at 7:21 PM, Don Stewart wrote: > manlio_perillo: >> Don Stewart ha scritto: >>> [...] >>>> >>>> So, the patch is: "just revert this change". >>> >>> Or... use your own UIO instance. That's why it's a type class! >>> >> >> Why should I rewrite the UIO instance, if one already exists? > > Oh, because you want different serialization semantics to the > (arbitrary) defaults. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Fri Mar 13 19:34:37 2009 From: dons at galois.com (Don Stewart) Date: Fri Mar 13 19:23:38 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> <49BAE921.6080705@libero.it> <20090313232115.GF15913@whirlpool.galois.com> Message-ID: <20090313233437.GI15913@whirlpool.galois.com> I'd like to do away with UIO altogether though. pumpkingod: > The main issue seems to be that although the semantics of UIO may be > arbitrary, Wallace's patch actually broke deserialization for any > production-based UArr, and I'm not sure the benefits are worthwhile > (loading a file someone else sent you) given that endianness is > already not taken into account when loading (so the chances of someone > giving you a raw binary file that happens to contain values of the > correct endianness is rather low, it seems). > > On a related note, having a (more) complete testsuite might help > prevent patches like this from breaking existing functionality. > > Maybe a way to resolve the issue is to use the file size and break it > according to the size of the two halves of the production? This avoids > prefixing array length, but allows the productions to still work. > > Either way, I'm in the process of writing a Binary instance, so maybe > we can get the best of both worlds eventually. > > Thanks, > Dan > > On Fri, Mar 13, 2009 at 7:21 PM, Don Stewart wrote: > > manlio_perillo: > >> Don Stewart ha scritto: > >>> [...] > >>>> > >>>> So, the patch is: "just revert this change". > >>> > >>> Or... use your own UIO instance. That's why it's a type class! > >>> > >> > >> Why should I rewrite the UIO instance, if one already exists? > > > > Oh, because you want different serialization semantics to the > > (arbitrary) defaults. > > > > -- Don > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From fall.into.this at gmail.com Fri Mar 13 20:25:43 2009 From: fall.into.this at gmail.com (fallintothis) Date: Fri Mar 13 20:13:53 2009 Subject: [Haskell-cafe] reddit.com/r/haskell_proposals: Relevance to Google Summer of Code? Message-ID: <8930c56a0903131725n79abaea1m99257495e4b93a27@mail.gmail.com> NOTE: This message was originally posted to the subreddit in question (and has been slightly modified), where I was told that I should post the question on haskell-cafe.? See http://www.reddit.com/r/haskell_proposals/comments/847by/ask_relevance_to_google_summer_of_code/ I'm currently researching the possibility of applying for the Google Summer of Code[1] and (by way of dons's post[2]) have found myself perusing the Haskell Proposals subreddit for project ideas. As an accepted MS CS student, I've spent my undergraduate life annoying professors by using a slew of different programming languages -- most recently, Haskell. While not altogether unfamiliar with the language, I rather doubt (or at least try to honestly question) how useful a contributor I'd be to some of the larger projects that have been posted (e.g., the Immix garbage collector[3] or loop unrolling[4]), despite some of their acceptances as tickets on the Summer of Code Trac[5] and my deep interest in compiler & language theory. There are projects that match other interests of mine and (in my approximation) my experience level, but they also tend to be smaller. For example, the reddit-alike[6] or wiki-embedded Haddock[7]. So, background sap-story notwithstanding, I suppose my general question is: with respect to the aforementioned Summer of Code post, is this subreddit meant to be a place for appropriate SoC projects? It doesn't feel quite like it is, but I would be excited to work on some of those that I indicated. The telltale sign for a project's worthiness seems to be that a ticket is already opened on the Trac that spells out the appropriateness, but this is limiting. More obviously, to test the fitness of a project, should the idea be opened as a ticket for the cursory review of others? Should someone who wants to do Summer of Code work be at any particular level of experience ("dive into GHC's backend" versus "use Haskell to hack on a project")? Intuitively, 1 summer's worth of work could probably be found in any corner of code that meshes with any student's expertise and interests -- even a reddit-alike can actually be a lot of work. But the catch (for me) is that when familiarity is relatively low, it's hard to come up with such ideas. I realize that applications are competitive against other students, so the range of acceptable submissions would depend more on the other applicants, but I think it's also important to address haskell.org's ethos with regards to who they're looking for. If there's a more appropriate place to post this question (ha! singular) I'm more than happy to transplant it. [1] http://code.google.com/soc/ [2] http://www.reddit.com/r/programming/comments/7zfog/anybody_done_the_google_summer_of_code_your/c07twkd [3] http://www.reddit.com/r/haskell_proposals/comments/7wjsc/implement_the_immix_garbage_collector_in_ghc/ [4] http://www.reddit.com/r/haskell_proposals/comments/7z1uf/implement_loop_unrolling_for_c_level_loops_in_ghc/ [5] http://hackage.haskell.org/trac/summer-of-code/wiki/Soc2009 [6] http://www.reddit.com/r/haskell_proposals/comments/7u48x/a_simple_redditlike_happsbased_proposal_voting/ [7] http://www.reddit.com/r/haskell_proposals/comments/7qnwq/haddock_with_embedded_wiki_feature_a_la_rwh_so_we/ From lemming at henning-thielemann.de Fri Mar 13 20:40:58 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Mar 13 20:29:07 2009 Subject: [Haskell-cafe] Re: Haskell-Wiki Account registration In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, Benjamin L.Russell wrote: > Why not ask new users to identify letters in a random bitmapped image > of a string, as is commonly done? I assume, because those images are 1) not accessible by blind people 2) can be decoded by spammers, since they know how the images are generated by common software. Thus my suggestion was a simple Haskell specific question, which cannot be answered by stupid spambots. From lemming at henning-thielemann.de Fri Mar 13 20:52:32 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Mar 13 20:40:41 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> Message-ID: On Mon, 9 Mar 2009, Alexander Dunlap wrote: > - uvector, storablevector and vector are all designed for dealing with > arrays. They *can* be used for characters/word8s but are not > specialized for that purpose, do not deal with Unicode at all, and are > probably worse at it. They are better for dealing with things that you > would generally use arrays for. Since the Storable instance of Char stores 32 bit values, I expect they store full Unicode codes and thus StorableVector can be used for Unicode strings without loss. They will require more memory than UTF8 strings, but whether they are faster or slower will depend on how expensive UTF8 decoding/encoding is. From lemming at henning-thielemann.de Fri Mar 13 21:14:53 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Mar 13 21:03:01 2009 Subject: [Haskell-cafe] Incompatibility of different (monad transformer) libraries In-Reply-To: <63c2e535e6a4e2f382c777103a37dc67@xs4all.nl> References: <63c2e535e6a4e2f382c777103a37dc67@xs4all.nl> Message-ID: On Tue, 10 Mar 2009, ariep wrote: > ==== Problem instance ==== > > In my code, I use some monad transformers. I used to use the "mtl" package, > but I recently switched to the combination "transformers"/"monads-tf" > (mainly for the Applicative instances). > > The same code also uses the "haskeline" library, for line reading. > Haskeline allows to edit the user's history (previously entered lines), but > only through a Control.Monad.State interface, and that happens to be the > Control.Monad.State from "mtl". So now, my package also needs to import > "mtl". > > This combination of package dependencies gives import conflicts: whenever I > import some Control.Monad.{State,Error,Cont,...} module, there is more than > one package providing such a module. I think 'transformers' exports Control.Monad.Trans.State. This should not conflict with MTL. However, MTL's State type is different from transformer's one. Is that your problem? > ==== Solution? ==== > > For now, I resolve the ambiguity by using "Package imports", i.e. annotate > the ambiguous imports by the right package name. > > Is this the best solution? The ghc manual states, that the package import > extension should not be necessary. I can think of another solution, by > creating a dedicated package, which imports mtl:Control.Monad.* and > re-exports them under another name, but that's even less elegant than > package imports. Since the 'cabal' tool became better and better, today I use a cabal file even for small programs. Cabal automatically calls GHC with the right package exposing and hiding options. From lemming at henning-thielemann.de Fri Mar 13 21:28:22 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Mar 13 21:16:30 2009 Subject: [Haskell-cafe] Style Guide for Haskell Code In-Reply-To: <49B68884.8000206@libero.it> References: <49B68884.8000206@libero.it> Message-ID: On Tue, 10 Mar 2009, Manlio Perillo wrote: > After a quick search with Google, it seems that there is not yet an > "official" document for Style Guide for Haskell Code. > > I was only able to found: > > http://www.cs.caltech.edu/courses/cs11/material/haskell/misc/haskell_style_guide.html > http://urchin.earth.li/~ian/style/haskell.html > http://github.com/tibbe/haskell-style-guide/tree/master > > and, of course, the GHC style guide. Ah, why does Google not show http://haskell.org/haskellwiki/Category:Style ? Of course, style is a matter of taste. So there are as many good styles as programmers and there won't be an official style guide, I'm afraid. From lemming at henning-thielemann.de Fri Mar 13 21:36:23 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Mar 13 21:24:32 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: References: Message-ID: On Tue, 10 Mar 2009, Conor McBride wrote: > Apologies for crossposting. Please forward this message > to individuals or lists who may be interested. In addition > to the recently advertised PhD position at Strathclyde on > "Reusability and Dependent Types", I am delighted to > advertise the following PhD opportunity. > > {--------------------------------------------------------- > -- Haskell Types with Numeric Constraints ---------------- > ---------------------------------------------------------} Sounds like it could simplify http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dimensional/ a lot. However, isn't this halfheartedly since we all wait for full dependent types? :-) From lemming at henning-thielemann.de Fri Mar 13 21:56:07 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Mar 13 21:44:16 2009 Subject: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr? In-Reply-To: References: Message-ID: On Wed, 11 Mar 2009, R J wrote: > foldl and foldr are defined as follows: > > ? foldr??????????????? :: (a -> b -> b) -> b -> [a] -> b > ? foldr f e []???????? =? e > ? foldr f e (x : xs)?? =? f x (foldr f e xs) > > ? foldl??????????????? :: (b -> a -> b) -> b -> [a] -> b > ? foldl f e []???????? =? e > ? foldl f e (x : xs)?? =? foldl f (f e x) xs > > 1.? I understand how these definitions work, and yet I'm unable to implement foldl in terms > of foldr.? What's a systematic approach to identifying such an implementation, and what is > the implementation? You are lucky, I recently wrote http://haskell.org/haskellwiki/Foldl_as_foldr From lemming at henning-thielemann.de Fri Mar 13 22:05:37 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Mar 13 21:53:45 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: References: Message-ID: On Thu, 12 Mar 2009, Peter Verswyvelen wrote: > I think. Or is it defined in some other package? The 'transformers' package has those instances. From lemming at henning-thielemann.de Fri Mar 13 22:13:50 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Mar 13 22:01:58 2009 Subject: [Haskell-cafe] Abuse of the monad [was: monadic logo] In-Reply-To: References: Message-ID: On Thu, 12 Mar 2009, Andrew Wagner wrote: > Can you expand on this a bit? I'm curious why you think this. http://haskell.org/haskellwiki/Type_classes_are_for_reusability We recently had a thread about that. I can't find it now. From aneumann at inf.fu-berlin.de Sat Mar 14 02:55:35 2009 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sat Mar 14 02:44:01 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] folds -- help! In-Reply-To: <20090310205422.GA1569@colquitt.org> References: <20090310205422.GA1569@colquitt.org> Message-ID: That's why I said "for appropriate g and f". But I see that my wording was misleading. However you can say: > foldl' oplus alpha bs =(foldr f id bs) alpha where > f a g = \alpha -> g (alpha `oplus` a) > > foldr' oplus alpha bs = (foldl f id bs) alpha where > f g a = \alpha -> g (a `oplus` alpha) And it works as long as oplus is strict in both arguments. Am 10.03.2009 um 21:54 schrieb John Dorsey: > Adrian Neumann wrote: > >> Notice that there is no difference between >> >> foldr g a >> foldl f a >> >> (for appropriate g and f) if g and f are strict in both arguments. > > Be careful... as apfelmus noted elsewhere in this thread, that's > not (in > general) true. > > Prelude> foldr (^) 2 [3,5] > 847288609443 > Prelude> foldl (^) 2 [3,5] > 32768 > > The reason? Integer exponentiation (^) isn't associative and > commutative. So the first is (3 ^ (5^2)) = 3^25, while the second is > ((2 ^ 3) ^ 5) = 2^15. > > Cheers, > John > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners -------------- 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/20090314/8bae8007/PGP.bin From bugfact at gmail.com Sat Mar 14 03:12:07 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Mar 14 03:00:15 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: References: Message-ID: I was using the transformers but still had to implement the Applicative instance of State This package contains an applicative instance for StateT but not for State On Sat, Mar 14, 2009 at 3:05 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > > On Thu, 12 Mar 2009, Peter Verswyvelen wrote: > > I think. Or is it defined in some other package? >> > > The 'transformers' package has those instances. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/6f5acd5d/attachment.htm From bugfact at gmail.com Sat Mar 14 03:19:23 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Mar 14 03:07:32 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: References: Message-ID: On Sat, Mar 14, 2009 at 2:36 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > a lot. However, isn't this halfheartedly since we all wait for full > dependent types? :-) > Well, in C++ one can already use the numerical values with templates for achieving a lot of compile time computations. So I would be very happy to have this feature in Haskell. It might also be good research towards full dependent types no? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/9980d8b7/attachment.htm From lists at qseep.net Sat Mar 14 03:45:25 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Sat Mar 14 03:33:33 2009 Subject: [Haskell-cafe] ANNOUNCE: Vintage BASIC 1.0 In-Reply-To: <200903130931.32211.jeltsch@informatik.tu-cottbus.de> References: <670e468e0903122110kf68bf0dt2a00a8a3287c3537@mail.gmail.com> <200903130931.32211.jeltsch@informatik.tu-cottbus.de> Message-ID: <670e468e0903140045ycb5c24ep1f9d7003af6de913@mail.gmail.com> I've posted a new version, 1.0.1, that has a usage message if you run it with no arguments. There is a package for Windows now (not just a binary) as well as Linux. Both packages include documentation and example programs. Thanks for pointing that out! On Fri, Mar 13, 2009 at 1:31 AM, Wolfgang Jeltsch < jeltsch@informatik.tu-cottbus.de> wrote: > When running the executable, nothing happens. The executable should show a > usage message instead. Where are the BASIC programs? I think, you have to > grab them from the source. They should be installed, too. > > Best wishes, > Wolfgang > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/3b4b7343/attachment.htm From mwassell at bigpond.net.au Sat Mar 14 04:10:59 2009 From: mwassell at bigpond.net.au (Mark Wassell) Date: Sat Mar 14 03:59:10 2009 Subject: [Haskell-cafe] Problem with cabal-install where package requires* mutually exclusive versions of another package Message-ID: <49BB6693.7080502@bigpond.net.au> I am trying install a package using cabal-install however the package requies an older version of QuickCheck and one of the required packages requires the latest version: $ cabal fetch Reactive Resolving dependencies... cabal.exe: cannot configure Stream-0.3.1. It requires QuickCheck >=2.0 For the dependency on QuickCheck >=2.0 there are these packages: QuickCheck-2.1 and QuickCheck-2.1.0.1. However none of them are available. QuickCheck-2.1 was excluded because checkers-0.1.3 requires QuickCheck <2.0 QuickCheck-2.1 was excluded because reactive-0.10.5 requires QuickCheck <2.0 QuickCheck-2.1.0.1 was excluded because checkers-0.1.3 requires QuickCheck <2.0 QuickCheck-2.1.0.1 was excluded because reactive-0.10.5 requires QuickCheck <2.0 How can I get around this? I could work around this and install the packages individually. Can I have two versions of a package installed (ie QuickCheck) and will everything get resolved correctly? Mark From colin at colina.demon.co.uk Sat Mar 14 04:39:41 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sat Mar 14 04:27:49 2009 Subject: [Haskell-cafe] How to catch error in array index when debugging Message-ID: I'm getting a runtime failure "Error in array index". This causes ghci to exit. Is there a way to get it to break instead, so I can find out which function is failing? -- Colin Adams Preston Lancashire From perikov at gmail.com Sat Mar 14 05:33:50 2009 From: perikov at gmail.com (Pavel Perikov) Date: Sat Mar 14 05:22:01 2009 Subject: [Haskell-cafe] Vim support for cabal In-Reply-To: References: Message-ID: <1CAC81C7-56B3-4F59-BD3A-19360A5DEEC7@gmail.com> Great ! I'm just starting with Vim so I'm not sure if I could contribute. But I definitely will look into the sources. Thanks! Pavel On 13.03.2009, at 21:44, andy morris wrote: > 2009/3/13 Pavel Perikov : >> Hi caf? ! >> >> I googled for some kind of vim support for cabal but found >> nothing. I mean >> syntax highlighting of .cabal and probably integration with >> haskellmode. Did >> anyone hear about such thing? >> >> Pavel > > I've been wanting something like this as well, so you inspired me to > finally get round to writing it. :D > > I've stuck it on Patch-tag, so: > darcs get http://patch-tag.com/publicrepos/cabal-vim > > Nothing special at the moment; it just highlights field names and does > some basic autoindenting. If you (or someone else on the list) have > any suggestions, then just say (or send a patch if you want :) ) > > I might add to it over the weekend as well (highlighting of compiler > names in the 'tested-on' field, that sort of thing), so perhaps check > back in a few days. From pumpkingod at gmail.com Sat Mar 14 05:40:46 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Sat Mar 14 05:28:53 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: <20090313233437.GI15913@whirlpool.galois.com> References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> <49BAE921.6080705@libero.it> <20090313232115.GF15913@whirlpool.galois.com> <20090313233437.GI15913@whirlpool.galois.com> Message-ID: I have added UAProd-based Binary instances to my copy of the uvector repo at http://patch-tag.com/publicrepos/pumpkin-uvector . I have some extensive tests (added to the existing tests directory) of things in there and they seem to be mostly sane. The Binary code isn't at all pretty right now, and the UnsafeIO (which I'm thinking of renaming to UnsafeBinary, thoughts?) that comes with it is even uglier, but it'll be improving soon. When I clean it up, I'll submit a patch to the main uvector repo and we can see how it goes (maybe at that point we can pull out UIO). Also in that repo are changes that add safety checks to all the functions I know to be unsafe. Due to the fact that these functions would previously crash my tests, I'm currently only testing safe parameter combinations on them, so when I get the tests to check that errors are being thrown appropriately, I'll also submit a patch for that. Cheers, Dan On Fri, Mar 13, 2009 at 7:34 PM, Don Stewart wrote: > I'd like to do away with UIO altogether though. > > pumpkingod: >> The main issue seems to be that although the semantics of UIO may be >> arbitrary, Wallace's patch actually broke deserialization for any >> production-based UArr, and I'm not sure the benefits are worthwhile >> (loading a file someone else sent you) given that endianness is >> already not taken into account when loading (so the chances of someone >> giving you a raw binary file that happens to contain values of the >> correct endianness is rather low, it seems). >> >> On a related note, having a (more) complete testsuite might help >> prevent patches like this from breaking existing functionality. >> >> Maybe a way to resolve the issue is to use the file size and break it >> according to the size of the two halves of the production? This avoids >> prefixing array length, but allows the productions to still work. >> >> Either way, I'm in the process of writing a Binary instance, so maybe >> we can get the best of both worlds eventually. >> >> Thanks, >> Dan >> >> On Fri, Mar 13, 2009 at 7:21 PM, Don Stewart wrote: >> > manlio_perillo: >> >> Don Stewart ha scritto: >> >>> [...] >> >>>> >> >>>> So, the patch is: "just revert this change". >> >>> >> >>> Or... use your own UIO instance. That's why it's a type class! >> >>> >> >> >> >> Why should I rewrite the UIO instance, if one already exists? >> > >> > Oh, because you want different serialization semantics to the >> > (arbitrary) defaults. >> > >> > -- Don >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > From martijn at van.steenbergen.nl Sat Mar 14 05:52:59 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Mar 14 05:41:07 2009 Subject: [Haskell-cafe] Style Guide for Haskell Code In-Reply-To: References: <49B68884.8000206@libero.it> Message-ID: <49BB7E7B.2040302@van.steenbergen.nl> Henning Thielemann wrote: > Of course, style is a matter of taste. So there are as many good styles > as programmers and there won't be an official style guide, I'm afraid. While that is true, it's no valid reason to not have a style guide. Sun's style guide for Java has been very successful, improving legibility of Java code in general. Noone has to adhere to it, but most people do anyway. Martijn. From martijn at van.steenbergen.nl Sat Mar 14 05:58:19 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Mar 14 05:46:26 2009 Subject: [Haskell-cafe] Re: Haskell-Wiki Account registration In-Reply-To: References: Message-ID: <49BB7FBB.7060902@van.steenbergen.nl> Benjamin L.Russell wrote: > Why not ask new users to identify letters in a random bitmapped image > of a string, as is commonly done? Then any new user who still > registers and starts submitting spam can be tracked and moderated. If this doesn't work out we can always use hackage's approach: have someone answer emails requesting new accounts. Martijn. From bulat.ziganshin at gmail.com Sat Mar 14 05:57:30 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Mar 14 05:46:36 2009 Subject: [Haskell-cafe] How to catch error in array index when debugging In-Reply-To: References: Message-ID: <427796131.20090314125730@gmail.com> Hello Colin, Saturday, March 14, 2009, 11:39:41 AM, you wrote: > I'm getting a runtime failure "Error in array index". This causes ghci > to exit. > Is there a way to get it to break instead, so I can find out which > function is failing? i recall two techniques - one is trivially define your own (!) and print index at least. another is to use ghc profiling with -xc RTS option -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ashley at semantic.org Sat Mar 14 06:20:18 2009 From: ashley at semantic.org (Ashley Yakeley) Date: Sat Mar 14 06:08:26 2009 Subject: [Haskell-cafe] Re: Haskell-Wiki Account registration In-Reply-To: References: Message-ID: <49BB84E2.1010408@semantic.org> Henning Thielemann wrote: > > How long will the Wiki account registration be disabled? Would it be > possible to ask a question, that real Haskellers could easily answer, > but a spambot cannot? E.g. "What's Haskell's surname?" It will be re-enabled when an appropriate extension to MediaWiki is installed. An appropriate extension will be installed when MediaWiki is upgraded to a version that supports that. MediaWiki will be upgraded when PHP and MySQL are upgraded. MySQL cannot easily be upgraded on the existing distribution (RHEL AS 3 update 9 with Linux 2.4.21), as various other packages depend on the current version. MySQL will be upgraded when we have a more up-to-date distribution (for instance, Debian 4.0). http://haskell.org/pipermail/haskell/2009-January/020916.html We will have a more up-to-date distribution when a new machine takes over from the existing machine at Yale. I don't know when anyone will have a new machine. This is an overview of which machine does what: http://haskell.org/haskellwiki/Haskell.org_domain -- Ashley Yakeley From aneumann at inf.fu-berlin.de Sat Mar 14 06:24:59 2009 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sat Mar 14 06:13:24 2009 Subject: [Haskell-cafe] How to catch error in array index when debugging In-Reply-To: References: Message-ID: You can use the ghci debugger > http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci- debugger.html it can set breakpoints on exceptions. Am 14.03.2009 um 09:39 schrieb Colin Paul Adams: > I'm getting a runtime failure "Error in array index". This causes ghci > to exit. > > Is there a way to get it to break instead, so I can find out which > function is failing? > -- > Colin Adams > Preston Lancashire > _______________________________________________ > 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/20090314/d63ef3e3/PGP.bin From kowey at darcs.net Sat Mar 14 06:42:37 2009 From: kowey at darcs.net (Eric Kow) Date: Sat Mar 14 06:30:48 2009 Subject: [Haskell-cafe] darcs fundraising drive - only $720 left to go! Message-ID: <20090314104237.GA419@Macintosh.local> Hi everybody, Just a quick update on the fundraising drive. We are trying to raise $1000 to help pay for travel to the upcoming Haskell hackathon (the second of our biannual darcs hacking sprints). So far we have raised $280, so we're almost a third of the way there. Think you can help? Details on this page http://www.darcs.net/donations.html Many thanks! Eric PS. Ultimately, what we are trying to buy is *time*. So if you have a few spare moments in your week, the most generous donation you can make is by offering us a little of your time. Come join us in Utrecht, 17-19 April or on #darcs! Otherwise, we accept Paypal :-) -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/2d77f6ff/attachment.bin From roma at ro-che.info Sat Mar 14 06:51:47 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Sat Mar 14 06:40:31 2009 Subject: [Haskell-cafe] Hashing over equivalence classes Message-ID: <20090314105147.GA7258@flit> Are there some known ways to define hashing (or any other) functions over equivalence classes? I.e. a ~ b => hash(a) == hash(b) where (~) is some equivalence relation. For example, you might want to hash lambda terms modulo alpha-equivalence or hash logical terms with respect to commutativity of (&&) and (||). Often we can choose 'canonical' element from each class and hash it. But (at least, in theory) it's not necessary. So, are there (practical) ways to define hash function without it? -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From claus.reinke at talk21.com Sat Mar 14 06:54:12 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Mar 14 06:42:26 2009 Subject: [Haskell-cafe] How to catch error in array index when debugging References: <427796131.20090314125730@gmail.com> Message-ID: >> I'm getting a runtime failure "Error in array index". This causes ghci >> to exit. > >> Is there a way to get it to break instead, so I can find out which >> function is failing? > > i recall two techniques - one is trivially define your own (!) and > print index at least. another is to use ghc profiling with -xc RTS > option None of which is satisfactory. You might also want to add yourself to this ticket: "index out of range" error message regression http://hackage.haskell.org/trac/ghc/ticket/2669 Claus From manlio_perillo at libero.it Sat Mar 14 07:47:39 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sat Mar 14 07:35:59 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> <49BAE921.6080705@libero.it> <20090313232115.GF15913@whirlpool.galois.com> <20090313233437.GI15913@whirlpool.galois.com> Message-ID: <49BB995B.501@libero.it> Daniel Peebles ha scritto: > I have added UAProd-based Binary instances to my copy of the uvector > repo at http://patch-tag.com/publicrepos/pumpkin-uvector . I have some > extensive tests (added to the existing tests directory) of things in > there and they seem to be mostly sane. > Thanks for the work. I have a question, however. Isn't it possible to write binary serialization code for the generic Stream type? Manlio From g9ks157k at acme.softbase.org Sat Mar 14 08:00:08 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sat Mar 14 07:48:16 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: References: Message-ID: <200903141300.09023.g9ks157k@acme.softbase.org> Am Samstag, 14. M?rz 2009 08:19 schrieb Peter Verswyvelen: > Well, in C++ one can already use the numerical values with templates for > achieving a lot of compile time computations. > > So I would be very happy to have this feature in Haskell. It might also be > good research towards full dependent types no? I doubt that it will be a good thing to include full dependent types into a language with partial functions like Haskell. Conor, is Epigram currently under development? Best wishes, Wolfgang From conor at strictlypositive.org Sat Mar 14 08:12:09 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat Mar 14 08:00:15 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: References: Message-ID: Hi Henning On 14 Mar 2009, at 01:36, Henning Thielemann wrote: > > On Tue, 10 Mar 2009, Conor McBride wrote: > >> Apologies for crossposting. Please forward this message >> to individuals or lists who may be interested. In addition >> to the recently advertised PhD position at Strathclyde on >> "Reusability and Dependent Types", I am delighted to >> advertise the following PhD opportunity. >> >> {--------------------------------------------------------- >> -- Haskell Types with Numeric Constraints ---------------- >> ---------------------------------------------------------} > > Sounds like it could simplify > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ > dimensional/ Hope so. > > a lot. However, isn't this halfheartedly since we all wait for full > dependent types? :-) Rome wasn't burnt in a day. Of course I want more than just numerical indexing (and I even have a plan) but numeric constraints are so useful and have so much of their own peculiar structure that they're worth studying in their own right, even for languages which do have full dependent types, let alone Haskell. We'll carry out this project with an eye to the future, to make sure it's compatible with full dependent types. Be assured (excited, nervous, etc...) that this is not halfhearted: it's a wholehearted start. All the best Conor From grzegorz.chrupala at computing.dcu.ie Sat Mar 14 08:37:44 2009 From: grzegorz.chrupala at computing.dcu.ie (Grzegorz Chrupala) Date: Sat Mar 14 08:25:51 2009 Subject: [Haskell-cafe] Alternative to Data.Binary Message-ID: <22512229.post@talk.nabble.com> Hi all, Is there a serialization library other than the Data.Binary from hackage? I am using Data.Binary in a couple of projects, but I have found its stack and memory usage very hard to control. Its very common that decoding a map or list of non-trivial size uses up all available RAM, or causes a stack overflow. I don't care that much about it being extremely fast, I just want to stop worrying that if I try to read a file a few percent larger than the last time, my program will suddenly stop working. Best, -- Grzegorz -- View this message in context: http://www.nabble.com/Alternative-to-Data.Binary-tp22512229p22512229.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From barsoap at web.de Sat Mar 14 08:54:11 2009 From: barsoap at web.de (Achim Schneider) Date: Sat Mar 14 08:42:33 2009 Subject: [Haskell-cafe] Re: Haskell-Wiki Account registration References: Message-ID: <20090314135411.61cec167@solaris> Henning Thielemann wrote: > > On Fri, 13 Mar 2009, Benjamin L.Russell wrote: > > > Why not ask new users to identify letters in a random bitmapped > > image of a string, as is commonly done? > > I assume, because those images are > 1) not accessible by blind people > 2) can be decoded by spammers, since they know how the images are > generated by common software. > Thus my suggestion was a simple Haskell specific question, which > cannot be answered by stupid spambots. > http://recaptcha.net is believed to be spam-proof, and there's good reasons to believe so, see http://recaptcha.net/security.html : It starts off with text that can't be OCR'd, in the first place. It also features an audio mode for accessibility. Question-based captchas provide security by rarity. You can be sure that if a spammer really, really wants to spam on the wiki, it won't take long before a program is written that memoises all questions and answers. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From haskell at list.mightyreason.com Sat Mar 14 09:09:40 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Sat Mar 14 08:58:03 2009 Subject: [Haskell-cafe] Re: Alternative to Data.Binary In-Reply-To: <22512229.post@talk.nabble.com> References: <22512229.post@talk.nabble.com> Message-ID: <49BBAC94.4020705@list.mightyreason.com> Grzegorz Chrupala wrote: > Hi all, > Is there a serialization library other than the Data.Binary from hackage? Yes. "binary-strict" is one alternative: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict > > I am using Data.Binary in a couple of projects, but I have found its stack > and memory usage very hard to control. Its very common that decoding a map > or list of non-trivial size uses up all available RAM, or causes a stack > overflow. > > I don't care that much about it being extremely fast, I just want to stop > worrying that if I try to read a file a few percent larger than the last > time, my program will suddenly stop working. > > Best, > -- > Grzegorz > From svein.ove at aas.no Sat Mar 14 09:16:33 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sat Mar 14 09:04:40 2009 Subject: [Haskell-cafe] Alternative to Data.Binary In-Reply-To: <22512229.post@talk.nabble.com> References: <22512229.post@talk.nabble.com> Message-ID: <221b53ab0903140616m75031a3ob6493bba2d9987ef@mail.gmail.com> On Sat, Mar 14, 2009 at 1:37 PM, Grzegorz Chrupala wrote: > > Hi all, > Is there a serialization library other than the Data.Binary from hackage? > > I am using Data.Binary in a couple of projects, but I have found its stack > and memory usage very hard to control. Its very common that decoding a map > or list of non-trivial size uses up all available RAM, or causes a stack > overflow. > That little problem appears to be an artifact of the particular Binary instance for lists (the map instance starts by converting to/from a list), and should be fixable in principle, for example by writing them in chunks of 256 elements. That said, the current instance really should only have problems when *writing*, in that it'll force the entire list to figure out its length before it starts writing any of it. That this is not, in fact, the case suggests that the reader should be fixable without changing its on-disk format. -- Svein Ove Aas From manlio_perillo at libero.it Sat Mar 14 09:28:16 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sat Mar 14 09:16:39 2009 Subject: [Haskell-cafe] Alternative to Data.Binary In-Reply-To: <221b53ab0903140616m75031a3ob6493bba2d9987ef@mail.gmail.com> References: <22512229.post@talk.nabble.com> <221b53ab0903140616m75031a3ob6493bba2d9987ef@mail.gmail.com> Message-ID: <49BBB0F0.9020808@libero.it> Svein Ove Aas ha scritto: > On Sat, Mar 14, 2009 at 1:37 PM, Grzegorz Chrupala > wrote: >> Hi all, >> Is there a serialization library other than the Data.Binary from hackage? >> >> I am using Data.Binary in a couple of projects, but I have found its stack >> and memory usage very hard to control. Its very common that decoding a map >> or list of non-trivial size uses up all available RAM, or causes a stack >> overflow. >> > That little problem appears to be an artifact of the particular Binary > instance for lists (the map instance starts by converting to/from a > list), and should be fixable in principle, for example by writing them > in chunks of 256 elements. > I can confirm that reading serialized UArr from uvector package does not cause memory problems. Manlio From conor at strictlypositive.org Sat Mar 14 09:51:35 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat Mar 14 09:39:43 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: <200903141300.09023.g9ks157k@acme.softbase.org> References: <200903141300.09023.g9ks157k@acme.softbase.org> Message-ID: Hi Wolfgang On 14 Mar 2009, at 12:00, Wolfgang Jeltsch wrote: > Am Samstag, 14. M?rz 2009 08:19 schrieb Peter Verswyvelen: >> Well, in C++ one can already use the numerical values with >> templates for >> achieving a lot of compile time computations. >> >> So I would be very happy to have this feature in Haskell. It might >> also be >> good research towards full dependent types no? > > I doubt that it will be a good thing to include full dependent types > into a > language with partial functions like Haskell. I think we could manage quite a bit, though. It seems reasonable to allow types to contain expressions drawn from a total fragment of the value language. Even a tiny fragment (such the expressions built only from fully applied constructors and variables) would be a useful start (vector head, tail, zip, but not vector append). The present capacity for open type functions suggests that it shouldn't be too violent to add some total value-functions (probably with a flag allowing self-certification of totality). We should also ask what the problem is with partiality? I'd far rather have a simplistic Set-based intuition about what values in types might mean, rather than worrying about vectors of length bottom. The other side of that coin is that it makes perfect sense to have partial *computations* in types as long as they're somehow distinguished from total values, and as long as the system remembers not to *run* them until run-time. My point: it isn't all or nothing -- there's a slider here, and we can shift it a bit at a time. > > > Conor, is Epigram currently under development? We've even stopped working on the engine and started working on the chassis. I'm in an intensive teaching block until the end of April, but from May it becomes Priority. The "Reusability and Dependent Types" project studentship will hopefully bring an extra pair of hands, come October. Epigram exists to be stolen from, so I'll be trying to encourage a literate programming style and plenty of blogging. We've spent a lot of time figuring out how to make the system much more open and modular, so it will hopefully prove easier for people to contribute to as well as to burgle. The worst thing about Epigram 1 was just how monolithic and impenetrable the code base became. It was a valuable learning experience but no basis for further progress. This time, we optimize for clarity. I don't see any conflict -- indeed I see considerable synergy -- in working simultaneously on the experimental frontier of dependent type systems and on the pragmatic delivery of their basic benefits via a much more established language like Haskell. Indeed, I think we'll learn more readily about the engineering realities of developing applications with dependent types by doing plenty of the latter. I don't think functional programmers should wait for the next generation of languages to mature before picking up this particular habit... All the best Conor From byorgey at seas.upenn.edu Sat Mar 14 09:58:27 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Mar 14 09:46:33 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 109 - March 14, 2009 Message-ID: <20090314135827.GA30843@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090314 Issue 109 - March 14, 2009 --------------------------------------------------------------------------- Welcome to issue 109 of HWN, a newsletter covering developments in the [1]Haskell community. Congratulations to the authors of RWH on their [2]Jolt award! Some cool libraries released this week (as usual), and some really cool PhD [3]opportunities at Strathclyde. Also, it seems that I was censured last week for not including any quotes in the HWN, which is because tunes.org (which hosts the #haskell logs) was down while I was putting it together. So, this time I've included quotes going back two weeks, I HOPE YOU'RE HAPPY Community News Tom DuBuisson (TomMD) has [4]moved to Portland and will be starting a PhD at Portland State soon. Announcements darcs fundraising drive - only $720 left to go!. Eric Kow [5]announced that [6]donations are still being accepted to help pay for travel to the upcoming Haskell hackathon. So far we have raised $280, so we're almost a third of the way there. Think you can help? Vintage BASIC 1.0. Lyle Kopnicky [7]announced the initial release of [8]Vintage BASIC, an interpreter for microcomputer-era BASIC. Fully unit-tested, it faithfully implements the common elements of the language. On the web site, you can find 102 games from the classic book BASIC Computer Games, all of which run flawlessly. Have fun! ThreadScope: Request for features for the performance tuning of parallel and concurrent Haskell programs. Satnam Singh [9]requested feedback on infrastructure for logging run-time events and a graphical viewer program called [10]ThreadScope. The goal is for these features to make it into the next release of GHC. torch-0.1. Yusaku Hashimoto [11]announced a new unit test framework, [12]torch-0.1. sparsebit 0.5 - Sparse Bitmaps for Pattern Match Coverage. Ki Yung Ahn [13]announced the release of the [14]sparsebit library. This library packages the functional peal paper [15]Sparse Bitmaps for Pattern Match Coverage submitted to ICFP 2009 by Ki Yung Ahn and Tim Sheard. happs-tutorial 0.8. Crieghton Hogg [16]announced the release of [17]happs-tutorial 0.8, which is compatible with [18]happstack-0.2. A number of changes have occurred in this release, including general code cleanup, migration to the new Happstack.Server.SimpleHTTP API, and more. Future 1.1.0 concurrency library. ChrisK [19]announced the [20]future package, which ought to do what C++ standard futures/promises do, plus a bit more. The main operation is forkPromise :: IO a -> IO (Promise a), which sets the "IO a" operation running in a fresh thread; the eventual result can be accessed in many ways (non-blocking, blocking, blocking with timeout). Holumbus-MapReduce 0.0.1. Stefan Schmidt [21]announced three new libraries: [22]Holumbus-MapReduce, [23]Holumbus-Distribution, and [24]Holumbus-Storage, which provide tools for building distributed systems. These libraries are used as the backbone of the [25]Holumbus search engine. Turbinado V0.6. Alson Kemp [26]announced the release of [27]Turbinado 0.6, a Rails-ish Model-View-Controller web serving framework for Haskell. New features include support for CGI serving, statically compiled Layouts, Views, and Controllers, lower case paths, support for cookies and encrypted cookie sessions, easier installation, and support for GHC 6.10. iteratee-0.1.0. John Lato [28]announced the hackage release of [29]iteratee-0.1.0. This library implements enumerators and iteratees [30]as proposed by Oleg Kiselyov. Harpy 0.4.4 - Runtime code generation for x86 machine code. Dirk Kleeblatt [31]announced the release of [32]Harpy 0.4.1, a library for runtime code generation for x86 machine code. The new release features additional Eq instances, support for new prefetching instructions, and some bug fixes. Discussion Suggestion for a Haskell mascot. Maur?cio [33]suggested using a sloth as the Haskell mascot. If you would like to know how to say 'sloth' in just about every language ever, read this thread. Jobs Microsoft PhD Scholarship at Strathclyde. Conor McBride [34]announced another PhD opportunity at Strathclyde, sponsored by Microsoft Research, to investigate the practical and theoretical impact of extending Haskell's type system with numeric expressions (representing sizes, or ranges, or costs, for example) and constraints capturing richer safety properties than are currently managed by static typing. Blog noise [35]Haskell news from the [36]blogosphere. * Braden Shepherdson: [37]Pimp Your XMonad #4: Urgency Hooks. * Thomas M. DuBuisson: [38]Explicit Parallelism via Thread Pools. * Ketil Malde: [39]Current developments. Ongoing development of the biohaskell libraries for bioinformatics. * Philip Wadler: [40]Cafe Scientifique. Philip will be giving a talk, "Proofs are Programs: 19th Century Logic and 21st Century Computing", on Monday in Edinburgh. * Yi: [41]Yi 0.6.0 Release Notes. * Alson Kemp: [42]ANNOUNCE: Turbinado V0.6. * GHC / OpenSPARC Project: [43]Thread activity plotting. * Real-World Haskell: [44]We won a Jolt Award!. * Real-World Haskell: [45]Real World Haskell on the Kindle 2. * Christophe Poucet (vincenz): [46]Bootstrapping cabal. * Gtk2HS: [47]Mickinator File Manager. * Osfameron: [48](rough) Grids in Haskell. Some notes on representing 2D grids in Haskell. * Manuel M T Chakravarty: [49]These graphs summarise the performance of Data Parallel Haskell.... * GHC / OpenSPARC Project: [50]Project midpoint. * GHC / OpenSPARC Project: [51]The GNU Debugger and me. * Don Stewart (dons): [52]Evolving faster Haskell programs. Using genetic algorithms to find optimal flag combinations. * Xmonad: [53]Xmonad and the Gimp. * Xmonad: [54]xmonad on eee. * Mark Wassell: [55]Conversations with a type checker. * Holumbus: [56]Holumbus-MapReduce on Hackage. Some neat libraries for building distributed systems! * Darcs: [57]darcs weekly news #20. * Nick Mudge: [58]First Bay Area Haskell Meeting. * Dan Piponi (sigfpe): [59]Dinatural Transformations and Coends. Quotes of the Week * mmorrow: when i first saw haskell i was like "holy shitfork! that's what i've been trying to do in C for forever!" * pastah: the maybe monad is like cheating. everything is so awesomelly easy. * wli: Monads are like constipation. Comonads are like Ex-Lax. * TomMD: Never trust IO. * Axman6: let blah f x = f (blah f x) in blah ("blah "++) "" * MyCatVerbs: Lazy IO is implemented in terms of unsafePerformIO, you, you, you silly bipedal carbon-based organism. * MyCatVerbs: Amdahl's law is mostly to be used for making people feel depressed. * Axman6: -ddump-occur-anal <- another terrible name... * AchimSchneider: Finite automata don't go bottom in any case, at least not if you don't happen to shoot them and their health drops below zero. * ski: the truth (semantics), the whole truth (completeness), and nothing but the truth (soundness) * f4hy: wait you can do a show on an infinite list?! (I am starting to think haskell is not a programming language, it is evil wizardry) * Baughn: concat $ forM [(1,2), (4,5)] $ \(a,b) -> show (b,a+b) About the Haskell Weekly News New editions are posted to [60]the Haskell mailing list as well as to [61]the Haskell Sequence and [62]Planet Haskell. [63]RSS is also available, and headlines appear on [64]haskell.org. To help create new editions of this newsletter, please see the information on [65]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [66]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://www.realworldhaskell.org/blog/2009/03/12/we-won-a-jolt-award/ 3. http://article.gmane.org/gmane.comp.lang.haskell.general/16944 4. http://tommd.wordpress.com/2009/03/13/explicit-parallelism-via-thread-pools/ 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54758 6. http://www.darcs.net/donations.html 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54652 8. http://www.vintage-basic.net/ 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54521 10. http://raintown.org/threadscope 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54445 12. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/torch 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54436 14. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/sparsebit 15. http://kyagrd.dyndns.org/wiki/SparseBitmapsForPatternMatchCoverage 16. http://www.haskell.org//pipermail/haskell-cafe/2009-March/057305.html 17. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs%2Dtutorial 18. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happstack 19. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54409 20. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/future 21. http://article.gmane.org/gmane.comp.lang.haskell.cafe/54325 22. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Holumbus%2DMapReduce 23. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Holumbus-Distribution 24. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Holumbus-Storage 25. http://www.holumbus.org/redmine/wiki/holumbus 26. http://article.gmane.org/gmane.comp.lang.haskell.general/16953 27. http://www.turbinado.org/ 28. http://article.gmane.org/gmane.comp.lang.haskell.general/16945 29. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/iteratee 30. http://okmij.org/ftp/Haskell/Iteratee/ 31. http://article.gmane.org/gmane.comp.lang.haskell.general/16942 32. http://uebb.cs.tu-berlin.de/harpy/ 33. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/54418 34. http://article.gmane.org/gmane.comp.lang.haskell.general/16944 35. http://planet.haskell.org/ 36. http://haskell.org/haskellwiki/Blog_articles 37. http://braincrater.wordpress.com/2009/03/14/pimp-your-xmonad-4-urgency-hooks/ 38. http://tommd.wordpress.com/2009/03/13/explicit-parallelism-via-thread-pools/ 39. http://blog.malde.org/index.php/2009/03/13/current-developments/ 40. http://wadler.blogspot.com/2009/03/cafe-scientifique.html 41. http://yi-editor.blogspot.com/2009/03/yi-060-release-notes.html 42. http://www.alsonkemp.com/haskell/announce-turbinado-v06/ 43. http://ghcsparc.blogspot.com/2009/03/thread-activity-plotting.html 44. http://www.realworldhaskell.org/blog/2009/03/12/we-won-a-jolt-award/ 45. http://www.realworldhaskell.org/blog/2009/03/13/real-world-haskell-on-the-kindle-2/ 46. http://cpoucet.wordpress.com/2009/03/12/bootstrapping-cabal/ 47. http://haskell.org/gtk2hs/archives/2009/03/10/mickinator-file-manager/ 48. http://greenokapi.net/blog/2009/03/10/rough-grids-in-haskell/ 49. http://justtesting.org/post/85103645 50. http://ghcsparc.blogspot.com/2009/03/project-midpoint.html 51. http://ghcsparc.blogspot.com/2009/03/gnu-debugger-and-me.html 52. http://donsbot.wordpress.com/2009/03/09/evolving-faster-haskell-programs/ 53. http://xmonad.wordpress.com/2009/03/08/xmonad-and-the-gimp/ 54. http://xmonad.wordpress.com/2009/03/08/xmonad-on-eee/ 55. http://www.poundstone.org/blog/?p=23 56. http://holumbus.fh-wedel.de/blog/?p=18 57. http://blog.darcs.net/2009/03/darcs-weekly-news-20.html 58. http://nickmudge.info/?post=115 59. http://blog.sigfpe.com/2009/03/dinatural-transformations-and-coends.html 60. http://www.haskell.org/mailman/listinfo/haskell 61. http://sequence.complete.org/ 62. http://planet.haskell.org/ 63. http://sequence.complete.org/node/feed 64. http://haskell.org/ 65. http://haskell.org/haskellwiki/HWN 66. http://code.haskell.org/~byorgey/code/hwn/ From haskell at colquitt.org Sat Mar 14 10:03:21 2009 From: haskell at colquitt.org (John Dorsey) Date: Sat Mar 14 09:51:29 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] folds -- help! In-Reply-To: References: <20090310205422.GA1569@colquitt.org> Message-ID: <20090314140320.GB1569@colquitt.org> Adrian, > That's why I said "for appropriate g and f". But I see that my > wording was misleading. Thanks for following up! I had thought you were arguing that foldl and foldr were easily and intuitively interchangeable; they're surely not so for beginners. Now I think you're arguing that given strict oplus, each can be generally expressed in terms of the other, allowing for different space/time complexity. Thanks for clarifying. I should have paid more attention to your "appropriate g and f" qualifier. Cheers, John From gue.schmidt at web.de Sat Mar 14 10:05:53 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Sat Mar 14 09:54:16 2009 Subject: [Haskell-cafe] examples for error handling in takusen? Message-ID: Hi, can someone please point me to error handling examples with takusen? I try to run a piece of code with takusen but just get the very sparse "Database.InternalEnumerator.DBException From dan.doel at gmail.com Sat Mar 14 10:26:47 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sat Mar 14 10:14:56 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: References: Message-ID: <200903141026.48632.dan.doel@gmail.com> On Saturday 14 March 2009 8:12:09 am Conor McBride wrote: > Rome wasn't burnt in a day. > > Of course I want more than just numerical indexing (and I even > have a plan) but numeric constraints are so useful and have > so much of their own peculiar structure that they're worth > studying in their own right, even for languages which do have > full dependent types, let alone Haskell. We'll carry out this > project with an eye to the future, to make sure it's compatible > with full dependent types. One should note that ATS, which has recently been generating some excitement, doesn't have "full" dependent types, depending on what exactly you mean by that. For instance, it's dependent typing for integers consist of: 1) A simply typed static/type-level integer type 2) A family of singleton types int(n) parameterized by the static type. For instance, int(5) is the type that contains only the run-time value 5. 3) An existential around the above family for representing arbitrary integers. where, presumably, inspecting a value of the singleton family informs the type system in some way. But, we can already do this in GHC (I'll do naturals): -- datakind nat = Z | S nat data Z data S n -- family linking static and dynamic data NatFam :: * -> * where Z :: NatFam Z S :: NatFam n -> NatFam (S n) -- existential wrapper data Nat where N :: forall n. NatFam n -> Nat Of course, ATS' are built-in, and faster, and the type-level programming is probably easier, but as far as dependent typing goes, GHC is already close (I don't think you'd ever see the above scheme in something like Agda or Coq with 'real' dependent types). And this isn't just limited to integers. If you go look at the quicksort example, you'll see something that when translated to GHC looks like: -- datakind natlist = nil | cons nat natlist data Nil data n ::: l data ListFam :: * -> * where Nil :: ListFam Nil (:::) :: forall n l. NatFam n -> ListFam l -> ListFam (n ::: l) data List where L :: forall l. ListFam l -> List So this sort of type-level vs. value-level duplication with GADTs tying the two together seems to be what is always done in ATS. This may not be as sexy as taking the plunge all the way into dependent typing ala Agda and Coq, but it might be a practical point in the design space that GHC/Haskell-of-the- future could move toward without too much shaking up. And if ATS is any indication, it allows for very efficient code, to boot. :) Cheers, -- Dan From colin at colina.demon.co.uk Sat Mar 14 10:37:32 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sat Mar 14 10:25:42 2009 Subject: [Haskell-cafe] How to catch error in array index when debugging In-Reply-To: (Claus Reinke's message of "Sat\, 14 Mar 2009 10\:54\:12 -0000") References: <427796131.20090314125730@gmail.com> Message-ID: >>>>> "Claus" == Claus Reinke writes: Claus> None of which is satisfactory. You might also want to add Claus> yourself to this ticket: Claus> "index out of range" error message regression Claus> http://hackage.haskell.org/trac/ghc/ticket/2669 How do I do that? -- Colin Adams Preston Lancashire From colin at colina.demon.co.uk Sat Mar 14 10:44:09 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sat Mar 14 10:32:17 2009 Subject: [Haskell-cafe] How to catch error in array index when debugging In-Reply-To: (Adrian Neumann's message of "Sat\, 14 Mar 2009 11\:24\:59 +0100") References: Message-ID: >>>>> "Adrian" == Adrian Neumann writes: Adrian> You can use the ghci debugger >> http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci- Adrian> debugger.html Adrian> it can set breakpoints on exceptions. So i tried adding the -fbreak-on-error flag. It made no difference - it still exited: : Error in array index : interrupted : warning: too many hs_exit()s Adrian> Am 14.03.2009 um 09:39 schrieb Colin Paul Adams: >> I'm getting a runtime failure "Error in array index". This >> causes ghci to exit. >> >> Is there a way to get it to break instead, so I can find out >> which function is failing? -- Colin Adams Preston Lancashire -- Colin Adams Preston Lancashire From wss at cs.nott.ac.uk Sat Mar 14 10:50:09 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Sat Mar 14 10:38:16 2009 Subject: [Haskell-cafe] Uploading files to the wiki Message-ID: I can't manage to upload files to the Haskell wiki. I've tried different browsers, different internet connections, different machines, different operating systems, and different user accounts - all without success. Is this a new anti-spam measure? This is slightly annoying. I was looking to release the next Monad.Reader on the wiki. Thanks for any advice, Wouter From g9ks157k at acme.softbase.org Sat Mar 14 11:09:10 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sat Mar 14 10:57:16 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: References: <200903141300.09023.g9ks157k@acme.softbase.org> Message-ID: <200903141609.10773.g9ks157k@acme.softbase.org> Am Samstag, 14. M?rz 2009 14:51 schrieb Conor McBride: > > Conor, is Epigram currently under development? > > We've even stopped working on the engine and started working on the chassis. > I'm in an intensive teaching block until the end of April, but from May it > becomes Priority. The "Reusability and Dependent Types" project studentship > will hopefully bring an extra pair of hands, come October. This sounds good! > I don't see any conflict -- indeed I see considerable synergy -- in working > simultaneously on the experimental frontier of dependent type systems and > on the pragmatic delivery of their basic benefits via a much more > established language like Haskell. Indeed, I think we'll learn more readily > about the engineering realities of developing applications with dependent > types by doing plenty of the latter. This makes sense indeed. Best wishes, Wolfgang From duncan.coutts at worc.ox.ac.uk Sat Mar 14 11:40:04 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Mar 14 11:28:12 2009 Subject: [Haskell-cafe] Problem with cabal-install where package requires* mutually exclusive versions of another package In-Reply-To: <49BB6693.7080502@bigpond.net.au> References: <49BB6693.7080502@bigpond.net.au> Message-ID: <1237045204.22402.482.camel@localhost> On Sat, 2009-03-14 at 19:10 +1100, Mark Wassell wrote: > I am trying install a package using cabal-install however the package > requies an older version of QuickCheck and one of the required packages > requires the latest version: > > $ cabal fetch Reactive > > Resolving dependencies... > cabal.exe: cannot configure Stream-0.3.1. It requires QuickCheck >=2.0 > For the dependency on QuickCheck >=2.0 there are these packages: > QuickCheck-2.1 and QuickCheck-2.1.0.1. However none of them are available. > QuickCheck-2.1 was excluded because checkers-0.1.3 requires QuickCheck <2.0 > QuickCheck-2.1 was excluded because reactive-0.10.5 requires QuickCheck <2.0 > QuickCheck-2.1.0.1 was excluded because checkers-0.1.3 requires QuickCheck > <2.0 > QuickCheck-2.1.0.1 was excluded because reactive-0.10.5 requires QuickCheck > <2.0 The cabal-install solver does not have enough information to know that it will not break to use multiple versions of QuickCheck so it's looking for a solution involving only one version. It cannot find one of course. A medium term solution here should involve letting packages specify that some of their dependencies are private, ie nothing is re-exported and thus there is no danger of clashes. > How can I get around this? I could work around this and install the > packages individually. Yes. You'll just have to avoid using "cabal install" because that invokes the solver. You can either go back to the runghc Setup method or use the (undocumented) cabal install --only flag. > Can I have two versions of a package installed (ie QuickCheck) and > will everything get resolved correctly? Should do. It will warn you that it's highly likely to break, but if you're confident that it will not then press on. Duncan From duncan.coutts at worc.ox.ac.uk Sat Mar 14 11:43:53 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Mar 14 11:32:01 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <1815851200.20090310235535@gmail.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> <87vdqi862e.fsf@columbia.edu> <20090310194030.GB1077@whirlpool.galois.com> <265663706.20090310224946@gmail.com> <20090310200131.GC1077@whirlpool.galois.com> <1815851200.20090310235535@gmail.com> Message-ID: <1237045433.22402.484.camel@localhost> On Tue, 2009-03-10 at 23:55 +0300, Bulat Ziganshin wrote: > starting with 6.6, ForeignArray access is no-op, so we can just use > obvious Ptr operations (via Storable class) to get unboxed arrays fast > access. so, no more need for those special ByteArray# access operations > > but Array library still old, so any effort based on its spources, got > the same restrictions > > also, ByteArray# may be unpinned, but afaik, this isn't really > important - it can be coerced to Ptr for the period of one operation Actually the fact that they may be unpinned is really important for small allocations like short strings. Pinned allocations are slow and lead to heap fragmentation. Duncan From duncan.coutts at worc.ox.ac.uk Sat Mar 14 11:48:04 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Mar 14 11:36:11 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <1029275363.20090313203044@gmail.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <49BA932A.1040302@libero.it> <20090313170857.GF15913@whirlpool.galois.com> <1029275363.20090313203044@gmail.com> Message-ID: <1237045684.22402.489.camel@localhost> On Fri, 2009-03-13 at 20:30 +0300, Bulat Ziganshin wrote: > Hello Don, > > Friday, March 13, 2009, 8:08:57 PM, you wrote: > > >> What is the reason why you have decided to use unpinned arrays > >> (ByteArray#) instead of pinned arrays (Foreign.Ptr)? > > > They prevent heap fragmentation (and in general are faster). > > you probably mean faster alloc/gc operations, everything else should > be the same Right. Access times are the same. Both are just pointers internally. It is just the allocation time, GC time and extra memory use and lower cache utilisation caused by heap fragmentation. For big arrays it doesn't make much difference. Big ByteArray# allocations get pinned anyway. For small ones, like strings I expect the difference is much more noticeable, though I have not measured it. Using ByteArray# also means we can use ST/runST rather than IO/unsafePerformIO. In general we should prefer heap allocated byte arrays and ST unless we really really want to always use pinned allocations to interact with C libs easily. Duncan From duncan.coutts at worc.ox.ac.uk Sat Mar 14 12:02:06 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Mar 14 11:50:16 2009 Subject: [Haskell-cafe] bytestring vs. uvector In-Reply-To: <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> References: <57526e770903072223w784d6a54xb04a63621aa94a30@mail.gmail.com> <1236496965-sup-5525@existential.local> <7728C45CDA54457FA0579612FFDD77B0@cr3lt> <57526e770903091829j284b46a0w84c843fbd4aaca69@mail.gmail.com> Message-ID: <1237046526.22402.504.camel@localhost> On Mon, 2009-03-09 at 18:29 -0700, Alexander Dunlap wrote: > Thanks for all of the responses! > > So let me see if my summary is accurate here: > > - ByteString is for just that: strings of bytes, generally read off of > a disk. The Char8 version just interprets the Word8s as Chars but > doesn't do anything special with that. Right. So it's only suitable for binary or ASCII (or mixed) formats. > - Data.Text/text library is a higher-level library that deals with > "text," abstracting over Unicode details and treating each element as > a potentially-multibye "character." If you're writing about this on the wiki for people, it's best not to confuse the issue by talking about multibyte anything. We do not describe [Char] as a multibyte encoding of Unicode. We say it is a Unicode string. The abstraction is at the level of Unicode code points. The String type *is* a sequence of Unicode code points. This is exactly the same for Data.Text. It is a sequence of Unicode code points. It is not an encoding. It is not UTF-anything. It does not abstract over Unicode. The Text type is just like the String type but with different strictness and performance characteristics. Both are just sequences of Unicode code points. There is a reasonably close correspondence between Unicode code points and what people normally think of as characters. > - utf8-string is a wrapper over ByteString that interprets the bytes > in the bytestring as potentially-multibye unicode "characters." This on the other hand is an encoding. ByteString is a sequence of bytes and when we interpret that as UTF-8 then we are looking at an encoding of a sequence of Unicode code points. Clear as mud? :-) Duncan From dbueno at gmail.com Sat Mar 14 12:02:17 2009 From: dbueno at gmail.com (Denis Bueno) Date: Sat Mar 14 11:50:30 2009 Subject: [Haskell-cafe] Problem with cabal-install where package requires* mutually exclusive versions of another package In-Reply-To: <1237045204.22402.482.camel@localhost> References: <49BB6693.7080502@bigpond.net.au> <1237045204.22402.482.camel@localhost> Message-ID: <6dbd4d000903140902s6b56bfa2wcd30f90a3911b0fd@mail.gmail.com> On Sat, Mar 14, 2009 at 09:40, Duncan Coutts wrote: > A medium term solution here should involve letting packages specify that > some of their dependencies are private, ie nothing is re-exported and > thus there is no danger of clashes. Is the long term solution to automatically detect what is exported? It seems feasible, since I think that is a totally static property, no? Denis From duncan.coutts at worc.ox.ac.uk Sat Mar 14 12:18:59 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Mar 14 12:07:21 2009 Subject: [Haskell-cafe] Problem with cabal-install where package requires* mutually exclusive versions of another package In-Reply-To: <6dbd4d000903140902s6b56bfa2wcd30f90a3911b0fd@mail.gmail.com> References: <49BB6693.7080502@bigpond.net.au> <1237045204.22402.482.camel@localhost> <6dbd4d000903140902s6b56bfa2wcd30f90a3911b0fd@mail.gmail.com> Message-ID: <1237047539.22402.508.camel@localhost> On Sat, 2009-03-14 at 10:02 -0600, Denis Bueno wrote: > On Sat, Mar 14, 2009 at 09:40, Duncan Coutts > wrote: > > A medium term solution here should involve letting packages specify that > > some of their dependencies are private, ie nothing is re-exported and > > thus there is no danger of clashes. > > Is the long term solution to automatically detect what is exported? > It seems feasible, since I think that is a totally static property, > no? Right I think the long term solution is something that involves identifying packages as functors/signatures and doing subtyping and unification to check if packages can be composed. Duncan From manlio_perillo at libero.it Sat Mar 14 12:38:45 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sat Mar 14 12:26:58 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> <49BAE921.6080705@libero.it> <20090313232115.GF15913@whirlpool.galois.com> <20090313233437.GI15913@whirlpool.galois.com> Message-ID: <49BBDD95.1020600@libero.it> Daniel Peebles ha scritto: > I have added UAProd-based Binary instances to my copy of the uvector > repo at http://patch-tag.com/publicrepos/pumpkin-uvector . I can confirm that it works for me. However I have now a memory problem with data decoding. I need to serialize the Netflix Prize training dataset. When I parse the data from original data set, memory usage is about 640 MB [1]. But when I load the data serialized and compressed, (as [UArr (Word32 *:* Word8)]), memory usage is about 840 MB... The culprit is probably the decoding of the list (17770 elements). [1] I have written a script in Python that parse the data, and it only takes 491 MB (using a list of a tuple with two compact arrays from numpy). So, GHC has memory problems here. Thanks Manlio Perillo From dons at galois.com Sat Mar 14 12:53:17 2009 From: dons at galois.com (Don Stewart) Date: Sat Mar 14 12:42:28 2009 Subject: [Haskell-cafe] Alternative to Data.Binary In-Reply-To: <22512229.post@talk.nabble.com> References: <22512229.post@talk.nabble.com> Message-ID: <20090314165317.GA20923@whirlpool.galois.com> grzegorz.chrupala: > > Hi all, > Is there a serialization library other than the Data.Binary from hackage? > > I am using Data.Binary in a couple of projects, but I have found its stack > and memory usage very hard to control. Its very common that decoding a map > or list of non-trivial size uses up all available RAM, or causes a stack > overflow. > > I don't care that much about it being extremely fast, I just want to stop > worrying that if I try to read a file a few percent larger than the last > time, my program will suddenly stop working. Have you tried the latest release, which modified the Map and [a] instances? -- Don From malcolm.wallace at cs.york.ac.uk Sat Mar 14 12:55:47 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Sat Mar 14 12:43:55 2009 Subject: [Haskell-cafe] Re: Haskell-Wiki Account registration In-Reply-To: <49BB84E2.1010408@semantic.org> References: <49BB84E2.1010408@semantic.org> Message-ID: <09A2707D-E779-4571-89FD-57BBF90051C2@cs.york.ac.uk> On 14 Mar 2009, at 10:20, Ashley Yakeley wrote: > We will have a more up-to-date distribution when a new machine takes > over from the existing machine at Yale. > > I don't know when anyone will have a new machine. The contract with Yale for running the haskell.org machine is due for its yearly renewal in the early summer (around July I think). Various people have already mooted the possibility of re-locating all of the services provided on that machine, by purchasing hosting elsewhere. So we should be aiming to plan which version of which software to install on the new machine, and an orderly transfer of content in that sort of timeframe. Regards, Malcolm From conor at strictlypositive.org Sat Mar 14 13:07:01 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat Mar 14 12:55:09 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: <200903141026.48632.dan.doel@gmail.com> References: <200903141026.48632.dan.doel@gmail.com> Message-ID: <23600486-68A3-4330-86F5-24806BD5EC41@strictlypositive.org> Hi Dan On 14 Mar 2009, at 14:26, Dan Doel wrote: > On Saturday 14 March 2009 8:12:09 am Conor McBride wrote: >> Rome wasn't burnt in a day. >> >> Of course I want more than just numerical indexing (and I even >> have a plan) but numeric constraints are so useful and have >> so much of their own peculiar structure that they're worth >> studying in their own right, even for languages which do have >> full dependent types, let alone Haskell. We'll carry out this >> project with an eye to the future, to make sure it's compatible >> with full dependent types. > > One should note that ATS, which has recently been generating some > excitement, > doesn't have "full" dependent types, depending on what exactly you > mean by > that. I'm really impressed by the results ATS is getting, and by DML before it. I think these systems do a great job of showing what can be gained in performance by improving precision. > > For instance, it's dependent typing for integers consist of: I certainly want > > 1) A simply typed static/type-level integer type which looks exactly like the value-level integers and has a helpful but not exhaustive selection of the same operations. But this... > 2) A family of singleton types int(n) parameterized by the static > type. > For instance, int(5) is the type that contains only the run-time > value 5. > 3) An existential around the above family for representing arbitrary > integers. ...I like less. > where, presumably, inspecting a value of the singleton family > informs the type > system in some way. But, we can already do this in GHC (I'll do > naturals): > > -- datakind nat = Z | S nat > data Z > data S n > > -- family linking static and dynamic > data NatFam :: * -> * where > Z :: NatFam Z > S :: NatFam n -> NatFam (S n) > > -- existential wrapper > data Nat where > N :: forall n. NatFam n -> Nat > > Of course, ATS' are built-in, and faster, and the type-level > programming is > probably easier, but as far as dependent typing goes, GHC is already > close (I > don't think you'd ever see the above scheme in something like Agda > or Coq with > 'real' dependent types). Which is why I'd rather not have to do that in Haskell either. It really hurts to go through this rigmarole to make this weird version of Nat. I'd much rather figure out how to re-use the existing datatype Nat. Also, where the GADT coding really doesn't compete with ATS is in dealing with constraints on indices that go beyond unification -- numbers have more structure and deserve special attention. Numerical indexing systems need to carry a big stick for "boring algebra" if we're to gain the power but keep the weight down. But wherever possible, I'd prefer to avoid doing things an awkward way, just because we don't quite have dependent types. If the above kludge is really necessary, then it should at least be machine- generated behind the scenes from ordinary Nat. I'd much rather be able to lift a type to a kind than have a separate datakind feature. Apart from anything else, when you get around to indexed kinds, what you gonna index /them/ with? Long term, I'd far rather think about how to have some sort of dependent functions and tuples than muddle along with singletons and weak existentials. > So this sort of type-level vs. value-level duplication with GADTs > tying the > two together seems to be what is always done in ATS. This may not be > as sexy > as taking the plunge all the way into dependent typing ala Agda and > Coq, but > it might be a practical point in the design space that GHC/Haskell- > of-the- > future could move toward without too much shaking up. And if ATS is > any > indication, it allows for very efficient code, to boot. :) I'd certainly agree that ATS demonstrates the benefits of moving in this direction, but I think we can go further than you suggest, avoiding dead ends in the design space, and still without too much shaking up. I don't think the duplicate-or-plunge dilemma you pose exhausts the options. At least, I seem no reason to presume so and I look forward to finding out! To be honest, I think the real challenge is to develop good libraries and methodologies for working with indexed types (and particularly, indexed notions of computation: what's the indexed mtl?). There are lots of promising ideas around, but it's hard to build something that scales whilst the encodings are so clunky. A bit of language design, even just to package existing functionality more cleanly, would really kick the door open. And yes, I am writing a research proposal. All the best Conor From grzegorz.chrupala at computing.dcu.ie Sat Mar 14 13:07:52 2009 From: grzegorz.chrupala at computing.dcu.ie (Grzegorz Chrupala) Date: Sat Mar 14 12:55:58 2009 Subject: [Haskell-cafe] Alternative to Data.Binary In-Reply-To: <20090314165317.GA20923@whirlpool.galois.com> References: <22512229.post@talk.nabble.com> <20090314165317.GA20923@whirlpool.galois.com> Message-ID: <22514771.post@talk.nabble.com> Don Stewart-2 wrote: > > Have you tried the latest release, which modified the Map and [a] > instances? > No, I'm working with 0.5. I'll give the new version a try. Thanks! -- Grzegorz -- View this message in context: http://www.nabble.com/Alternative-to-Data.Binary-tp22512229p22514771.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From malcolm.wallace at cs.york.ac.uk Sat Mar 14 13:20:52 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Sat Mar 14 13:09:23 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> <49BAE921.6080705@libero.it> <20090313232115.GF15913@whirlpool.galois.com> Message-ID: > The main issue seems to be that although the semantics of UIO may be > arbitrary, Wallace's patch actually broke deserialization for any > production-based UArr, and I'm not sure the benefits are worthwhile > (loading a file someone else sent you) given that endianness is > already not taken into account when loading (so the chances of someone > giving you a raw binary file that happens to contain values of the > correct endianness is rather low, it seems). In my experience, having written several libraries in Haskell for serialisation and deserialisation, it is highly problematic when a library writer decides that all data to be stored began its life in Haskell, and is only being serialised in order to be read back in again by the same Haskell library. I have already made that mistake myself in two different libraries now, eventually regretting it (and fixing it). The real utility of serialisation is when it is possible to read data from any arbitrary external source, and to write data according to external standards. A library that can only read and write data in its own idiosyncratic format is not production-ready at all. This is why I submitted the patch that enables the uvector library to read raw binary data that was not produced by itself. I had 300Gb of data from an external source that I needed to deal with efficiently, and uvector was the ideal candidate apart from this small design flaw. And yes, my code also had to deal with endianness conversion on this data. Regards, Malcolm From marcin.kosiba at gmail.com Sat Mar 14 13:44:59 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Sat Mar 14 13:33:22 2009 Subject: [Haskell-cafe] Using a monad to decompose a function into functions In-Reply-To: References: <200903130934.28466.marcin.kosiba@gmail.com> <200903131738.14126.marcin.kosiba@gmail.com> Message-ID: <200903141845.04206.marcin.kosiba@gmail.com> Skipped content of type multipart/mixed-------------- 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/20090314/b2112831/attachment.bin From pumpkingod at gmail.com Sat Mar 14 14:28:12 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Sat Mar 14 14:16:18 2009 Subject: [Haskell-cafe] broken IO support in uvector package, when using non primitive types In-Reply-To: References: <49BABF8B.4030304@libero.it> <200903132146.42922.daniel.is.fischer@web.de> <49BAE34E.6000305@libero.it> <20090313225353.GC15913@whirlpool.galois.com> <49BAE921.6080705@libero.it> <20090313232115.GF15913@whirlpool.galois.com> Message-ID: I'm sorry, I didn't mean to imply otherwise. I can see your point, but maybe it would be even more flexible in that kind of situation to keep a separate UIO-like API that allows one to explicitly request a particular size? For your large dataset, you could specify the entire filesize (divided by the size of your elements, maybe) while Manlio could take care of storing his array sizes in a different form if necessary. The semantics of UIO loading could then become "I have a large chunk of data on a handle that I need to load verbatim; tell me how much to load", which would work on pipes, sockets, and other non-file sources, as well as still being useful in your case of having enormous amounts of data. Anyway, I'm clearly in no position to be deciding on significant API changes for uvector, but having more than one option in a high-performance library like this seems like a good thing. Cheers, Dan On Sat, Mar 14, 2009 at 1:20 PM, Malcolm Wallace wrote: >> The main issue seems to be that although the semantics of UIO may be >> arbitrary, Wallace's patch actually broke deserialization for any >> production-based UArr, and I'm not sure the benefits are worthwhile >> (loading a file someone else sent you) given that endianness is >> already not taken into account when loading (so the chances of someone >> giving you a raw binary file that happens to contain values of the >> correct endianness is rather low, it seems). > > In my experience, having written several libraries in Haskell for > serialisation and deserialisation, it is highly problematic when a library > writer decides that all data to be stored began its life in Haskell, and is > only being serialised in order to be read back in again by the same Haskell > library. ?I have already made that mistake myself in two different libraries > now, eventually regretting it (and fixing it). > > The real utility of serialisation is when it is possible to read data from > any arbitrary external source, and to write data according to external > standards. ?A library that can only read and write data in its own > idiosyncratic format is not production-ready at all. > > This is why I submitted the patch that enables the uvector library to read > raw binary data that was not produced by itself. ?I had 300Gb of data from > an external source that I needed to deal with efficiently, and uvector was > the ideal candidate apart from this small design flaw. ?And yes, my code > also had to deal with endianness conversion on this data. > > Regards, > ? ?Malcolm > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Sat Mar 14 14:36:33 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Mar 14 14:24:39 2009 Subject: [Haskell-cafe] Hashing over equivalence classes In-Reply-To: <20090314105147.GA7258@flit> References: <20090314105147.GA7258@flit> Message-ID: <2f9b2d30903141136o2b14cbfbg6356ec4064355154@mail.gmail.com> For the second case you might be able to come up with a commutative hash-combiner function for && and ||. For the lambda-term situation, I can think of a couple ways to hash that give what you want. (1) Ignore variable names altogether while hashing; this gives you what you want but has the disadvantage that (\a b. a) and (\a b. b) hash to the same value. (2) Hash the term with de Bruijn indices. But this is the same as "hash the canonical element". I don't see that you have much other choice, though. Fortunately, due to laziness, hash . canonicalize should not have much worse space behavior than just hash. Did you have something else in mind? -- ryan On Sat, Mar 14, 2009 at 3:51 AM, Roman Cheplyaka wrote: > Are there some known ways to define hashing (or any other) functions over > equivalence classes? I.e. > > ?a ~ b => hash(a) == hash(b) > > where (~) is some equivalence relation. For example, you might want to > hash lambda terms modulo alpha-equivalence or hash logical terms with > respect to commutativity of (&&) and (||). > > Often we can choose 'canonical' element from each class and hash it. > But (at least, in theory) it's not necessary. So, are there (practical) > ways to define hash function without it? > > -- > Roman I. Cheplyaka :: http://ro-che.info/ > "Don't let school get in the way of your education." - Mark Twain > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dan.doel at gmail.com Sat Mar 14 14:48:29 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sat Mar 14 14:36:38 2009 Subject: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: <23600486-68A3-4330-86F5-24806BD5EC41@strictlypositive.org> References: <200903141026.48632.dan.doel@gmail.com> <23600486-68A3-4330-86F5-24806BD5EC41@strictlypositive.org> Message-ID: <200903141448.29776.dan.doel@gmail.com> On Saturday 14 March 2009 1:07:01 pm Conor McBride wrote: > But this... > > > 2) A family of singleton types int(n) parameterized by the static > > type. > > For instance, int(5) is the type that contains only the run-time > > value 5. > > 3) An existential around the above family for representing arbitrary > > integers. > > ...I like less. Well, I don't actually like it, either. Finding this out rather disappointed me. > I'd certainly agree that ATS demonstrates the benefits of moving > in this direction, but I think we can go further than you suggest, > avoiding dead ends in the design space, and still without too > much shaking up. I don't think the duplicate-or-plunge dilemma you > pose exhausts the options. At least, I seem no reason to presume > so and I look forward to finding out! I didn't mean to suggest that ATS is the best you can do. Merely that you can still get a lot done without going very far beyond what is technically possible (though not enjoyable) in GHC today (to the point that people will actually categorize your language as "dependently typed" when it merely has a type language comparable in richness and convenience to the value level, but is still mostly separate). So adding more faux dependent typing (like ATS or Omega) isn't just wasting time when we should be figuring out how to compile Agda efficiently, because simply making type-level programming easy, while maintaining a strict divide between values and types may well be good enough in practice, until the Agdas and Epigrams come into their own. If you can do better than ATS, and have value-level stuff automatically reproduced at the type level and suchlike, so much the better. I fully support that. :) -- Dan From manlio_perillo at libero.it Sat Mar 14 15:13:20 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sat Mar 14 15:01:43 2009 Subject: [Haskell-cafe] Alternative to Data.Binary In-Reply-To: <20090314165317.GA20923@whirlpool.galois.com> References: <22512229.post@talk.nabble.com> <20090314165317.GA20923@whirlpool.galois.com> Message-ID: <49BC01D0.90908@libero.it> Don Stewart ha scritto: > grzegorz.chrupala: >> Hi all, >> Is there a serialization library other than the Data.Binary from hackage? >> >> I am using Data.Binary in a couple of projects, but I have found its stack >> and memory usage very hard to control. Its very common that decoding a map >> or list of non-trivial size uses up all available RAM, or causes a stack >> overflow. >> > [...] > Have you tried the latest release, which modified the Map and [a] > instances? > Tried right now. My [UArr (Word32 :*: Word8)], where the list length is 17770, now requires 660 MB of memory, when decoding, against 840 MB with the previous version of the binary package. This is fantastic, thanks! Regards Manlio From barsoap at web.de Sat Mar 14 15:27:00 2009 From: barsoap at web.de (Achim Schneider) Date: Sat Mar 14 15:15:20 2009 Subject: [Haskell-cafe] Re: Alternative to Data.Binary References: <22512229.post@talk.nabble.com> Message-ID: <20090314202700.1afbc8d7@solaris> Grzegorz Chrupala wrote: > > Hi all, > Is there a serialization library other than the Data.Binary from > hackage? > There are Iteratees[1]. They're still grok-in-process___ community-wise They are (afaik) currently only used for file input, though it's certainly possible to enumerate a data structure and have an iteratee do the output. Hmmm. Output-iteratees are a very, very, interesting thing to think about. [3] Anyway, they'd almost certainly annihilate all your worries about resource usage. [1] The original: http://okmij.org/ftp/Haskell/Iteratee/ Cabalised and improved (e.g. seek performance, identifier capitalisation): http://inmachina.net/~jwlato/haskell/iteratee/ Monadic Regions[2] might shed some light on Oleg's train of thought regarding all this [2] http://www.cs.rutgers.edu/~ccshan/capability/region-io.pdf [3] Which is just another way of saying "I'd rather shut up now, let me try it first" -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From claus.reinke at talk21.com Sat Mar 14 16:33:13 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Mar 14 16:21:23 2009 Subject: [Haskell-cafe] How to catch error in array index when debugging References: <427796131.20090314125730@gmail.com> Message-ID: <789E839B1B2041DC930A3E1C4E1C929A@cr3lt> > Claus> None of which is satisfactory. You might also want to add > Claus> yourself to this ticket: > > Claus> "index out of range" error message regression > Claus> http://hackage.haskell.org/trac/ghc/ticket/2669 > > How do I do that? Ghc Trac's idea of voting is by adding yourself to the cc, so that tickets can be sorted by length of cc list: http://hackage.haskell.org/trac/ghc/report/17 That is often subverted by closing tickets as duplicate/related, without transferring the cc list to the one ticket that is kept;-) Apart from the immediate bug of not getting any information, there's also the more general issue of wanting information about the call site (who called which operation, leading to the exception). A solution to that issue has been sought for a long time, but there seem to be so many options that the discussion has slowed down to a halt: Lexical call site string http://hackage.haskell.org/trac/ghc/ticket/960 Maintaining an explicit call stack http://hackage.haskell.org/trac/ghc/wiki/ExplicitCallStack Using your own wrappers to give you the missing information is probably the best short-term workaround, but it is no fun. Something like this, perhaps: import qualified Data.Array.IArray as A import Control.Exception arr ! index = mapException (addErrorInfo (" ! "++show index)) $ arr A.! index arr // idxs = mapException (addErrorInfo (" // "++show idxs)) $ arr A.// idxs addErrorInfo info (ErrorCall str) = ErrorCall (str++":"++info) test1 i = (A.array (1,5) [(i,i)|i<-[1..5]] :: A.Array Int Int) ! i test2 i = (A.array (1,5) [(i,i)|i<-[1..5]] :: A.Array Int Int) // [(i,0)] *Main> test1 0 *** Exception: Error in array index: ! 0 *Main> test1 3 3 *Main> test1 8 *** Exception: Error in array index: ! 8 *Main> test2 0 array *** Exception: Error in array index: // [(0,0)] *Main> test2 4 array (1,5) [(1,1),(2,2),(3,3),(4,0),(5,5)] *Main> test2 7 array *** Exception: Error in array index: // [(7,0)] Claus From rj248842 at hotmail.com Sat Mar 14 16:45:04 2009 From: rj248842 at hotmail.com (R J) Date: Sat Mar 14 16:33:10 2009 Subject: [Haskell-cafe] Proof of induction case of simple foldl identity. Message-ID: Can someone provide the induction-case proof of the following identity: foldl (-) ((-) x y) ys = (foldl (-) x ys) - y If foldl is defined as usual: foldl :: (b -> a -> b) -> b -> [a] -> b foldl f e [] = e foldl f e (x : xs) = myFoldl f (f e x) xs The first two cases, _|_ and [], are trivial. Here's my best attempt at the (y : ys) case (the left and right sides reduce to expressions that are obviously equal, but I don't know how to show it): Case (y : ys). Left-side reduction: foldl (-) ((-) x y) (y : ys) = {second equation of "foldl"} foldl (-) ((-) ((-) x y) y) ys = {notation} foldl (-) ((-) (x - y) y) ys = {notation} foldl (-) ((x - y) - y) ys = {arithmetic} foldl (-) (x - 2 * y) ys Right-side reduction: (foldl (-) x (y : ys)) - y = {second equation of "foldl"} (foldl (-) ((-) x y) ys) - y = {induction hypothesis: foldl (-) ((-) x y) ys = (foldl (-) x ys) - y} ((foldl (-) x ys) - y) - y = {arithmetic} (foldl (-) x ys) - 2 * y Thanks as always. _________________________________________________________________ Express your personality in color! Preview and select themes for Hotmail?. http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/cf5f90f9/attachment.htm From anton.tayanovskyy at gmail.com Sat Mar 14 17:10:12 2009 From: anton.tayanovskyy at gmail.com (Anton Tayanovskyy) Date: Sat Mar 14 16:58:19 2009 Subject: [Haskell-cafe] building c-callable shared objects and dlls with Haskell Message-ID: Hello, What's the current best practice to build shared objects / dlls to call Haskell from C? I think I figured out the basics, but I would like to understand the picture completely and document the current state of affairs in the Haskell wiki. In particular, I'd like to make sure that the shared libraries are usable from multiple applications, and ideally that applications can dynamically link to multiple shared libraries built from Haskell. I was trying to do that to call Pandoc from C, and the information was rather scattered. Here are two links that I used: http://www.haskell.org/haskellwiki/Calling_Haskell_from_C http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html Based on that information, I was able to compile and run small examples. However, I'm not sure I completely understand how it works in production. Specifically, for the UNIX version, I followed a recipe for loading and unloading the Haskell runtime with library constructors/destructors: #include static void library_init(void) __attribute__((constructor)); static void library_init(void) { hs_init(..); } static void library_exit(void) __attribute__((destructor)); static void library_exit(void) { hs_exit(); } Does this work correctly? Another concern is that every library compiled this way will include its own copy of the Haskell runtime. Will there be problems when using multiple libraries? For the Windows counterpart, there is this very suspicious code I adapted from the GHC user guide: #include #include extern void __stginit_LibPandoc(void); BOOL STDCALL DllMain( HANDLE hModule, DWORD reason, void* reserved) { if (reason == DLL_PROCESS_ATTACH) { static char* args[] = { "ghcDll", NULL }; startupHaskell(1, args, __stginit_LibPandoc); } return TRUE; } It does not seem to unload the Haskell runtime, indeed the Guide warns that it is unsafe to do so from DllMain. What are the implications of this? Thanks! --A From conor at strictlypositive.org Sat Mar 14 17:15:40 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat Mar 14 17:03:47 2009 Subject: the nearly dependent near future, was Re: [Haskell-cafe] Microsoft PhD Scholarship at Strathclyde In-Reply-To: <200903141448.29776.dan.doel@gmail.com> References: <200903141026.48632.dan.doel@gmail.com> <23600486-68A3-4330-86F5-24806BD5EC41@strictlypositive.org> <200903141448.29776.dan.doel@gmail.com> Message-ID: Hi Dan On 14 Mar 2009, at 18:48, Dan Doel wrote: > On Saturday 14 March 2009 1:07:01 pm Conor McBride wrote: >> I don't think the duplicate-or-plunge dilemma you >> pose exhausts the options. At least, I seem no reason to presume >> so and I look forward to finding out! > > I didn't mean to suggest that ATS is the best you can do. Merely > that you can > still get a lot done without going very far beyond what is technically > possible (though not enjoyable) in GHC today (to the point that > people will > actually categorize your language as "dependently typed" when it > merely has a > type language comparable in richness and convenience to the value > level, but > is still mostly separate). I'd certainly agree with that assessment. [..] > If you can do better than ATS, and have value-level stuff > automatically > reproduced at the type level and suchlike, so much the better. I > fully support > that. :) Good! 'Cos that's what I'm going for. It certainly won't involve types depending on arbitrary expressions -- or even on run-time data in the first instance -- but by taking the approach of lifting what we can from types to kinds and from values to types, we keep those options open, as well as hiding the cruft. Note: subject about to slide into something a tad more technical, but I gotta tell you this one... To echo your remarks above, I'm pretty sure one could go quite far even with something as non-invasive as a GHC preprocessor. My opening gambit would be to extend the grammar of kinds as follows, with a translation (#) back to current kinds: kind ::= * #* = * | kind -> kind #(j -> k) = #j -> #k | {type} #{t} = * | forall x :: kind. kind #(forall x :: j. k) = #k Note that this forall abstracts type-level stuff in a given kind, not kinds themselves, so the bound variable can only occur inside the {..} used to lift types up to kinds. Correspondingly, when we smash the {t} kinds all to *, we can dump the polymorphism. Now populate the {t} kinds by lifting expressions to the type level: these look like {e} where e :: t is built from fully applied constructors and variables. That's certainly a total fragment! The preprocessor will need to cook up the usual bunch of gratuitous type constructors, one for each data constructor used inside {..} in order to translate expressions to types. It will need to perform tighter checks on class and data declarations (ideally by constructing objects one level down which express an equivalent typing problem) but GHC already has the necessary functionality to check programs. It might be possible to cut down on the amount of {..} you need to festoon your code with. On the other hand, it might be good to delimit changes of level clearly, especially given existing namespace policies. It's not much but it's a start, it's super-cheap, and it's compatible with a much more sophisticated future. I program in this language already, then I comment out the kinds and types I want and insert their translations by hand. At the moment, I have to write types like data Case :: ({a} -> *) -> ({b} -> *) -> {Either a b} -> * where InL :: f {a} -> Case f g {Left a} InR :: g {b} -> Case f g {Right b} rather than programs like, er... "either". But perhaps we could also figure out how to translate "either" to a type function. However, the numeric constraints project will need more than a preprocessor, because it delivers specific new constraint-solving functionality during type inference, rather than just the precooking of first-order value unification problems as first-order type unification problems. Indeed, with rank-n types, it could be quite fun. I'm sure there are devils yet in details, but the prospects for not-quite-dependent types by re-use rather than hard labour look quite good, and forwards-compatible with yer actual dependent functions, etc, further down the line. We live in interesting times! All the best Conor From dons at galois.com Sat Mar 14 17:21:15 2009 From: dons at galois.com (Don Stewart) Date: Sat Mar 14 17:10:12 2009 Subject: [Haskell-cafe] What's new on Hackage this week? March 14, 2009 Message-ID: <20090314212115.GK21094@whirlpool.galois.com> http://archhaskell.wordpress.com/2009/03/14/arch-haskell-news-mar-14-2009/ A regular update of Haskell in Arch Linux Arch now has 974 Haskell packages in AUR. That?s 12 new packages this week, and lots of updates as well. See the blog for the full list of updates. -- Don From heringtonlacey at mindspring.com Sat Mar 14 17:22:55 2009 From: heringtonlacey at mindspring.com (Dean Herington) Date: Sat Mar 14 17:11:10 2009 Subject: [Haskell-cafe] Proof of induction case of simple foldl identity. In-Reply-To: References: Message-ID: At 8:45 PM +0000 3/14/09, R J wrote: >Can someone provide the induction-case proof of the following identity: > > foldl (-) ((-) x y) ys = (foldl (-) x ys) - y > >If foldl is defined as usual: > > foldl :: (b -> a -> b) -> b -> [a] -> b > foldl f e [] = e > foldl f e (x : xs) = myFoldl f (f e x) xs > >The first two cases, _|_ and [], are trivial. > >Here's my best attempt at the (y : ys) case (the left and right >sides reduce to expressions that are obviously equal, but I don't >know how to show it): > > Case (y : ys). Careful. Your introduced variables y and ys already appear in the equation to be proved. Try introducing fresh variables. > > Left-side reduction: > > foldl (-) ((-) x y) (y : ys) > = {second equation of "foldl"} > foldl (-) ((-) ((-) x y) y) ys > = {notation} > foldl (-) ((-) (x - y) y) ys > = {notation} > foldl (-) ((x - y) - y) ys > = {arithmetic} > foldl (-) (x - 2 * y) ys > > Right-side reduction: > > (foldl (-) x (y : ys)) - y > = {second equation of "foldl"} > (foldl (-) ((-) x y) ys) - y > = {induction hypothesis: foldl (-) ((-) x y) ys = (foldl (-) x ys) - y} > ((foldl (-) x ys) - y) - y > = {arithmetic} > (foldl (-) x ys) - 2 * y > >Thanks as always. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/778c726e/attachment.htm From daniel.is.fischer at web.de Sat Mar 14 17:25:21 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Mar 14 17:13:25 2009 Subject: [Haskell-cafe] Proof of induction case of simple foldl identity. In-Reply-To: References: Message-ID: <200903142225.21291.daniel.is.fischer@web.de> Am Samstag, 14. M?rz 2009 21:45 schrieb R J: > Can someone provide the induction-case proof of the following identity: > > foldl (-) ((-) x y) ys = (foldl (-) x ys) - y > > If foldl is defined as usual: > > foldl :: (b -> a -> b) -> b -> [a] -> b > foldl f e [] = e (R) foldl f e (x : xs) = foldl f (f e x) xs > > The first two cases, _|_ and [], are trivial. > > Here's my best attempt at the (y : ys) case (the left and right sides > reduce to expressions that are obviously equal, but I don't know how to > show it): > > Case (y : ys). > > Left-side reduction: > > foldl (-) ((-) x y) (y : ys) > = {second equation of "foldl"} > foldl (-) ((-) ((-) x y) y) ys > = {notation} > foldl (-) ((-) (x - y) y) ys > = {notation} > foldl (-) ((x - y) - y) ys > = {arithmetic} > foldl (-) (x - 2 * y) ys > > Right-side reduction: > > (foldl (-) x (y : ys)) - y > = {second equation of "foldl"} > (foldl (-) ((-) x y) ys) - y > = {induction hypothesis: foldl (-) ((-) x y) ys = (foldl (-) x ys) - > y} ((foldl (-) x ys) - y) - y > = {arithmetic} > (foldl (-) x ys) - 2 * y > > Thanks as always. > Consider a one-element list. foldl (-) (x-y) [z] = (x-y)-z (foldl (-) x [z]) - y = (x-z)-y So a necessary condition for the identity to generally hold is that the Num instance obeys the law (L) forall u v w. (u - v) - w = (u - v) - w Then take as inductive hypothesis that zs is a list such that forall a b. foldl (-) (a-b) zs = (foldl (-) a zs) - b Let z be an arbitrary value of appropriate type, x and y too. Then foldl (-) (x - y) (z:zs) = foldl (-) ((x-y)-z) zs (R) = (foldl (-) (x-y) zs) - z (IH, a = x-y, b = z) = ((foldl (-) x zs) - y) - z (IH, a = x, b = y) = ((foldl (-) x zs) - z) - y (L, u = foldl (-) x zs, v = y, w = z) = (foldl (-) (x-z) zs) - y (IH, a = x, b = z) = (foldl (-) x (z:zs)) - y (R) The trick is to formulate the inductive hypothesis with enough generality, so you have strong foundations to build on. From lemming at henning-thielemann.de Sat Mar 14 17:32:11 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Mar 14 17:20:21 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <000001c9a387$0eab4e70$2c01eb50$%spezzano@chariot.net.au> References: <000001c9a387$0eab4e70$2c01eb50$%spezzano@chariot.net.au> Message-ID: On Fri, 13 Mar 2009, Mark Spezzano wrote: > 1.? Don?t bother. Just use Integer. > > 2.? Use the type > > data Natural = Zero | Succ !Natural > > 3.? Use the following definition taken from the Gentle Introduction to Haskell 98 > > newtype Natural = MakeNatural Integer This option looks like non-negative package. From marcin.kosiba at gmail.com Sat Mar 14 17:44:55 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Sat Mar 14 17:33:12 2009 Subject: [Haskell-cafe] Proof of induction case of simple foldl identity. In-Reply-To: <200903142225.21291.daniel.is.fischer@web.de> References: <200903142225.21291.daniel.is.fischer@web.de> Message-ID: <200903142244.59748.marcin.kosiba@gmail.com> On Saturday 14 March 2009, Daniel Fischer wrote: > Am Samstag, 14. M?rz 2009 21:45 schrieb R J: > > Can someone provide the induction-case proof of the following identity: > > > > foldl (-) ((-) x y) ys = (foldl (-) x ys) - y > > > > If foldl is defined as usual: > > > > foldl :: (b -> a -> b) -> b -> [a] -> b > > foldl f e [] = e > > (R) foldl f e (x : xs) = foldl f (f e x) xs > > > The first two cases, _|_ and [], are trivial. > > > > Here's my best attempt at the (y : ys) case (the left and right sides > > reduce to expressions that are obviously equal, but I don't know how to > > show it): > > > > Case (y : ys). > > > > Left-side reduction: > > > > foldl (-) ((-) x y) (y : ys) > > = {second equation of "foldl"} > > foldl (-) ((-) ((-) x y) y) ys > > = {notation} > > foldl (-) ((-) (x - y) y) ys > > = {notation} > > foldl (-) ((x - y) - y) ys > > = {arithmetic} > > foldl (-) (x - 2 * y) ys > > > > Right-side reduction: > > > > (foldl (-) x (y : ys)) - y > > = {second equation of "foldl"} > > (foldl (-) ((-) x y) ys) - y > > = {induction hypothesis: foldl (-) ((-) x y) ys = (foldl (-) x ys) > > - y} ((foldl (-) x ys) - y) - y > > = {arithmetic} > > (foldl (-) x ys) - 2 * y > > > > Thanks as always. > > Consider a one-element list. > foldl (-) (x-y) [z] = (x-y)-z > (foldl (-) x [z]) - y = (x-z)-y > > So a necessary condition for the identity to generally hold is that the Num > instance obeys the law > > (L) forall u v w. (u - v) - w = (u - v) - w Typo? :) (L) forall u v w. (u - v) - w = (u - w) - v > Then take as inductive hypothesis that zs is a list such that > forall a b. foldl (-) (a-b) zs = (foldl (-) a zs) - b > > Let z be an arbitrary value of appropriate type, x and y too. > Then > > foldl (-) (x - y) (z:zs) > = foldl (-) ((x-y)-z) zs (R) > = (foldl (-) (x-y) zs) - z (IH, a = x-y, b = z) > = ((foldl (-) x zs) - y) - z (IH, a = x, b = y) > = ((foldl (-) x zs) - z) - y (L, u = foldl (-) x zs, v = y, w = z) > = (foldl (-) (x-z) zs) - y (IH, a = x, b = z) > = (foldl (-) x (z:zs)) - y (R) > > The trick is to formulate the inductive hypothesis with enough generality, > so you have strong foundations to build on. -- Pozdrawiam, Marcin Kosiba -------------- 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/20090314/0a2fd360/attachment.bin From phercek at gmail.com Sat Mar 14 18:12:14 2009 From: phercek at gmail.com (Peter Hercek) Date: Sat Mar 14 18:03:00 2009 Subject: [Haskell-cafe] Re: How to catch error in array index when debugging In-Reply-To: References: Message-ID: Colin Paul Adams wrote: >>>>>> "Adrian" == Adrian Neumann writes: > > Adrian> You can use the ghci debugger > >> http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci- > Adrian> debugger.html > > Adrian> it can set breakpoints on exceptions. > > So i tried adding the -fbreak-on-error flag. It made no difference - > it still exited: > > : Error in array index > : interrupted > : warning: too many hs_exit()s IIRC, this is because you are catching exceptions at some higher level where you actually find out that this kind of an exception is not handled and give up. If your application is Gtk2Hs then this library will do the catching you do not like in this case. Try to use -fbreak-on-exception instead of -fbreak-on-error. If you try this you may need to set break-on-exception late enough in the execution (use some breakpoint) so that you are not stopping at places which are ok (are correctly handled in an exception handler). In addition to other solutions mentioned here you can also setup conditional breakpoints in GHCi because GHCi breakpoints can be scripted. This is what I mostly use. Most of my debugging is done by writing GHCi debug scripts. Some ideas how to do it are here: http://permalink.gmane.org/gmane.comp.lang.haskell.glasgow.user/16270 It does not work well for interactive command line applications now, but it will work well for them when GHC 6.10.2 is out (the three most critical patches were merged). This alternative may have steep learning curve for such a simple thing but once mastered it works well. Peter. From daniel.is.fischer at web.de Sat Mar 14 18:18:04 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Mar 14 18:06:09 2009 Subject: [Haskell-cafe] Proof of induction case of simple foldl identity. In-Reply-To: <200903142244.59748.marcin.kosiba@gmail.com> References: <200903142225.21291.daniel.is.fischer@web.de> <200903142244.59748.marcin.kosiba@gmail.com> Message-ID: <200903142318.04766.daniel.is.fischer@web.de> Am Samstag, 14. M?rz 2009 22:44 schrieb Marcin Kosiba: > > (L) forall u v w. (u - v) - w = (u - v) - w > > Typo? :) > > (L) forall u v w. (u - v) - w = (u - w) - v > Sure. Thanks for spotting it. I had (x-y)-z = (x-z)-y first, then decided it would be better to use different variable names... From lemming at henning-thielemann.de Sat Mar 14 18:23:38 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Mar 14 18:11:45 2009 Subject: [Haskell-cafe] Style Guide for Haskell Code In-Reply-To: <49BB7E7B.2040302@van.steenbergen.nl> References: <49B68884.8000206@libero.it> <49BB7E7B.2040302@van.steenbergen.nl> Message-ID: On Sat, 14 Mar 2009, Martijn van Steenbergen wrote: > Henning Thielemann wrote: >> Of course, style is a matter of taste. So there are as many good styles as >> programmers and there won't be an official style guide, I'm afraid. > > While that is true, it's no valid reason to not have a style guide. Sun's > style guide for Java has been very successful, improving legibility of Java > code in general. Noone has to adhere to it, but most people do anyway. I'm glad about everyone who follows the tips I have written in Category:Style, but I can by no way call them "official". From lemming at henning-thielemann.de Sat Mar 14 18:33:32 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Mar 14 18:22:07 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: <200903130937.49012.g9ks157k@acme.softbase.org> References: <2816604275516129323@unknownmsgid> <57526e770903122001w4093677ex244db35198686852@mail.gmail.com> <20090313082105.GA14652@flit> <200903130937.49012.g9ks157k@acme.softbase.org> Message-ID: On Fri, 13 Mar 2009, Wolfgang Jeltsch wrote: > Am Freitag, 13. M?rz 2009 09:21 schrieb Roman Cheplyaka: >> * Alexander Dunlap [2009-03-12 20:01:57-0700] >> >>> Also, a lot of functions just take >>> Integers so it would be more of a pain to use. >> >> AFAIK there are very few fuctions that take Integers. Many functions >> take instances of Integral, but it's not a problem to make your own type >> such an instance. > > I?d say that it is a problem. Class instances should satisfy certain laws. > (Although these laws are often not stated explicitely, they are assumed to > hold by users of the class and they should hold to make the instance > sensible.) In the case of Num, I would expect num + negate num to equal num. "equal zero" ? From tphyahoo at gmail.com Sat Mar 14 19:01:44 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Mar 14 18:49:50 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <910ddf450903141445o5d893949wfd10e01177e6e821@mail.gmail.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <49B9A674.4020708@list.mightyreason.com> <910ddf450903141445o5d893949wfd10e01177e6e821@mail.gmail.com> Message-ID: <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> So, I tweaked Text.Regex to have the behavior I need. http://patch-tag.com/repo/haskell-learning/browse/regexStuff/pcreReplace.hs FWIW, the problem I was trying to solve was deleting single newlines but not strings of newlines in a document. Dead simple for pcre-regex with lookaround. But, I think, impossible with posix regex. -- replace single newlines, but not strings of newlines (requires pcre look-around (lookaround, lookahead, lookbehind, for googlebot)) http://perldoc.perl.org/perlre.html testPcre = ( subRegex (mkRegex "(?: > Right, I'm just saying that a "subRegex" that worked on pcre regex > matches would be great for people used to perl regexen and unused to > posix -- even it only allowed a string replacement, and didn't have > all the bells and whistles of =~ s../../../ in perl. > > 2009/3/12 ChrisK >> Thomas Hartman wrote: >>> >>> Is there something like subRegex... something like =~ s/.../.../ in >>> perl... for haskell pcre Regexen? >>> >>> I mean, subRegex from Text.Regex of course: >>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat >>> >>> Thanks for any advice, >>> >>> thomas. >> >> Short answer: No. >> >> This is a FAQ. ?The usual answer to your follow up "Why not?" is that the >> design space is rather huge. ?Rather than justify this statement, I will >> point at the complicated module: >> >> http://hackage.haskell.org/packages/archive/split/0.1.1/doc/html/Data-List-Split.html >> >> The above module is "a wide range of strategies for splitting lists", which >> is a much simpler problem than your subRegex request, and only works on >> lists. ?A subRegex library should also work on bytestrings (and Seq). >> >> At the cost of writing your own routine you get exactly what you want in a >> screen or less of code, see >> http://hackage.haskell.org/packages/archive/regex-compat/0.92/doc/html/src/Text-Regex.html#subRegex >> for "subRegex" which is 30 lines of code. >> >> Cheers, >> ?Chris >> > From lemming at henning-thielemann.de Sat Mar 14 19:04:30 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Mar 14 18:52:59 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: References: Message-ID: On Sat, 14 Mar 2009, Peter Verswyvelen wrote: > I was using the transformers but still had to implement the Applicative instance of State > This package contains an applicative instance for StateT but not for State In 'transformers' State is a type synonym for StateT Identity and thus does not need an own instance declaration. From dons at galois.com Sat Mar 14 19:12:31 2009 From: dons at galois.com (Don Stewart) Date: Sat Mar 14 19:01:29 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <49B9A674.4020708@list.mightyreason.com> <910ddf450903141445o5d893949wfd10e01177e6e821@mail.gmail.com> <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> Message-ID: <20090314231231.GO21094@whirlpool.galois.com> Also, consider stealing the regex susbt code from: http://shootout.alioth.debian.org/u64q/benchmark.php?test=regexdna&lang=ghc&id=4 tphyahoo: > So, I tweaked Text.Regex to have the behavior I need. > > http://patch-tag.com/repo/haskell-learning/browse/regexStuff/pcreReplace.hs > > FWIW, the problem I was trying to solve was deleting single newlines > but not strings of newlines in a document. Dead simple for pcre-regex > with lookaround. But, I think, impossible with posix regex. > > -- replace single newlines, but not strings of newlines (requires pcre > look-around (lookaround, lookahead, lookbehind, for googlebot)) > > http://perldoc.perl.org/perlre.html > > testPcre = ( subRegex (mkRegex "(? "" ) == "asdf \n\n\nadsf" > > Can I lobby for this to make its way into the Regex distribution? > Really, I would argue that every regex flavor should have all the > functions that Text.Regex get, not just posix. (subRegex is just the > most important, to my mind) > > Otherwise I'll make my own RegexHelpers hackage package or something. > > Hard for me to see how to do this in an elegant way since the pcre > packages are so polymorphic-manic. I'm sure there is a way though. > > Or if you point me to the darcs head of regex I'll patch that directly. > > 2009/3/14 Thomas Hartman : > > Right, I'm just saying that a "subRegex" that worked on pcre regex > > matches would be great for people used to perl regexen and unused to > > posix -- even it only allowed a string replacement, and didn't have > > all the bells and whistles of =~ s../../../ in perl. > > > > 2009/3/12 ChrisK > >> Thomas Hartman wrote: > >>> > >>> Is there something like subRegex... something like =~ s/.../.../ in > >>> perl... for haskell pcre Regexen? > >>> > >>> I mean, subRegex from Text.Regex of course: > >>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat > >>> > >>> Thanks for any advice, > >>> > >>> thomas. > >> > >> Short answer: No. > >> > >> This is a FAQ. ?The usual answer to your follow up "Why not?" is that the > >> design space is rather huge. ?Rather than justify this statement, I will > >> point at the complicated module: > >> > >> http://hackage.haskell.org/packages/archive/split/0.1.1/doc/html/Data-List-Split.html > >> > >> The above module is "a wide range of strategies for splitting lists", which > >> is a much simpler problem than your subRegex request, and only works on > >> lists. ?A subRegex library should also work on bytestrings (and Seq). > >> > >> At the cost of writing your own routine you get exactly what you want in a > >> screen or less of code, see > >> http://hackage.haskell.org/packages/archive/regex-compat/0.92/doc/html/src/Text-Regex.html#subRegex > >> for "subRegex" which is 30 lines of code. > >> > >> Cheers, > >> ?Chris > >> > > > From allbery at ece.cmu.edu Sat Mar 14 19:39:11 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Mar 14 19:27:33 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <49B9A674.4020708@list.mightyreason.com> <910ddf450903141445o5d893949wfd10e01177e6e821@mail.gmail.com> <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> Message-ID: <7087DE9F-8641-4EB8-AB7C-7888BA6CA068@ece.cmu.edu> On 2009 Mar 14, at 19:01, Thomas Hartman wrote: > FWIW, the problem I was trying to solve was deleting single newlines > but not strings of newlines in a document. Dead simple for pcre-regex > with lookaround. But, I think, impossible with posix regex. s/(^|[^\n])\n($|[^\n])/\1\2/g; POSIX regexen may be ugly, but they're capable. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/c3b7c772/PGP.bin From ashley at semantic.org Sat Mar 14 20:44:23 2009 From: ashley at semantic.org (Ashley Yakeley) Date: Sat Mar 14 20:32:29 2009 Subject: [Haskell-cafe] Re: Does anybody dislike implicit params as much asI do? In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B01ABA90E@ELON17P32001A.csfb.cs-group.com> References: <910ddf450903121336w73a88ba5m311fad9b133f475e@mail.gmail.com> <49BA376D.8000803@jellybean.co.uk> <16442B752A06A74AB4D9F9A5FF076E4B01ABA90E@ELON17P32001A.csfb.cs-group.com> Message-ID: <49BC4F67.5060304@semantic.org> Sittampalam, Ganesh wrote: > I think they have a useful place in propagating semi-global > configuration information without imposing huge syntactic overhead. Right, for instance, type MyMonad a = (?env :: Env) => IO a No lift needed! I was hoping to use IPs to do OO-style implicit type conversion from a "derived" type to "base" type. For instance: type Base = forall a. ((?f1 :: Int) => a) -> a field1 :: Base -> Int field1 b = b ?f1 type Derived = forall a. ((?f1 :: Int, ?f2 :: String) => a) -> a d :: Derived d x = let {?f1 = 3;?f2 = "Hello"} in x f1d :: Int f1d = field1 d Annoyingly, GHC objects to the "field1 d" application. -- Ashley Yakeley From vigalchin at gmail.com Sat Mar 14 23:52:26 2009 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sat Mar 14 23:40:30 2009 Subject: [Haskell-cafe] RE: Hashing over equivalence classes Message-ID: <5ae4f2ba0903142052r59099355r68fd8daab2430f24@mail.gmail.com> Hi Roman, So are you really talking about an equivalence relation on the function's domain? The reason I ask is that it is well known that "f(a)=f(b)" establishes an equivalence relation on f's co-domain! Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/3b2059d4/attachment.htm From wren at freegeek.org Sun Mar 15 00:51:44 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Mar 15 00:39:48 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> References: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> Message-ID: <49BC8960.5020608@freegeek.org> Mark Spezzano wrote: > Because Haskell is not OO, it is functional, I was wondering if there is > some kind of analogous “design pattern”/”template” type concept that > describe commonly used functions that can be “factored out” in a general > sense to provide the same kind of usefulness that Design Patterns do for > OOP. Basically I’m asking if there are any kinds of “common denominator” > function compositions that are used again and again to solve problems. If > so, what are they called? Most of the (particular) problems OO design patterns solve are non-issues in Haskell because the language is more expressive. The issues giving rise to patterns like Visitor and Factory are non-issues, so their "solutions" are trivial. A number of other patterns can actually be written down once and for all (in higher-order functions like foldr, map,...) instead of needing repetition. But that's not to say we don't have our own expressiveness deficiencies ;) The analogous term for the genre is "functional pearl", though the individual pearls don't tend to be as codified as in OOP. One example is using coproducts for open unions[1] which solves the dual problem to Visitor. Another is using open recursion[2]. A third example along the same track is using two-level types[3]. But again a lot of the patterns, once discovered, get turned into libraries that can be used off the shelf: e.g. the two-continuation solution for efficient and fair backtracking search[4], and list-fusion techniques[5]. There also a number of "idioms" which are similar in scope to the idioms that arise in other languages: using tail recursion, accumulators, continuation-passing transformations, closures over recursion[6], Schwartzian transforms, etc. And then there are some things like monoids which fall somewhere between idiom and pearl. Some specific OO patterns have direct analogues in "defunctionalization"[7]. For the most part defunctionalization is something best left to the compiler, but on occasion we want to be explicit about it and this too is an idiom/pearl border case IMO. And, of course, there's the entire cottage industry of using category theory for fun and profit. [1] http://www.cs.nott.ac.uk/~wss/Publications/DataTypesALaCarte.pdf [2] http://www.cs.utexas.edu/~wcook/Drafts/2006/MemoMixins.pdf [3a] http://web.cecs.pdx.edu/~sheard/papers/generic.ps [3b] http://web.cecs.pdx.edu/~sheard/papers/JfpPearl.ps [4a] http://okmij.org/ftp/papers/LogicT.pdf [4b] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/logict [5a] http://www.cse.unsw.edu.au/~dons/papers/CSL06.html [5b] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring [5c] http://www.cse.unsw.edu.au/~dons/papers/CLS07.html [5d] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/stream-fusion [5e] http://homepages.inf.ed.ac.uk/wadler/papers/vanish/vanish.pdf [6] For lack of a better name. I mean doing this: > -- Here the a,b,c,d variables are captured in the closure for go > recursive a b c d = go > where > go 0 = ...a...b... > go n = ...c...d...go (n-1) instead of this: > -- ...instead of needing to be passed through the recursion each time > recursive a b c d 0 = ...a...b... > recursive a b c d n = ...c...d...recursive a b c d (n-1) [7a] http://blog.plover.com/prog/defunctionalization.html -- Live well, ~wren From porges at porg.es Sun Mar 15 01:22:02 2009 From: porges at porg.es (porges@porg.es) Date: Sun Mar 15 01:10:13 2009 Subject: [Haskell-cafe] Re: Alternative to Data.Binary In-Reply-To: <20090314202700.1afbc8d7@solaris> Message-ID: 2009/3/15 Achim Schneider > > Hmmm. Output-iteratees are a very, very, interesting thing to think > about. Careful, comments like that have a tendency to invoke Oleg. Next thing you know: Interesting Question --> "Maybe you could..." ^ | | | | v Sound of heads popping <-- Oleg: "Yes you can, *and*..." -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 270 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/17ea18ef/signature.bin From yuri.kashnikoff at gmail.com Sun Mar 15 01:38:55 2009 From: yuri.kashnikoff at gmail.com (Yuri Kashnikoff) Date: Sun Mar 15 01:26:59 2009 Subject: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h Message-ID: Hi! I was trying to install hs-plugins both from sources "$./Setup.lhs ..." and with "$cabal fetch&&cabal install" and both failed. It always reports that Linker.h is missing. I have tried to use --extra-include-dirs with path to ghc-6.10.1 dir and ghc-6.10.1/include dir. Nothing changed. Here is a report from Setup.lhs: Setup.lhs:2:2: Warning: In the use of `defaultUserHooks' (imported from Distribution.Simple): Deprecated: "Use simpleUserHooks or autoconfUserHooks, unless you need Cabal-1.2 compatibility in which case you must stick with defaultUserHooks" Warning: defaultUserHooks in Setup script is deprecated. Configuring plugins-1.4.0... Warning: This package indirectly depends on multiple versions of the same package. This is highly likely to cause a compile failure. package ghc-6.10.1 requires Cabal-1.6.0.1 package plugins-1.4.0 requires Cabal-1.6.0.2 checking build system type... i386-apple-darwin9.6.0 checking for ghc... ghc checking for value of __GLASGOW_HASKELL__... 610 checking for ghc library directory... /opt/local/lib/ghc-6.10.1/. checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking for arc4random... yes checking for a BSD-compatible install... /usr/bin/install -c configure: creating ./config.status config.status: creating config.mk config.status: creating testsuite/makewith/io/TestIO.conf config.status: creating testsuite/makewith/unsafeio/Unsafe.conf config.status: creating config.h config.status: config.h is unchanged Setup.lhs: Missing dependency on a foreign library: * Missing header file: Linker.h This problem can usually be solved by installing the system package that provides this library (you may need the "-dev" version). If the library is already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where it is. -- Yuri S. Kashnikov Novosibirsk State University, Russia 2 Pirogova street 630090, Novosibirsk-90 yuri.kashnikoff@gmail.com From dons at galois.com Sun Mar 15 01:43:21 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 15 01:32:39 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <49BC8960.5020608@freegeek.org> References: <49BC8960.5020608@freegeek.org> Message-ID: <20090315054321.GA23147@whirlpool.galois.com> wren: > There also a number of "idioms" which are similar in scope to the idioms > that arise in other languages: using tail recursion, accumulators, > continuation-passing transformations, closures over recursion[6], > Schwartzian transforms, etc. > [6] For lack of a better name. I mean doing this: > > > -- Here the a,b,c,d variables are captured in the closure for go > > recursive a b c d = go > > where > > go 0 = ...a...b... > > go n = ...c...d...go (n-1) > > instead of this: > > > -- ...instead of needing to be passed through the recursion each time > > recursive a b c d 0 = ...a...b... > > recursive a b c d n = ...c...d...recursive a b c d (n-1) > Static argument transformation: http://hackage.haskell.org/trac/ghc/ticket/888 http://www.haskell.org/pipermail/cvs-ghc/2008-April/041959.html Or more generally worker/wrapper http://www.workerwrapper.com/ Take your pick :) From wren at freegeek.org Sun Mar 15 01:50:34 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Mar 15 01:38:39 2009 Subject: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr? In-Reply-To: References: Message-ID: <49BC972A.30305@freegeek.org> R J wrote: > 2. I believe that the reverse implementation--namely, implementing > foldr in terms of foldl--is impossible. What's the proof of that? As others have said, foldr in terms of foldl is impossible when infinite lists are taken into account. For finite lists it's easy though: (\f z xs -> foldl (\yz y -> yz . f y) id xs z) > 3. Any advice on how, aside from tons of practice, to develop the > intuition for rapidly seeing solutions to questions like these would > be much appreciated. The difficulty a newbie faces in answering > seemingly simple questions like these is quite discouraging. The solutions to this problem, while "seemingly simple", is not so simple that a newbie should get discouraged, IMO. The essential trick here is to come up with the idea of using the fold to build a function, which in turn actually does what you want--- rather than trying to do anything "useful" with the fold itself. This idea comes in two parts: implementation indirection (let another function do the real work) and continuation-passing (to build the other function). Both of those tricks are ones we use all the time, but the foldr/foldl problem weds them together in a particularly perverse (though deliciously elegant) manner. In order to develop an intuition for the interplay of CPS and recursion, consider this exercise: You have a type for binary trees and you have this function for getting the size of a tree: > size (Leaf _) = 1 > size (Branch l r) = size l + size r Unfortunately you have very deep trees and so this function gives stack-overflow errors. Rewrite it to be tail recursive. That one's not too hard because the order of recursion doesn't matter (addition is associative and commutative). Now, you have a similar function and you're worried about the fact that repeated list concatenation can take O(n^2) time. Rewrite this one so it's tail recursive--- making sure that the leaves still come out in the right order. If you're familiar with the difference list trick[1] then also rewrite it so you only take O(n) time building the list. > toList (Leaf x) = [x] > toList (Branch l r) = toList l ++ toList r [1] See http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dlist or look at the ShowS type used in the Prelude for the shows function. -- Live well, ~wren From jfredett at gmail.com Sun Mar 15 02:00:05 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sun Mar 15 01:48:10 2009 Subject: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h In-Reply-To: References: Message-ID: <49BC9965.3000309@gmail.com> I believe that hs-plugins has fallen out of use, on #haskell, I was directed to hint[1]. IIRC, I had to disable some packages because of cross installation. /Joe [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hint Yuri Kashnikoff wrote: > Hi! > > I was trying to install hs-plugins both from sources "$./Setup.lhs > ..." and with "$cabal fetch&&cabal install" and both failed. > It always reports that Linker.h is missing. I have tried to use > --extra-include-dirs with path to ghc-6.10.1 dir and > ghc-6.10.1/include dir. Nothing changed. > > Here is a report from Setup.lhs: > > Setup.lhs:2:2: > Warning: In the use of `defaultUserHooks' > (imported from Distribution.Simple): > Deprecated: "Use simpleUserHooks or autoconfUserHooks, > unless you need Cabal-1.2 > compatibility in which case you must stick with defaultUserHooks" > Warning: defaultUserHooks in Setup script is deprecated. > Configuring plugins-1.4.0... > Warning: This package indirectly depends on multiple versions of the same > package. This is highly likely to cause a compile failure. > package ghc-6.10.1 requires Cabal-1.6.0.1 > package plugins-1.4.0 requires Cabal-1.6.0.2 > checking build system type... i386-apple-darwin9.6.0 > checking for ghc... ghc > checking for value of __GLASGOW_HASKELL__... 610 > checking for ghc library directory... /opt/local/lib/ghc-6.10.1/. > checking for gcc... gcc > checking for C compiler default output file name... a.out > checking whether the C compiler works... yes > checking whether we are cross compiling... no > checking for suffix of executables... > checking for suffix of object files... o > checking whether we are using the GNU C compiler... yes > checking whether gcc accepts -g... yes > checking for gcc option to accept ANSI C... none needed > checking for arc4random... yes > checking for a BSD-compatible install... /usr/bin/install -c > configure: creating ./config.status > config.status: creating config.mk > config.status: creating testsuite/makewith/io/TestIO.conf > config.status: creating testsuite/makewith/unsafeio/Unsafe.conf > config.status: creating config.h > config.status: config.h is unchanged > Setup.lhs: Missing dependency on a foreign library: > * Missing header file: Linker.h > This problem can usually be solved by installing the system package that > provides this library (you may need the "-dev" version). If the library is > already installed but in a non-standard location then you can use the flags > --extra-include-dirs= and --extra-lib-dirs= to specify where it is. > > > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/3f892e98/jfredett-0001.vcf From dons at galois.com Sun Mar 15 02:04:30 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 15 01:53:28 2009 Subject: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h In-Reply-To: <49BC9965.3000309@gmail.com> References: <49BC9965.3000309@gmail.com> Message-ID: <20090315060430.GB23147@whirlpool.galois.com> It depends on if you need 'eval' or object loading capability. For true plugins, hs-plugins is still the only binding to the GHC rts object loader, for eval-like mechanisms, we've a number of bindings to the ghc-api bytecode interpreter, such as hint. That said, hs-plugins is kinda sorta patches-applied maintained. jfredett: > I believe that hs-plugins has fallen out of use, on #haskell, I was > directed to hint[1]. IIRC, I had to disable some packages because of > cross installation. > > > /Joe > > > > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hint > > Yuri Kashnikoff wrote: >> Hi! >> >> I was trying to install hs-plugins both from sources "$./Setup.lhs >> ..." and with "$cabal fetch&&cabal install" and both failed. >> It always reports that Linker.h is missing. I have tried to use >> --extra-include-dirs with path to ghc-6.10.1 dir and >> ghc-6.10.1/include dir. Nothing changed. >> >> Here is a report from Setup.lhs: >> >> Setup.lhs:2:2: >> Warning: In the use of `defaultUserHooks' >> (imported from Distribution.Simple): >> Deprecated: "Use simpleUserHooks or autoconfUserHooks, >> unless you need Cabal-1.2 >> compatibility in which case you must stick with defaultUserHooks" >> Warning: defaultUserHooks in Setup script is deprecated. >> Configuring plugins-1.4.0... >> Warning: This package indirectly depends on multiple versions of the same >> package. This is highly likely to cause a compile failure. >> package ghc-6.10.1 requires Cabal-1.6.0.1 >> package plugins-1.4.0 requires Cabal-1.6.0.2 >> checking build system type... i386-apple-darwin9.6.0 >> checking for ghc... ghc >> checking for value of __GLASGOW_HASKELL__... 610 >> checking for ghc library directory... /opt/local/lib/ghc-6.10.1/. >> checking for gcc... gcc >> checking for C compiler default output file name... a.out >> checking whether the C compiler works... yes >> checking whether we are cross compiling... no >> checking for suffix of executables... >> checking for suffix of object files... o >> checking whether we are using the GNU C compiler... yes >> checking whether gcc accepts -g... yes >> checking for gcc option to accept ANSI C... none needed >> checking for arc4random... yes >> checking for a BSD-compatible install... /usr/bin/install -c >> configure: creating ./config.status >> config.status: creating config.mk >> config.status: creating testsuite/makewith/io/TestIO.conf >> config.status: creating testsuite/makewith/unsafeio/Unsafe.conf >> config.status: creating config.h >> config.status: config.h is unchanged >> Setup.lhs: Missing dependency on a foreign library: >> * Missing header file: Linker.h >> This problem can usually be solved by installing the system package that >> provides this library (you may need the "-dev" version). If the library is >> already installed but in a non-standard location then you can use the flags >> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. >> >> >> >> >> > begin:vcard > fn:Joseph Fredette > n:Fredette;Joseph > adr:Apartment #3;;6 Dean Street;Worcester;Massachusetts;01609;United States of America > email;internet:jfredett@gmail.com > tel;home:1-508-966-9889 > tel;cell:1-508-254-9901 > x-mozilla-html:FALSE > url:lowlymath.net, humbuggery.net > version:2.1 > end:vcard > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From yuri.kashnikoff at gmail.com Sun Mar 15 02:20:58 2009 From: yuri.kashnikoff at gmail.com (Yuri Kashnikoff) Date: Sun Mar 15 02:09:03 2009 Subject: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h In-Reply-To: <20090315060430.GB23147@whirlpool.galois.com> References: <49BC9965.3000309@gmail.com> <20090315060430.GB23147@whirlpool.galois.com> Message-ID: Originally I was trying to install turbinado which depends on plugins>=1.4. Actually I don't know how turbinado uses plugins. But still I can't build it because of plugins. I wonder how "turbinado guys" builds hs-plugins with ghc-6.10.1. On Sun, Mar 15, 2009 at 12:04 PM, Don Stewart wrote: > It depends on if you need 'eval' or object loading capability. > > For true plugins, hs-plugins is still the only binding to the GHC rts > object loader, for eval-like mechanisms, we've a number of bindings to > the ghc-api bytecode interpreter, such as hint. > > That said, hs-plugins is kinda sorta patches-applied maintained. > > jfredett: >> I believe that hs-plugins has fallen out of use, on #haskell, I was >> directed to hint[1]. IIRC, I had to disable some packages because of >> cross installation. >> >> >> /Joe >> >> >> >> >> [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hint >> >> Yuri Kashnikoff wrote: >>> Hi! >>> >>> I was trying to install hs-plugins both from sources "$./Setup.lhs >>> ..." and with "$cabal fetch&&cabal install" and both failed. >>> It always reports that Linker.h is missing. I have tried to use >>> --extra-include-dirs with path to ghc-6.10.1 dir and >>> ghc-6.10.1/include dir. Nothing changed. >>> >>> Here is a report from Setup.lhs: >>> >>> Setup.lhs:2:2: >>> ? ? Warning: In the use of `defaultUserHooks' >>> ? ? ? ? ? ? ?(imported from Distribution.Simple): >>> ? ? ? ? ? ? ?Deprecated: "Use simpleUserHooks or autoconfUserHooks, >>> unless you need Cabal-1.2 >>> ? ? ? ? ? ? ?compatibility in which case you must stick with defaultUserHooks" >>> Warning: defaultUserHooks in Setup script is deprecated. >>> Configuring plugins-1.4.0... >>> Warning: This package indirectly depends on multiple versions of the same >>> package. This is highly likely to cause a compile failure. >>> package ghc-6.10.1 requires Cabal-1.6.0.1 >>> package plugins-1.4.0 requires Cabal-1.6.0.2 >>> checking build system type... i386-apple-darwin9.6.0 >>> checking for ghc... ghc >>> checking for value of __GLASGOW_HASKELL__... 610 >>> checking for ghc library directory... /opt/local/lib/ghc-6.10.1/. >>> checking for gcc... gcc >>> checking for C compiler default output file name... a.out >>> checking whether the C compiler works... yes >>> checking whether we are cross compiling... no >>> checking for suffix of executables... >>> checking for suffix of object files... o >>> checking whether we are using the GNU C compiler... yes >>> checking whether gcc accepts -g... yes >>> checking for gcc option to accept ANSI C... none needed >>> checking for arc4random... yes >>> checking for a BSD-compatible install... /usr/bin/install -c >>> configure: creating ./config.status >>> config.status: creating config.mk >>> config.status: creating testsuite/makewith/io/TestIO.conf >>> config.status: creating testsuite/makewith/unsafeio/Unsafe.conf >>> config.status: creating config.h >>> config.status: config.h is unchanged >>> Setup.lhs: Missing dependency on a foreign library: >>> * Missing header file: Linker.h >>> This problem can usually be solved by installing the system package that >>> provides this library (you may need the "-dev" version). If the library is >>> already installed but in a non-standard location then you can use the flags >>> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. >>> >>> >>> >>> >>> > >> begin:vcard >> fn:Joseph Fredette >> n:Fredette;Joseph >> adr:Apartment #3;;6 Dean Street;Worcester;Massachusetts;01609;United States of America >> email;internet:jfredett@gmail.com >> tel;home:1-508-966-9889 >> tel;cell:1-508-254-9901 >> x-mozilla-html:FALSE >> url:lowlymath.net, humbuggery.net >> version:2.1 >> end:vcard >> > >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Yuri S. Kashnikov Novosibirsk State University, Russia 2 Pirogova street 630090, Novosibirsk-90 yuri.kashnikoff@gmail.com From colin at colina.demon.co.uk Sun Mar 15 03:21:57 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Mar 15 03:10:03 2009 Subject: [Haskell-cafe] How to catch error in array index when debugging In-Reply-To: <789E839B1B2041DC930A3E1C4E1C929A@cr3lt> (Claus Reinke's message of "Sat\, 14 Mar 2009 20\:33\:13 -0000") References: <427796131.20090314125730@gmail.com> <789E839B1B2041DC930A3E1C4E1C929A@cr3lt> Message-ID: >>>>> "Claus" == Claus Reinke writes: Claus> None of which is satisfactory. You might also want to add Claus> yourself to this ticket: >> Claus> "index out of range" error message regression Claus> http://hackage.haskell.org/trac/ghc/ticket/2669 >> >> How do I do that? Claus> Ghc Trac's idea of voting is by adding yourself to the cc, Claus> so that tickets can be sorted by length of cc list: I was asking specifically how I add myself to the CC list. There is no button to do so. There is a CC text field, but last time I typed my name there, it ERASED the previous member of the CC list. Rather than a wrapper, I coded an assert, and added it in all the places where I used (!). That was no fun. It did identify the calling function, but that doesn't tell me anything very interesting. I now have to repeat the process for all the callers of that function, which is no joke. -- Colin Adams Preston Lancashire From mark.spezzano at chariot.net.au Sun Mar 15 03:33:11 2009 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Sun Mar 15 03:21:20 2009 Subject: [Haskell-cafe] Default Tuple Orderings Message-ID: <000501c9a540$4c85b1d0$e5911570$@spezzano@chariot.net.au> Hi, Does anyone know how Haskell’s tuple ordering works? Presumably for some tuple T1 (x1,x2,...xn) and another tuple T2 (y1,y2,...yn) Haskell would compare T1 and T2 as follows: T1 < T2 if: x1 < y1 OR otherwise if x1 == y1 then if x2 < y2 OR otherwise if x2 == y2 then if x3 < y3 OR otherwise etc xn < yn OR otherwise both tuple are equal In other words my best guess is that the ordering of tuples is by comparing the first tuple elements and then the seconds, thirds etc, until there’s an element less than another. Is this reasoning correct? So minimum xs would yield the “smallest” tuple (according to the above rules and if xs is a list of tuples)? Cheers, Mark Spezzano No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.13/2001 - Release Date: 14/03/2009 6:54 AM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/cbcdc0fc/attachment.htm From aeyakovenko at gmail.com Sun Mar 15 04:02:44 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sun Mar 15 03:50:48 2009 Subject: [Haskell-cafe] is there a version of hsffig that builds on a recent versin of haskell? Message-ID: is there a version of hsffig that builds on a recent versin of haskell? From martijn at van.steenbergen.nl Sun Mar 15 04:08:17 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sun Mar 15 03:56:23 2009 Subject: [Haskell-cafe] Default Tuple Orderings In-Reply-To: <000501c9a540$4c85b1d0$e5911570$@spezzano@chariot.net.au> References: <000501c9a540$4c85b1d0$e5911570$@spezzano@chariot.net.au> Message-ID: <49BCB771.1080304@van.steenbergen.nl> Mark Spezzano wrote: > In other words my best guess is that the ordering of tuples is by > comparing the first tuple elements and then the seconds, thirds etc, > until there’s an element less than another. ...until there's an element not equal to the other, yes. It finds the first position at which the two elements in the tuples are unequal and returns the result of comparing those two elements (LT or GT). If there's no such position, then the tuples are equal. See also: http://en.wikipedia.org/wiki/Lexicographical_order HTH, Martijn. From colin at colina.demon.co.uk Sun Mar 15 05:08:07 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Mar 15 04:56:11 2009 Subject: [Haskell-cafe] Re: How to catch error in array index when debugging In-Reply-To: (Peter Hercek's message of "Sat\, 14 Mar 2009 23\:12\:14 +0100") References: Message-ID: >>>>> "Peter" == Peter Hercek writes: Peter> Colin Paul Adams wrote: >>>>>>> "Adrian" == Adrian Neumann >>>>>>> writes: >> Adrian> You can use the ghci debugger >> >> >> http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci- Adrian> debugger.html >> Adrian> it can set breakpoints on exceptions. >> >> So i tried adding the -fbreak-on-error flag. It made no >> difference - it still exited: >> >> : Error in array index : interrupted >> : warning: too many hs_exit()s Peter> IIRC, this is because you are catching exceptions at some Peter> higher level where you actually find out that this kind of Peter> an exception is not handled and give up. If your Peter> application is Gtk2Hs then this library will do the Peter> catching you do not like in this case. Try to use That is the case. Peter> -fbreak-on-exception instead of -fbreak-on-error. If you Peter> try this you may need to set break-on-exception late enough Peter> in the execution (use some breakpoint) so that you are not Peter> stopping at places which are ok (are correctly handled in Peter> an exception handler). This works - in conhunction with :trace and :history. Thanks. -- Colin Adams Preston Lancashire From rj248842 at hotmail.com Sun Mar 15 07:42:13 2009 From: rj248842 at hotmail.com (R J) Date: Sun Mar 15 07:30:18 2009 Subject: [Haskell-cafe] A non-inductive Haskell proof? Message-ID: The following theorem is obviously true, but how is it proved (most cleanly and simply) in Haskell? Theorem: (nondecreasing xs) => nondecreasing (insert x xs), where: nondecreasing :: (Ord a) => [a] -> Bool nondecreasing [] = True nondecreasing xxs@(x : xs) = and [a <= b | (a, b) <- zip xxs xs] insert :: (Ord a) => a -> [a] -> [a] insert x xs = takeWhile (<= x) xs ++ [x] ++ dropWhile (<= x) xs Thanks. _________________________________________________________________ Hotmail? is up to 70% faster. Now good news travels really fast. http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_70faster_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/253b7a82/attachment.htm From rj248842 at hotmail.com Sun Mar 15 08:21:14 2009 From: rj248842 at hotmail.com (R J) Date: Sun Mar 15 08:09:18 2009 Subject: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr Message-ID: I need to write an implementation using foldl, and a separate implementation using foldr, of a function, "remdups xs", that removes adjacent duplicate items from the list xs. For example, remdups [1,2,2,3,3,3,1,1]= [1,2,3,1]. My approach is first to write a direct recursion, as follows: remdups :: (Eq a) => [a] -> [a] remdups [] = [] remdups (x : []) = [x] remdups (x : xx : xs) = if x == xx then remdups (x : xs) else x : remdups (xx : xs) This code works, but it has three cases, not usual two, namely [] and (x : xs). What, if any, is the implementation using only two cases? Also, if three cases are required, then how can it be implemented using foldr, and how using foldl? Thanks. _________________________________________________________________ Express your personality in color! Preview and select themes for Hotmail?. http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/b492b96f/attachment.htm From duncan.coutts at worc.ox.ac.uk Sun Mar 15 09:20:50 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Mar 15 09:08:55 2009 Subject: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h In-Reply-To: References: Message-ID: <1237123250.22402.520.camel@localhost> On Sun, 2009-03-15 at 11:38 +0600, Yuri Kashnikoff wrote: > Hi! > > I was trying to install hs-plugins both from sources "$./Setup.lhs > ..." and with "$cabal fetch&&cabal install" and both failed. > It always reports that Linker.h is missing. > Setup.lhs: Missing dependency on a foreign library: > * Missing header file: Linker.h > This problem can usually be solved by installing the system package that > provides this library (you may need the "-dev" version). If the library is > already installed but in a non-standard location then you can use the flags > --extra-include-dirs= and --extra-lib-dirs= to specify where it is. It's a bug in the package that was exposed when Cabal-1.6.0.2 started checking for header files and C libs. I reported the bug to the package maintainer at the time of the release of Cabal-1.6.0.2. Until the maintainer updates it, the fix is to edit the .cabal file and simply remove the mention of Linker.h. You can use the new cabal unpack command: cabal unpack plugins cd plugins-1.4.0 vi plugins.cabal cabal install Duncan From sebastian.sylvan at gmail.com Sun Mar 15 09:24:49 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Sun Mar 15 09:12:53 2009 Subject: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr In-Reply-To: References: Message-ID: <3d96ac180903150624j60923ac9l641acf47d836a50a@mail.gmail.com> 2009/3/15 R J > I need to write an implementation using foldl, and a separate > implementation using foldr, of a function, "remdups xs", that removes > adjacent duplicate items from the list xs. For example, remdups > [1,2,2,3,3,3,1,1]= [1,2,3,1]. > > My approach is first to write a direct recursion, as follows: > > remdups :: (Eq a) => [a] -> [a] > remdups [] = [] > remdups (x : []) = [x] > remdups (x : xx : xs) = if x == xx then remdups (x : xs) else x : > remdups (xx : xs) > > This code works, but it has three cases, not usual two, namely [] and (x : > xs). > > What, if any, is the implementation using only two cases? > > Also, if three cases are required, then how can it be implemented using > foldr, and how using foldl? > > Thanks. > Perhaps it would be helpful to define a helper function with this signature: prepend :: (Eq a) => a -> [a] -> [a] Which for "prepend x xs" will put x at the front of the list, so long as the first element of the list xs is different from x. Once you have this function, take a look at the type signature for foldr. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/396e3fb5/attachment.htm From vandijk.roel at gmail.com Sun Mar 15 09:25:24 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Sun Mar 15 09:13:28 2009 Subject: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr In-Reply-To: References: Message-ID: 2009/3/15 R J : > What, if any, is the implementation using only two cases? This version considers 2 cases 2 times :-) But only the 'go' function is recursive, so it could probably be written using some kind of fold. The value being build by the fold should probably be some kind of tuple so you can keep track of some state. remdups2 :: (Eq a) => [a] -> [a] remdups2 [] = [] remdups2 (x:xs) = go x xs where go x [] = [x] go x (y:ys) = if x == y then go x ys else x : go y ys I almost managed to write one using foldr, but it always put the first group last :-( Perhaps someone else manages to get it right. -- Warning: doesn't work correctly! Last group is last... remdups3 :: (Eq a) => [a] -> [a] remdups3 [] = [] remdups3 (x:xs) = snd $ foldr f (x, []) xs where f y (x, xs') = if y == x then (x, xs') else (y, x : xs') From bugfact at gmail.com Sun Mar 15 09:33:20 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Mar 15 09:21:24 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: References: Message-ID: ouch, I was confusing the mtl and transformers package... so basically transformers is a better replacement for mtl? or does mtl offer things transformers does not? On Sun, Mar 15, 2009 at 12:04 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > > On Sat, 14 Mar 2009, Peter Verswyvelen wrote: > > I was using the transformers but still had to implement the Applicative >> instance of State >> This package contains an applicative instance for StateT but not for State >> > > In 'transformers' State is a type synonym for StateT Identity and thus does > not need an own instance declaration. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/2e9c61e1/attachment.htm From bugfact at gmail.com Sun Mar 15 09:43:06 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Mar 15 09:31:11 2009 Subject: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr In-Reply-To: References: Message-ID: Why don't you just swap the pattern match order? remdups :: (Eq a) => [a] -> [a] remdups (x : xx : xs) = if x == xx then remdups (x : xs) else x : remdups (xx : xs) remdups xs = xs This should cover all cases no? Also I prefer guards, but I guess that is personal remdups (x1:x2:xs) | x1 == x2 = remdups (x2 : xs) | otherwise = x1 : remdups (x2 : xs) remdups xs = xs 2009/3/15 R J > I need to write an implementation using foldl, and a separate > implementation using foldr, of a function, "remdups xs", that removes > adjacent duplicate items from the list xs. For example, remdups > [1,2,2,3,3,3,1,1]= [1,2,3,1]. > > My approach is first to write a direct recursion, as follows: > > remdups :: (Eq a) => [a] -> [a] > remdups [] = [] > remdups (x : []) = [x] > remdups (x : xx : xs) = if x == xx then remdups (x : xs) else x : > remdups (xx : xs) > > This code works, but it has three cases, not usual two, namely [] and (x : > xs). > > What, if any, is the implementation using only two cases? > > Also, if three cases are required, then how can it be implemented using > foldr, and how using foldl? > > Thanks. > > ------------------------------ > Express your personality in color! Preview and select themes for Hotmail?. See > how. > > _______________________________________________ > 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/20090315/7d8de249/attachment.htm From felipe.lessa at gmail.com Sun Mar 15 11:17:54 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Mar 15 11:06:03 2009 Subject: [Haskell-cafe] ANNOUNCE: dzen-utils 0.1 Message-ID: <20090315151754.GA9277@kira.casa> Hello! I'm please to announce dzen-utils 0.1. I don't feel like it is ready to be released, but let's see how everything goes. :) == WHAT == dzen-utils contains various utilities for creating dzen input strings in a type-safe way using some combinators, including the ability to apply colors locally (instead of applying for everything beyond some point). It can also emulate dbar and gdbar, do automatic padding, and more. == WHY == I don't like to write bash scripts for dzen, and I don't like the way xmobar treats its configuration and its inability to show anything other than text. This package is a short-term solution for my problems. Maybe I'll write xmozen in the future. ;) == WHERE, HOW, etc. == It is in Hackage already, go get it[1]. Please see the documentation of System.Dzen for some small examples. [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dzen-utils Thanks for your time, -- Felipe. From loganathan.lingappan at intel.com Sun Mar 15 12:10:58 2009 From: loganathan.lingappan at intel.com (Lingappan, Loganathan) Date: Sun Mar 15 11:58:35 2009 Subject: [Haskell-cafe] Link errors Message-ID: Hi, If I include import Text.Regex.Posix ((=~)) into a Haskell code, I get the following link error: FindBBUsage.o:fake:(.text+0x44d): undefined reference to `__stginit_regexzmposixzm0zi72zi0zi3_TextziRegexziPosix_' collect2: ld returned 1 exit status Any ideas on how to fix this? I am using GHC version 6.10.1 on Windows XP. Thanks, Logo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/5a02144d/attachment.htm From jochem at functor.nl Sun Mar 15 12:15:24 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Sun Mar 15 12:03:31 2009 Subject: [Haskell-cafe] Link errors In-Reply-To: References: Message-ID: <49BD299C.7010700@functor.nl> Lingappan, Loganathan wrote: > If I include > > import Text.Regex.Posix ((=~)) > > into a Haskell code, I get the following link error: > > FindBBUsage.o:fake:(.text+0x44d): undefined reference to `__stginit_regexzmposixzm0zi72zi0zi3_TextziRegexziPosix_' > collect2: ld returned 1 exit status > > Any ideas on how to fix this? I am using GHC version 6.10.1 on Windows XP. Did you use --make ? Regards, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From yuri.kashnikoff at gmail.com Sun Mar 15 13:44:11 2009 From: yuri.kashnikoff at gmail.com (Yuri Kashnikoff) Date: Sun Mar 15 13:32:16 2009 Subject: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h In-Reply-To: <1237123250.22402.520.camel@localhost> References: <1237123250.22402.520.camel@localhost> Message-ID: Thanks. Problem solved now! On Sun, Mar 15, 2009 at 7:20 PM, Duncan Coutts wrote: > On Sun, 2009-03-15 at 11:38 +0600, Yuri Kashnikoff wrote: >> Hi! >> >> I was trying to install hs-plugins both from sources "$./Setup.lhs >> ..." and with "$cabal fetch&&cabal install" and both failed. >> It always reports that Linker.h is missing. > >> Setup.lhs: Missing dependency on a foreign library: >> * Missing header file: Linker.h >> This problem can usually be solved by installing the system package that >> provides this library (you may need the "-dev" version). If the library is >> already installed but in a non-standard location then you can use the flags >> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. > > It's a bug in the package that was exposed when Cabal-1.6.0.2 started > checking for header files and C libs. I reported the bug to the package > maintainer at the time of the release of Cabal-1.6.0.2. > > Until the maintainer updates it, the fix is to edit the .cabal file and > simply remove the mention of Linker.h. You can use the new cabal unpack > command: > > ?cabal unpack plugins > ?cd plugins-1.4.0 > ?vi plugins.cabal > ?cabal install > > Duncan > > -- Yuri S. Kashnikov Novosibirsk State University, Russia 2 Pirogova street 630090, Novosibirsk-90 yuri.kashnikoff@gmail.com From golubovsky at gmail.com Sun Mar 15 14:20:43 2009 From: golubovsky at gmail.com (Dmitry Golubovsky) Date: Sun Mar 15 14:08:45 2009 Subject: [Haskell-cafe] Re: is there a version of hsffig that builds on a recent versin of haskell? In-Reply-To: References: Message-ID: <6191ca42-55aa-4731-90d2-82a24d92633c@33g2000yqm.googlegroups.com> On Mar 15, 4:03?am, Anatoly Yakovenko wrote: > is there a version of hsffig that builds on a recent versin of haskell? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe Unfortunately no. There have been too many changes in GCC and GHC since, and too low interest to the project from other developers, so I did not maintain it. Dmitry. From nonowarn at gmail.com Sun Mar 15 14:31:35 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Sun Mar 15 14:19:37 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe Message-ID: Hello, I was studying about what unsafeInterleaveIO is.I understood unsafeInterleaveIO takes an IO action, and delays it. But I couldn't find any reason why unsafeInterleaveIO is unsafe. I have already read an example in http://www.haskell.org/pipermail/haskell-cafe/2009-March/057101.html says lazy IO may break purity, but I think real matter in this example are wrong use of seq. did I misread? From ryani.spam at gmail.com Sun Mar 15 16:02:37 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun Mar 15 15:50:40 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: References: Message-ID: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> unsafeInterleaveIO allows embedding side effects into a pure computation. This means you can potentially observe if some pure value has been evaluated or not; the result of your code could change depending how lazy/strict it is, which is very hard to predict! For example: > -- given > f :: Integer -> Integer > > main = do > r <- newIORef 0 > v <- unsafeInterleaveIO $ do > writeIORef r 1 > return 1 > x <- case f v of > 0 -> return 0 > n -> return (n - 1) > y <- readIORef r > print y > > -- a couple of examples: > f x = 0 -- program prints "0" > -- f x = x -- program prints "1" "f" is pure. But if f is nonstrict, this program prints 0, and if it's strict, it prints 1. The strictness of a pure function can change the observable behavior of your program! Furthermore, due to the monad laws, if f is total, then reordering the (x <- ...) and (y <- ...) parts of the program should have no effect. But if you switch them, the program will *always* print 0. Also, the compiller might notice that x is never used, and that "f" is total. So it could just optimize out the evaluation of "f v" completely, at which point the program always prints 0 again; changing optimization settings modifies the result of the program. This is why unsafeInterleaveIO is unsafe. -- ryan On Sun, Mar 15, 2009 at 11:31 AM, Yusaku Hashimoto wrote: > Hello, > > I was studying about what unsafeInterleaveIO is.I understood > unsafeInterleaveIO takes an IO action, and delays it. But I couldn't > find any reason why unsafeInterleaveIO is unsafe. > > I have already read an example in > http://www.haskell.org/pipermail/haskell-cafe/2009-March/057101.html > says lazy IO may break purity, but I think real matter in this example > are wrong use of seq. did I misread? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From rj248842 at hotmail.com Sun Mar 15 16:09:48 2009 From: rj248842 at hotmail.com (R J) Date: Sun Mar 15 15:57:54 2009 Subject: [Haskell-cafe] Help with Bird problem 4.5.6: sequence of successive maxima Message-ID: This Bird problem vexes me, in the first instance because it doesn't seem to specify a unique solution: Given a list xs = [x_1, x_2, . . . , x_n], the sequence of successive maxima "ssm xs" is the longest subsequence [x_j1, x_j2, x_j3..x_jk] such that j_1 = 1 and j_m < j_n => x_jm < x_jn. For example, xs = [3, 1, 3, 4, 9, 2, 10, 7] => ssm xs = [3, 4, 9, 10]. Define "ssm" in terms of "foldl". >From this specification, I infer: ssm [] = [] ssm [1] = [1] ssm [1, 2, 3] = [1, 2, 3] ssm [1, 0, 3, 2] = [1, 3] However, what is ssm [1,0,100,2,3,4,5]? Is it [1, 100] or [1, 2, 3, 4, 5]? I think the latter, but am not certain. Whichever it is, what's the solution? Thanks. _________________________________________________________________ Windows Live? Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/183d1952/attachment.htm From dons at galois.com Sun Mar 15 16:21:27 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 15 16:10:27 2009 Subject: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h In-Reply-To: References: <1237123250.22402.520.camel@localhost> Message-ID: <20090315202127.GC25750@whirlpool.galois.com> Fixed on hackage. $ cabal update $ cabal install plugins-1.4.1 Or via the web: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/plugins-1.4.1 -- Don yuri.kashnikoff: > Thanks. Problem solved now! > > On Sun, Mar 15, 2009 at 7:20 PM, Duncan Coutts > wrote: > > On Sun, 2009-03-15 at 11:38 +0600, Yuri Kashnikoff wrote: > >> Hi! > >> > >> I was trying to install hs-plugins both from sources "$./Setup.lhs > >> ..." and with "$cabal fetch&&cabal install" and both failed. > >> It always reports that Linker.h is missing. > > > >> Setup.lhs: Missing dependency on a foreign library: > >> * Missing header file: Linker.h > >> This problem can usually be solved by installing the system package that > >> provides this library (you may need the "-dev" version). If the library is > >> already installed but in a non-standard location then you can use the flags > >> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. > > > > It's a bug in the package that was exposed when Cabal-1.6.0.2 started > > checking for header files and C libs. I reported the bug to the package > > maintainer at the time of the release of Cabal-1.6.0.2. > > > > Until the maintainer updates it, the fix is to edit the .cabal file and > > simply remove the mention of Linker.h. You can use the new cabal unpack > > command: > > > > ?cabal unpack plugins > > ?cd plugins-1.4.0 > > ?vi plugins.cabal > > ?cabal install > > > > Duncan > > > > > > > > -- > Yuri S. Kashnikov > Novosibirsk State University, Russia > 2 Pirogova street > 630090, Novosibirsk-90 > yuri.kashnikoff@gmail.com > From jonathanccast at fastmail.fm Sun Mar 15 16:25:09 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Mar 15 16:13:14 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> Message-ID: <1237148709.6295.16.camel@jonathans-macbook> On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > unsafeInterleaveIO allows embedding side effects into a pure > computation. This means you can potentially observe if some pure > value has been evaluated or not; the result of your code could change > depending how lazy/strict it is, which is very hard to predict! > > For example: > > > -- given > > f :: Integer -> Integer > > > > main = do > > r <- newIORef 0 > > v <- unsafeInterleaveIO $ do > > writeIORef r 1 > > return 1 > > x <- case f v of > > 0 -> return 0 > > n -> return (n - 1) > > y <- readIORef r > > print y > > > > -- a couple of examples: > > f x = 0 -- program prints "0" > > -- f x = x -- program prints "1" > > "f" is pure. But if f is nonstrict, this program prints 0, and if > it's strict, it prints 1. The strictness of a pure function can > change the observable behavior of your program! Right. If the compiler feels like changing the way it implements your program based on that factor. But `semantics' that the compiler doesn't preserve are kind of useless... > Furthermore, due to the monad laws, if f is total, then reordering the > (x <- ...) and (y <- ...) parts of the program should have no effect. > But if you switch them, the program will *always* print 0. I'm confused. I though if f was strict, then my program *always* printed 1? > Also, the compiller might notice that x is never used, and that "f" is > total. So it could just optimize out the evaluation of "f v" > completely, at which point the program always prints 0 again; changing > optimization settings modifies the result of the program. > > This is why unsafeInterleaveIO is unsafe. Well, unsafeInterleaveIO or reasoning based on overly specific assumptions about how things must be implemented, anyway. I'm not sure you've narrowed it down to usafeInterleaveIO, though. jcc From daniel.is.fischer at web.de Sun Mar 15 16:43:01 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 15 16:31:05 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237148709.6295.16.camel@jonathans-macbook> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237148709.6295.16.camel@jonathans-macbook> Message-ID: <200903152143.01746.daniel.is.fischer@web.de> Am Sonntag, 15. M?rz 2009 21:25 schrieb Jonathan Cast: > On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > > > Furthermore, due to the monad laws, if f is total, then reordering the > > (x <- ...) and (y <- ...) parts of the program should have no effect. > > But if you switch them, the program will *always* print 0. > > I'm confused. I though if f was strict, then my program *always* > printed 1? But not if you switch the (x <- ...) and (y <- ...) parts: main = do r <- newIORef 0 v <- unsafeInterleaveIO $ do writeIORef r 1 return 1 y <- readIORef r x <- case f v of 0 -> return 0 n -> return (n - 1) print y Now the IORef is read before the case has a chance to trigger the writing. From daniel.is.fischer at web.de Sun Mar 15 16:52:57 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 15 16:41:02 2009 Subject: [Haskell-cafe] Help with Bird problem 4.5.6: sequence of successive maxima In-Reply-To: References: Message-ID: <200903152152.57671.daniel.is.fischer@web.de> Am Sonntag, 15. M?rz 2009 21:09 schrieb R J: > This Bird problem vexes me, in the first instance because it doesn't seem > to specify a unique solution: > > Given a list xs = [x_1, x_2, . . . , x_n], the sequence of successive > maxima "ssm xs" is the longest subsequence [x_j1, x_j2, x_j3..x_jk] such > that j_1 = 1 and j_m < j_n => x_jm < x_jn. For example, xs = [3, 1, 3, 4, > 9, 2, 10, 7] => ssm xs = [3, 4, 9, 10]. Define "ssm" in terms of "foldl". > > From this specification, I infer: > > ssm [] = [] > ssm [1] = [1] > ssm [1, 2, 3] = [1, 2, 3] > ssm [1, 0, 3, 2] = [1, 3] > > However, what is ssm [1,0,100,2,3,4,5]? Is it [1, 100] or [1, 2, 3, 4, 5]? > I think the latter, but am not certain. Since [1,2,3,4,5] is longer than [1,100], it's the former. But if we consider the example [1,0,3,2], the two lists [1,3] and [1,2] are equally long, both are valid answers given the above spec. So if you want one list as the answer, you have to add a criterium to choose. > Whichever it is, what's the solution? Is the above all that Bird gives as specification or was there more? > > Thanks. > From jonathanccast at fastmail.fm Sun Mar 15 16:56:13 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Mar 15 16:44:23 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <200903152143.01746.daniel.is.fischer@web.de> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237148709.6295.16.camel@jonathans-macbook> <200903152143.01746.daniel.is.fischer@web.de> Message-ID: <1237150573.6295.17.camel@jonathans-macbook> On Sun, 2009-03-15 at 21:43 +0100, Daniel Fischer wrote: > Am Sonntag, 15. M?rz 2009 21:25 schrieb Jonathan Cast: > > On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > > > > > Furthermore, due to the monad laws, if f is total, then reordering the > > > (x <- ...) and (y <- ...) parts of the program should have no effect. > > > But if you switch them, the program will *always* print 0. > > > > I'm confused. I though if f was strict, then my program *always* > > printed 1? > > But not if you switch the (x <- ...) and (y <- ...) parts: > > main = do > r <- newIORef 0 > v <- unsafeInterleaveIO $ do > writeIORef r 1 > return 1 > y <- readIORef r > x <- case f v of > 0 -> return 0 > n -> return (n - 1) > print y > > Now the IORef is read before the case has a chance to trigger the writing. But if the compiler is free to do this itself, what guarantee do I have that it won't? jcc From daniel.is.fischer at web.de Sun Mar 15 17:09:56 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 15 16:58:15 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237150573.6295.17.camel@jonathans-macbook> References: <200903152143.01746.daniel.is.fischer@web.de> <1237150573.6295.17.camel@jonathans-macbook> Message-ID: <200903152209.56845.daniel.is.fischer@web.de> Am Sonntag, 15. M?rz 2009 21:56 schrieb Jonathan Cast: > On Sun, 2009-03-15 at 21:43 +0100, Daniel Fischer wrote: > > Am Sonntag, 15. M?rz 2009 21:25 schrieb Jonathan Cast: > > > On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > > > > Furthermore, due to the monad laws, if f is total, then reordering > > > > the (x <- ...) and (y <- ...) parts of the program should have no > > > > effect. But if you switch them, the program will *always* print 0. > > > > > > I'm confused. I though if f was strict, then my program *always* > > > printed 1? > > > > But not if you switch the (x <- ...) and (y <- ...) parts: > > > > main = do > > r <- newIORef 0 > > v <- unsafeInterleaveIO $ do > > writeIORef r 1 > > return 1 > > y <- readIORef r > > x <- case f v of > > 0 -> return 0 > > n -> return (n - 1) > > print y > > > > Now the IORef is read before the case has a chance to trigger the > > writing. > > But if the compiler is free to do this itself, what guarantee do I have > that it won't? > None? Wasn't that Ryan's point, that without the unsafeInterleaveIO, that reordering wouldn't matter, but with it, it does? > jcc From jonathanccast at fastmail.fm Sun Mar 15 17:20:55 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Mar 15 17:08:58 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <200903152209.56845.daniel.is.fischer@web.de> References: <200903152143.01746.daniel.is.fischer@web.de> <1237150573.6295.17.camel@jonathans-macbook> <200903152209.56845.daniel.is.fischer@web.de> Message-ID: <1237152055.6295.25.camel@jonathans-macbook> On Sun, 2009-03-15 at 22:09 +0100, Daniel Fischer wrote: > Am Sonntag, 15. M?rz 2009 21:56 schrieb Jonathan Cast: > > On Sun, 2009-03-15 at 21:43 +0100, Daniel Fischer wrote: > > > Am Sonntag, 15. M?rz 2009 21:25 schrieb Jonathan Cast: > > > > On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > > > > > Furthermore, due to the monad laws, if f is total, then reordering > > > > > the (x <- ...) and (y <- ...) parts of the program should have no > > > > > effect. But if you switch them, the program will *always* print 0. > > > > > > > > I'm confused. I though if f was strict, then my program *always* > > > > printed 1? > > > > > > But not if you switch the (x <- ...) and (y <- ...) parts: > > > > > > main = do > > > r <- newIORef 0 > > > v <- unsafeInterleaveIO $ do > > > writeIORef r 1 > > > return 1 > > > y <- readIORef r > > > x <- case f v of > > > 0 -> return 0 > > > n -> return (n - 1) > > > print y > > > > > > Now the IORef is read before the case has a chance to trigger the > > > writing. > > > > But if the compiler is free to do this itself, what guarantee do I have > > that it won't? > > > > None? > > Wasn't that Ryan's point, that without the unsafeInterleaveIO, that reordering > wouldn't matter, but with it, it does? Sure. But *that point is wrong*. Given the two programs main0 = do r <- newIORef 0 v <- unsafeInterleaveIO $ do writeIORef r 1 return 1 y <- readIORef r x <- case f v of 0 -> return 0 n -> return (n - 1) print y main1 = do r <- newIORef 0 v <- unsafeInterleaveIO $ do writeIORef r 1 return 1 x <- case f v of 0 -> return 0 n -> return (n - 1) y <- readIORef r print y There is *no* guarantee that main0 prints 0, while main1 prints 1, as claimed. The compiler is in fact free to produce either output given either program, at its option. Since the two programs do in fact have exactly the same set of possible implementations, they *are* equivalent. So the ordering in fact *doesn't* matter. jcc From fft1976 at gmail.com Sun Mar 15 18:08:09 2009 From: fft1976 at gmail.com (FFT) Date: Sun Mar 15 17:56:11 2009 Subject: [Haskell-cafe] big discussion about Haskell on Reddit Message-ID: I noticed that on Programming Reddit, where I lurk, there is a big discussion about the disconnect between how much Haskell is advocated there and the number of applications written in it. http://www.reddit.com/r/programming/comments/84sqt/dear_reddit_i_am_seeing_12_articles_in/ The difficulty of reasoning about memory and CPU-efficiency in nontrivial programs was suggested as an explanation. From dons at galois.com Sun Mar 15 18:11:01 2009 From: dons at galois.com (Don Stewart) Date: Sun Mar 15 17:59:56 2009 Subject: [Haskell-cafe] big discussion about Haskell on Reddit In-Reply-To: References: Message-ID: <20090315221101.GF25750@whirlpool.galois.com> fft1976: > I noticed that on Programming Reddit, where I lurk, there is a big > discussion about the disconnect between how much Haskell is advocated > there and the number of applications written in it. > > http://www.reddit.com/r/programming/comments/84sqt/dear_reddit_i_am_seeing_12_articles_in/ > > The difficulty of reasoning about memory and CPU-efficiency in > nontrivial programs was suggested as an explanation. As well as a million other crazy things, sadly. Reminds me of: http://xkcd.com/386/ Just to cheer people up, there are now 1124 packages on hackage.haskell.org, and on average ~10 releases of Haskell apps and libs are happening each day: http://galois.com/~dons/images/hackage-daily-graph.png -- Don (goes back to writing some code) From daniel.is.fischer at web.de Sun Mar 15 18:18:10 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 15 18:06:12 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237152055.6295.25.camel@jonathans-macbook> References: <200903152209.56845.daniel.is.fischer@web.de> <1237152055.6295.25.camel@jonathans-macbook> Message-ID: <200903152318.10511.daniel.is.fischer@web.de> Am Sonntag, 15. M?rz 2009 22:20 schrieb Jonathan Cast: > There is *no* guarantee that main0 prints 0, while main1 prints 1, as > claimed. The compiler is in fact free to produce either output given > either program, at its option. Since the two programs do in fact have > exactly the same set of possible implementations, they *are* equivalent. > So the ordering in fact *doesn't* matter. Hum. Whether the programme prints 0 or 1 depends on whether "writeIORef r 1" is done before "readIORef r". That depends of course on the semantics of IO and unsafeInterleaveIO. In so far as the compiler is free to choose there, it can indeed produce either result with either programme. But I think "Haskell 's I/O monad provides the user with a way to specify the sequential chaining of actions, and an implementation is obliged to preserve this order." (report, section 7) restricts the freedom considerably. However, I understand "unsafeInterleaveIO allows IO computation to be deferred lazily. When passed a value of type IO a, the IO will only be performed when the value of the a is demanded." as explicitly allowing the programmer to say "do it if and when the result is needed, not before". So I think main0 *must* print 0, because the ordering of the statements puts the reading of the IORef before the result of the unsafeInterleaveIOed action may be needed, so an implementation is obliged to read it before writing to it. In main1 however, v may be needed to decide what action's result x is bound to, before the reading of the IORef in the written order, so if f is strict, the unsafeInterleaveIOed action must be performed before the IORef is read and the programme must print 1, but if f is lazy, v is not needed for that decision, so by the documentation, the unsafeInterleaveIOed action will not be performed, and the programme prints 0. > > jcc From jonathanccast at fastmail.fm Sun Mar 15 18:30:27 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Mar 15 18:18:30 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <200903152318.10511.daniel.is.fischer@web.de> References: <200903152209.56845.daniel.is.fischer@web.de> <1237152055.6295.25.camel@jonathans-macbook> <200903152318.10511.daniel.is.fischer@web.de> Message-ID: <1237156227.6295.36.camel@jonathans-macbook> On Sun, 2009-03-15 at 23:18 +0100, Daniel Fischer wrote: > Am Sonntag, 15. M?rz 2009 22:20 schrieb Jonathan Cast: > > There is *no* guarantee that main0 prints 0, while main1 prints 1, as > > claimed. The compiler is in fact free to produce either output given > > either program, at its option. Since the two programs do in fact have > > exactly the same set of possible implementations, they *are* equivalent. > > So the ordering in fact *doesn't* matter. > > Hum. Whether the programme prints 0 or 1 depends on whether "writeIORef r 1" > is done before "readIORef r". > That depends of course on the semantics of IO and unsafeInterleaveIO. > In so far as the compiler is free to choose there, it can indeed produce > either result with either programme. > But I think > "Haskell 's I/O monad provides the user with a way to specify the sequential > chaining of actions, and an implementation is obliged to preserve this > order." (report, section 7) restricts the freedom considerably. Why not read that line as prohibiting concurrency (forkIO) as well? > However, I understand > "unsafeInterleaveIO allows IO computation to be deferred lazily. When passed a > value of type IO a, the IO will only be performed when the value of the a is > demanded." Where is this taken from? If GHC's library docs try to imply that the programmer can predict when an unsafeInterleaveIO'd operation takes place --- well, then they shouldn't. I'm starting to suspect that not starting from a proper denotational theory of IO was a major mistake for GHC's IO system (which Haskell 1.3 in part adopted). > as explicitly allowing the programmer to say "do it if and when the result is > needed, not before". Haskell's order of evaluation is undefined, so this doesn't really allow the programmer to constrain when the effects are performed much. > So I think main0 *must* print 0, because the ordering of the statements puts > the reading of the IORef before the result of the unsafeInterleaveIOed action > may be needed, so an implementation is obliged to read it before writing to > it. > In main1 however, v may be needed to decide what action's result x is bound > to, before the reading of the IORef in the written order, so if f is strict, > the unsafeInterleaveIOed action must be performed before the IORef is read > and the programme must print 1, Although as Ryan pointed out, the compiler may decide to omit the case statement entirely, if it can statically prove that f v is undefined. > but if f is lazy, v is not needed for that > decision, so by the documentation, the unsafeInterleaveIOed action will not > be performed, and the programme prints 0. jcc From daniel.is.fischer at web.de Sun Mar 15 19:14:13 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 15 19:02:15 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237156227.6295.36.camel@jonathans-macbook> References: <200903152318.10511.daniel.is.fischer@web.de> <1237156227.6295.36.camel@jonathans-macbook> Message-ID: <200903160014.13116.daniel.is.fischer@web.de> Am Sonntag, 15. M?rz 2009 23:30 schrieb Jonathan Cast: > On Sun, 2009-03-15 at 23:18 +0100, Daniel Fischer wrote: > > Am Sonntag, 15. M?rz 2009 22:20 schrieb Jonathan Cast: > > > There is *no* guarantee that main0 prints 0, while main1 prints 1, as > > > claimed. The compiler is in fact free to produce either output given > > > either program, at its option. Since the two programs do in fact have > > > exactly the same set of possible implementations, they *are* > > > equivalent. So the ordering in fact *doesn't* matter. > > > > Hum. Whether the programme prints 0 or 1 depends on whether "writeIORef r > > 1" is done before "readIORef r". > > That depends of course on the semantics of IO and unsafeInterleaveIO. > > > > In so far as the compiler is free to choose there, it can indeed produce > > either result with either programme. > > But I think > > "Haskell 's I/O monad provides the user with a way to specify the > > sequential chaining of actions, and an implementation is obliged to > > preserve this order." (report, section 7) restricts the freedom > > considerably. > > Why not read that line as prohibiting concurrency (forkIO) as well? Good question. Because forkIO is a way to explicitly say one doesn't want the one thing necessarily done before the other, I'd say. > > > However, I understand > > "unsafeInterleaveIO allows IO computation to be deferred lazily. When > > passed a value of type IO a, the IO will only be performed when the value > > of the a is demanded." > > Where is this taken from? If GHC's library docs try to imply that the From the documentation of System.IO.Unsafe. > programmer can predict when an unsafeInterleaveIO'd operation takes > place --- well, then they shouldn't. I'm starting to suspect that not > starting from a proper denotational theory of IO was a major mistake for > GHC's IO system (which Haskell 1.3 in part adopted). Maybe. > > > as explicitly allowing the programmer to say "do it if and when the > > result is needed, not before". > > Haskell's order of evaluation is undefined, so this doesn't really allow > the programmer to constrain when the effects are performed much. The full paragraph from the report: " The I/O monad used by Haskell mediates between the values natural to a functional language and the actions that characterize I/O operations and imperative programming in general. The order of evaluation of expressions in Haskell is constrained only by data dependencies; an implementation has a great deal of freedom in choosing this order. Actions, however, must be ordered in a well-defined manner for program execution -- and I/O in particular -- to be meaningful. Haskell 's I/O monad provides the user with a way to specify the sequential chaining of actions, and an implementation is obliged to preserve this order." I read it as saying that IO *does* allow the programmer to control when the effects are performed. > > > So I think main0 *must* print 0, because the ordering of the statements > > puts the reading of the IORef before the result of the > > unsafeInterleaveIOed action may be needed, so an implementation is > > obliged to read it before writing to it. > > > > In main1 however, v may be needed to decide what action's result x is > > bound to, before the reading of the IORef in the written order, so if f > > is strict, the unsafeInterleaveIOed action must be performed before the > > IORef is read and the programme must print 1, > > Although as Ryan pointed out, the compiler may decide to omit the case > statement entirely, if it can statically prove that f v is undefined. I suppose that's a typo and should be "unneeded". But can it prove that f v is unneeded? After all, it may influence whether 0 or 1 is printed. > > > but if f is lazy, v is not needed for that > > decision, so by the documentation, the unsafeInterleaveIOed action will > > not be performed, and the programme prints 0. > > jcc From claus.reinke at talk21.com Sun Mar 15 19:16:26 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sun Mar 15 19:04:32 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> Message-ID: >> main = do >> r <- newIORef 0 >> v <- unsafeInterleaveIO $ do >> writeIORef r 1 >> return 1 >> x <- case f v of >> 0 -> return 0 >> n -> return (n - 1) >> y <- readIORef r >> print y >> >> -- a couple of examples: >> f x = 0 -- program prints "0" >> -- f x = x -- program prints "1" > > "f" is pure. But if f is nonstrict, this program prints 0, and if > it's strict, it prints 1. The strictness of a pure function can > change the observable behavior of your program! Strictness is an effect, even if it isn't recorded in Haskell's types. Replacing 'v <- ..' by 'let v = undefined' provides similar choices. 'unsafeInterleaveIO' explicitly uses the "implicit" effects of strictness to drive the "explicit" effects of IO, which is why it is unsafe (moving IO effects from explicit to implicit). But even if 'unsafeInterleaveIO' where eliminated, strictness/evaluation would still remain as an implicit effect in Haskell. Here's a variation without 'unsafeInterleaveIO': import Data.IORef import Control.Exception main = do r <- newIORef 0 let v = undefined handle (\(ErrorCall _)->print "hi">>return 42) $ case f v of 0 -> return 0 n -> return (n - 1) y <- readIORef r print y -- a couple of examples: f x = 0 -- program prints '0' f x = x -- program prints '"hi"0' (sideline: I often interpret '_|_::t' not so much as an element of 't' but as failure to produce information at type 't'; the type tells us what information we can have, evaluation not only provides the details, but also decides whether or not we have any of that info, and how much of it) > Furthermore, due to the monad laws, if f is total, then reordering the > (x <- ...) and (y <- ...) parts of the program should have no effect. case f v of { 0 -> return 0; n -> return (n - 1) } = return $! case f v of { 0 -> 0; n -> (n - 1) } =/= return $ case f v of { 0 -> 0; n -> (n - 1) } Monad laws apply to the latter, so how is reordering justified? It doesn't matter if 'f' is total, the context requires to know whether 'f v' is '0' or not. Since the only thing used from the result is its successful evaluation, the case could be eliminated, but that still leaves return $! f v =/= return $ f v > But if you switch them, the program will *always* print 0. In my copy of the docs, the only things known about 'unsafeInterleaveIO' are its module, its type, and that is is "unsafe". If we assume, from the name, that evaluation of its parameter will be interleaved unsafely with the main IO thread, there is no knowing when or if that evaluation will happen. Unless there is a dependency on the result of that evaluation, in which case we have an upper bound on when the evaluation must happen, but still no lower bound. From the comments in the source code, it appears that lower and upper bound are intended to be identical, ie. evaluation is supposed to happen at the latest possible point permitted by dependencies. Changing dependencies changes the program. > Also, the compiller might notice that x is never used, and that "f" is > total. So it could just optimize out the evaluation of "f v" > completely, at which point the program always prints 0 again; changing > optimization settings modifies the result of the program. It doesn't matter whether or not 'x' is used. It matters whether 'f v' needs to be evaluated to get at the 'return' action. Even if 'f' is total, that evaluation cannot be skipped. Eta-expansion changes strictness, which changes the program (eg, '\p->(fst p,snd p)' =/= 'id::(a,b)->(a,b)', even though these functions only apply to pairs, so we "know" that "whatever 'p' is, it ought to be a pair" - only we don't; and neither do we know that 'f v' is a number, even if 'f' itself is total). None of this means that lazy IO and monadic IO ought to be mixed freely. If a program depends on strictness/non-strictness, that needs to be taken into account, which can be troublesome, which is why lazy IO hasn't been the default IO mechanism in Haskell for many years. It is still available because when it is applicable, it can be quite elegant and simple. But we need to decide whether or not that is the case for each use case, even without the explicit 'unsafe'. Hth? Claus From jonathanccast at fastmail.fm Sun Mar 15 19:47:27 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Mar 15 19:35:30 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <200903160014.13116.daniel.is.fischer@web.de> References: <200903152318.10511.daniel.is.fischer@web.de> <1237156227.6295.36.camel@jonathans-macbook> <200903160014.13116.daniel.is.fischer@web.de> Message-ID: <1237160847.6295.42.camel@jonathans-macbook> On Mon, 2009-03-16 at 00:14 +0100, Daniel Fischer wrote: > Am Sonntag, 15. M?rz 2009 23:30 schrieb Jonathan Cast: > > On Sun, 2009-03-15 at 23:18 +0100, Daniel Fischer wrote: > > > Am Sonntag, 15. M?rz 2009 22:20 schrieb Jonathan Cast: > > > > There is *no* guarantee that main0 prints 0, while main1 prints 1, as > > > > claimed. The compiler is in fact free to produce either output given > > > > either program, at its option. Since the two programs do in fact have > > > > exactly the same set of possible implementations, they *are* > > > > equivalent. So the ordering in fact *doesn't* matter. > > > > > > Hum. Whether the programme prints 0 or 1 depends on whether "writeIORef r > > > 1" is done before "readIORef r". > > > That depends of course on the semantics of IO and unsafeInterleaveIO. > > > > > > In so far as the compiler is free to choose there, it can indeed produce > > > either result with either programme. > > > But I think > > > "Haskell 's I/O monad provides the user with a way to specify the > > > sequential chaining of actions, and an implementation is obliged to > > > preserve this order." (report, section 7) restricts the freedom > > > considerably. > > > > Why not read that line as prohibiting concurrency (forkIO) as well? > > Good question. > Because forkIO is a way to explicitly say one doesn't want the one thing > necessarily done before the other, I'd say. As is unsafeInterleaveIO. (And as is unsafePerformIO, as per the docs: > If the I/O computation wrapped in unsafePerformIO performs side > effects, then the relative order in which those side effects take > place (relative to the main I/O trunk, or other calls to > unsafePerformIO) is indeterminate. ) > > > However, I understand > > > "unsafeInterleaveIO allows IO computation to be deferred lazily. When > > > passed a value of type IO a, the IO will only be performed when the value > > > of the a is demanded." > > > > Where is this taken from? If GHC's library docs try to imply that the > > From the documentation of System.IO.Unsafe. This version of those docs: http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO-Unsafe.html leaves unsafeInterleaveIO completely un-documented. So I'm still not sure what you're quoting from. > > programmer can predict when an unsafeInterleaveIO'd operation takes > > place --- well, then they shouldn't. I'm starting to suspect that not > > starting from a proper denotational theory of IO was a major mistake for > > GHC's IO system (which Haskell 1.3 in part adopted). > > Maybe. > > > > > > as explicitly allowing the programmer to say "do it if and when the > > > result is needed, not before". > > > > Haskell's order of evaluation is undefined, so this doesn't really allow > > the programmer to constrain when the effects are performed much. > > The full paragraph from the report: > > " The I/O monad used by Haskell mediates between the values natural to a > functional language and the actions that characterize I/O operations and > imperative programming in general. The order of evaluation of expressions in > Haskell is constrained only by data dependencies; an implementation has a > great deal of freedom in choosing this order. Actions, however, must be > ordered in a well-defined manner for program execution -- and I/O in > particular -- to be meaningful. Haskell 's I/O monad provides the user with a > way to specify the sequential chaining of actions, and an implementation is > obliged to preserve this order." > > I read it as saying that IO *does* allow the programmer to control when the > effects are performed. Right. But by using forkIO or unsafeInterleaveIO you waive that ability. > > > So I think main0 *must* print 0, because the ordering of the statements > > > puts the reading of the IORef before the result of the > > > unsafeInterleaveIOed action may be needed, so an implementation is > > > obliged to read it before writing to it. > > > > > > In main1 however, v may be needed to decide what action's result x is > > > bound to, before the reading of the IORef in the written order, so if f > > > is strict, the unsafeInterleaveIOed action must be performed before the > > > IORef is read and the programme must print 1, > > > > Although as Ryan pointed out, the compiler may decide to omit the case > > statement entirely, if it can statically prove that f v is undefined. > > I suppose that's a typo and should be "unneeded". > But can it prove that f v is unneeded? After all, it may influence whether 0 > or 1 is printed. [Ignored: begging the question] jcc From schlepptop at henning-thielemann.de Sun Mar 15 19:57:22 2009 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Sun Mar 15 19:36:34 2009 Subject: [Haskell-cafe] State monad is missing Applicative instance In-Reply-To: References: Message-ID: <49BD95E2.7080700@henning-thielemann.de> Peter Verswyvelen schrieb: > ouch, I was confusing the mtl and transformers package... > > so basically transformers is a better replacement for mtl? > > or does mtl offer things transformers does not? transformers and monad-fd are cleanly separated, transformers is Haskell 98 and monad-fd uses functional dependencies. From daniel.is.fischer at web.de Sun Mar 15 19:49:54 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 15 19:37:55 2009 Subject: [Haskell-cafe] Help with Bird problem 4.5.6: sequence of successive maxima In-Reply-To: References: Message-ID: <200903160049.54264.daniel.is.fischer@web.de> Am Sonntag, 15. M?rz 2009 21:09 schrieb R J: > This Bird problem vexes me, in the first instance because it doesn't seem > to specify a unique solution: > > Given a list xs = [x_1, x_2, . . . , x_n], the sequence of successive > maxima "ssm xs" is the longest subsequence [x_j1, x_j2, x_j3..x_jk] such > that j_1 = 1 and j_m < j_n => x_jm < x_jn. For example, xs = [3, 1, 3, 4, > 9, 2, 10, 7] => ssm xs = [3, 4, 9, 10]. Define "ssm" in terms of "foldl". > > From this specification, I infer: > > ssm [] = [] > ssm [1] = [1] > ssm [1, 2, 3] = [1, 2, 3] > ssm [1, 0, 3, 2] = [1, 3] > > However, what is ssm [1,0,100,2,3,4,5]? Is it [1, 100] or [1, 2, 3, 4, 5]? > I think the latter, but am not certain. Whichever it is, what's the > solution? > > Thanks. > Not particularly efficient, but module SSM where import Data.List (maximumBy) import Data.Ord ssm :: Ord a => [a] -> [a] ssm = reverse . maximumBy (comparing length) . foldl comb [[]] where comb [[]] a = [[a]] comb lists a = do xs@(h:_) <- lists if h < a then [xs,a:xs] else [xs] I think it is impossible to implement ssm as foldl f z without any post-processing and since foldl can't foresee what comes in the remainder of the list, you must keep several candidates around. You can probably make it more efficient by removing all lists lst@(h:_) where there's a longer list with head <= h or an equally long list with head < h in the store (but doing that efficiently is not trivial). From tphyahoo at gmail.com Sun Mar 15 20:00:33 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sun Mar 15 19:48:36 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <7087DE9F-8641-4EB8-AB7C-7888BA6CA068@ece.cmu.edu> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <49B9A674.4020708@list.mightyreason.com> <910ddf450903141445o5d893949wfd10e01177e6e821@mail.gmail.com> <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> <7087DE9F-8641-4EB8-AB7C-7888BA6CA068@ece.cmu.edu> Message-ID: <910ddf450903151700t76440bdfj47d81ee184f77724@mail.gmail.com> Except that there is nothing like =~ s in haskell, as far as I can tell. I was mulling over this and thinking, the nicest solution for this -- from the lens of perl evangelism anyway -- would be to have some way of accessing the perl6 language =~ s mechanism in pugs, which would get us everything in perl 5 =~, and also all the cool grammar stuff that comes in perl6, which seems 90% of the way to parsec in terms of power but with a thought out huffman-optimized syntax. Accordingly I am trying to load pugs in ghci, about which more at http://perlmonks.org/?node_id=750768 2009/3/14 Brandon S. Allbery KF8NH : > On 2009 Mar 14, at 19:01, Thomas Hartman wrote: >> >> FWIW, the problem I was trying to solve was deleting single newlines >> but not strings of newlines in a document. Dead simple for pcre-regex >> with lookaround. But, I think, impossible with posix regex. > > s/(^|[^\n])\n($|[^\n])/\1\2/g; > > POSIX regexen may be ugly, but they're capable. > > -- > 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 daniel.is.fischer at web.de Sun Mar 15 20:04:46 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Mar 15 19:52:47 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237160847.6295.42.camel@jonathans-macbook> References: <200903160014.13116.daniel.is.fischer@web.de> <1237160847.6295.42.camel@jonathans-macbook> Message-ID: <200903160104.46743.daniel.is.fischer@web.de> Am Montag, 16. M?rz 2009 00:47 schrieb Jonathan Cast: > On Mon, 2009-03-16 at 00:14 +0100, Daniel Fischer wrote: > > > > > However, I understand > > > > "unsafeInterleaveIO allows IO computation to be deferred lazily. When > > > > passed a value of type IO a, the IO will only be performed when the > > > > value of the a is demanded." > > > > > > Where is this taken from? If GHC's library docs try to imply that the > > > > From the documentation of System.IO.Unsafe. > > This version of those docs: > > > http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO-Unsafe.htm >l > > leaves unsafeInterleaveIO completely un-documented. So I'm still not > sure what you're quoting from. The documentation haddock-0.9 built when I compiled ghc-6.8.3 last year. > > > > programmer can predict when an unsafeInterleaveIO'd operation takes > > > place --- well, then they shouldn't. I'm starting to suspect that not > > > starting from a proper denotational theory of IO was a major mistake > > > for GHC's IO system (which Haskell 1.3 in part adopted). > > > > Maybe. > > > > > > as explicitly allowing the programmer to say "do it if and when the > > > > result is needed, not before". > > > > > > Haskell's order of evaluation is undefined, so this doesn't really > > > allow the programmer to constrain when the effects are performed much. > > > > The full paragraph from the report: > > > > " The I/O monad used by Haskell mediates between the values natural to a > > functional language and the actions that characterize I/O operations and > > imperative programming in general. The order of evaluation of expressions > > in Haskell is constrained only by data dependencies; an implementation > > has a great deal of freedom in choosing this order. Actions, however, > > must be ordered in a well-defined manner for program execution -- and I/O > > in particular -- to be meaningful. Haskell 's I/O monad provides the user > > with a way to specify the sequential chaining of actions, and an > > implementation is obliged to preserve this order." > > > > I read it as saying that IO *does* allow the programmer to control when > > the effects are performed. > > Right. But by using forkIO or unsafeInterleaveIO you waive that > ability. That depends on the specification of unsafeInterleaveIO. If it is "unspecified order of evaluation", then yes, if it is "do when needed, not before", as my local documentation can be interpreted, then unsafeInterleaveIO reduces that ability, but doesn't completely remove it. From benjovi at gmx.net Sun Mar 15 20:17:17 2009 From: benjovi at gmx.net (Benedikt Huber) Date: Sun Mar 15 20:05:24 2009 Subject: [Haskell-cafe] Re: Help with Bird problem 4.5.6: sequence of successive maxima In-Reply-To: References: Message-ID: <49BD9A8D.1090206@gmx.net> R J schrieb: > This Bird problem vexes me, in the first instance because it doesn't > seem to specify a unique solution: > > Given a list xs = [x_1, x_2, . . . , x_n], the sequence of successive > maxima "ssm xs" is the > longest subsequence [x_j1, x_j2, x_j3..x_jk] such that j_1 = 1 and j_m < > j_n => x_jm < x_jn. > For example, xs = [3, 1, 3, 4, 9, 2, 10, 7] => ssm xs = [3, 4, 9, 10]. > Define "ssm" in terms of "foldl". Hi, this problem is a variant of http://en.wikipedia.org/wiki/Longest_increasing_subsequence discussed about a year ago: http://www.mail-archive.com/haskell-cafe@haskell.org/msg39784.html http://www.mail-archive.com/haskell-cafe@haskell.org/msg39844.html In the latter mail, Chris Kuklewicz presents an (efficient) implementation. To solve the problem you stated, simply reuse `lnds`: > -- ssm [3, 1, 3, 4, 9, 2, 9, 10, 7] = [3,4,9,10] > ssm (x:xs) = x : lnds (filter (> x) xs) benedikt > > From this specification, I infer: > > ssm [] = [] > ssm [1] = [1] > ssm [1, 2, 3] = [1, 2, 3] > ssm [1, 0, 3, 2] = [1, 3] > > However, what is ssm [1,0,100,2,3,4,5]? Is it [1, 100] or [1, 2, 3, 4, > 5]? I think the latter, but am not certain. Whichever it is, what's > the solution? > > Thanks. > > > ------------------------------------------------------------------------ > Windows Live? Groups: Create an online spot for your favorite groups to > meet. Check it out. > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From wren at freegeek.org Sun Mar 15 20:17:24 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Mar 15 20:05:35 2009 Subject: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr In-Reply-To: References: Message-ID: <49BD9A94.4030001@freegeek.org> R J wrote: > I need to write an implementation using foldl, and a separate implementation using foldr, of a function, "remdups xs", that removes adjacent duplicate items from the list xs. For example, remdups [1,2,2,3,3,3,1,1]= [1,2,3,1]. > > My approach is first to write a direct recursion, as follows: > > remdups :: (Eq a) => [a] -> [a] > remdups [] = [] > remdups (x : []) = [x] > remdups (x : xx : xs) = if x == xx then remdups (x : xs) else x : remdups (xx : xs) > > This code works, but it has three cases, not usual two, namely [] and (x : xs). You should take a look at the page on declaration style vs expression style: http://haskell.org/haskellwiki/Declaration_vs._expression_style At the risk of doing homework, it is always the case that you can decompose complex pattern matching into basic pattern matching (which for lists means it always has two cases, since list has two constructors).[1] remdups [] = ...#1 remdups (x:[]) = ...#2 remdups (x:(xx:xs)) = ...#3 == {desugar pattern-matching into case} remdups = \a -> case a of [] -> ...#1 (x:[]) -> ...#2 (x:(xx:xs)) -> ...#3 == {desugar case into case} remdups = \a -> case a of [] -> ...#1 (x:b) -> case b of [] -> ...#2 (xx:xs) -> ...#3 This transformation explicitly gives a name to the second argument of the first (:) which is beneficial since it means you don't need to allocate a new one that's identical to the old one in order to pass to the recursion. For the Then we know x==xx therefore (x:xs) == (xx:xs), for the Else we need (xx:xs), in both cases we already have an (xx:xs) laying around, namely b. If you want to give a name like this without manually desugaring the case statements yourself, then you can use an as-pattern like (x: b@(xx:xs)) which will bind the variable b to the value (xx:xs) just like above. [1] This would not be true if, for example, the language could express non-linear terms like in Prolog and other logic languages. Pattern matching can still be decomposed in such languages, but they need to introduce unification constraints along with the smaller patterns, to ensure correctness of the transformation. -- Live well, ~wren From jonathanccast at fastmail.fm Sun Mar 15 20:19:33 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Mar 15 20:07:35 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <200903160104.46743.daniel.is.fischer@web.de> References: <200903160014.13116.daniel.is.fischer@web.de> <1237160847.6295.42.camel@jonathans-macbook> <200903160104.46743.daniel.is.fischer@web.de> Message-ID: <1237162773.6334.4.camel@jonathans-macbook> On Mon, 2009-03-16 at 01:04 +0100, Daniel Fischer wrote: > Am Montag, 16. M?rz 2009 00:47 schrieb Jonathan Cast: > > On Mon, 2009-03-16 at 00:14 +0100, Daniel Fischer wrote: > > > > > > > However, I understand > > > > > "unsafeInterleaveIO allows IO computation to be deferred lazily. When > > > > > passed a value of type IO a, the IO will only be performed when the > > > > > value of the a is demanded." > > > > > > > > Where is this taken from? If GHC's library docs try to imply that the > > > > > > From the documentation of System.IO.Unsafe. > > > > This version of those docs: > > > > > > http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO-Unsafe.htm > >l > > > > leaves unsafeInterleaveIO completely un-documented. So I'm still not > > sure what you're quoting from. > > The documentation haddock-0.9 built when I compiled ghc-6.8.3 last year. So it's a GHC (and base) major version out of date. > > > > programmer can predict when an unsafeInterleaveIO'd operation takes > > > > place --- well, then they shouldn't. I'm starting to suspect that not > > > > starting from a proper denotational theory of IO was a major mistake > > > > for GHC's IO system (which Haskell 1.3 in part adopted). > > > > > > Maybe. > > > > > > > > as explicitly allowing the programmer to say "do it if and when the > > > > > result is needed, not before". > > > > > > > > Haskell's order of evaluation is undefined, so this doesn't really > > > > allow the programmer to constrain when the effects are performed much. > > > > > > The full paragraph from the report: > > > > > > " The I/O monad used by Haskell mediates between the values natural to a > > > functional language and the actions that characterize I/O operations and > > > imperative programming in general. The order of evaluation of expressions > > > in Haskell is constrained only by data dependencies; an implementation > > > has a great deal of freedom in choosing this order. Actions, however, > > > must be ordered in a well-defined manner for program execution -- and I/O > > > in particular -- to be meaningful. Haskell 's I/O monad provides the user > > > with a way to specify the sequential chaining of actions, and an > > > implementation is obliged to preserve this order." > > > > > > I read it as saying that IO *does* allow the programmer to control when > > > the effects are performed. > > > > Right. But by using forkIO or unsafeInterleaveIO you waive that > > ability. > > That depends on the specification of unsafeInterleaveIO. If it is "unspecified > order of evaluation", then yes, if it is "do when needed, not before", Note that `when needed' is still dependent on the (still unspecified) (non-IO) Haskell evaluation order. Also note that, to demonstrate any strong claims about unsafeInterleaveIO, you need to show that the compiler *must* perform in such-and-such a way, not simply that it *will* or that it *may*. > as my > local documentation can be interpreted, then unsafeInterleaveIO reduces that > ability, but doesn't completely remove it. Sure. The question is whether the compiler has still enough options for re-ordering the program that transforming a program according to the standard equational axiomatic semantics for Haskell doesn't change the set of options the compiler has for the behavior of its generated code. jcc From wren at freegeek.org Sun Mar 15 21:04:36 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Mar 15 20:52:39 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: References: Message-ID: <49BDA5A4.7070406@freegeek.org> Yusaku Hashimoto wrote: > Hello, > > I was studying about what unsafeInterleaveIO is.I understood > unsafeInterleaveIO takes an IO action, and delays it. But I couldn't > find any reason why unsafeInterleaveIO is unsafe. > > I have already read an example in > http://www.haskell.org/pipermail/haskell-cafe/2009-March/057101.html > says lazy IO may break purity, but I think real matter in this example > are wrong use of seq. did I misread? For example: I have some universal state in IO. We'll call it an IORef, but it could be anything, like reading lines from a file. And I have some method for accessing and updating that state. > next r = do n <- readIORef r > writeIORef r (n+1) > return n Now, if I use unsafeInterleaveIO: > main = do r <- newIORef 0 > x <- do a <- unsafeInterleaveIO (next r) > b <- unsafeInterleaveIO (next r) > return (a,b) > ... The values of a and b in x are entirely arbitrary, and are only set at the point when they are first accessed. They're not just arbitrary between which is 0 and which is 1, they could be *any* pair of values (other than equal) since the reference r is still in scope and other code in the ... could affect it before we access a and b, or between the two accesses. The arbitrariness is not "random" in the statistical sense, but rather is an oracle for determining the order in which evaluation has occurred. Consider, as an illustration these two alternatives for the ...: > fst x `seq` snd x `seq` return x vs > snd x `seq` fst x `seq` return x In this example, main will return (0,1) or (1,0) depending on which was chosen. You are right in that the issue lies in seq, but that's a red herring. Having made x, we can pass it along to any function, ignore the output of that function, and inspect x in order to know the order of strictness in that function. Moreover, let's have two pure implementations, f and g, of the same mathematical function. Even if f and g are close enough to correctly give the same output for inputs with _|_ in them, we may be able to observe the fact that they arrive at those answers differently by passing in our x. Given that such observations are possible, it is no longer safe to exchange f and g for one another, despite the fact that they are pure and give the same output for all (meaningful) inputs. This example is somewhat artificial because we set up x to use unsafeInterleaveIO in the bad way. For the intended use cases where it is indeed (arguably) safe, we would need to be sure to manually thread the state through the pure value (e.g. x) such that the final value is sane. For instance, in lazy I/O where we're constructing a list of lines/bytes/whatever, we need to ensure that any access to the Nth element of the list will first force the (N-1)th element, so that we ensure that the list comes out in the same order as if we forced all of them at construction time. For things like arbitrary symbol generation, unsafeInterleaveIO is perfectly fine because the order and identity of the symbols generated is irrelevant, but more importantly it is safe because the "IO" that's going on is not actually I/O. For arbitrary symbol generation, we could use unsafeInterleaveST instead, and that would be better because it accurately describes the effects. For any IO value which has real I/O effects, unsafeInterleaveIO is almost never correct because the ordering of effects on the real world (or whether the effects occur at all) depends entirely on the evaluation behavior of the program, which can vary by compiler, by compiler version, or even between different runs of the same compiled binary. -- Live well, ~wren From ryani.spam at gmail.com Sun Mar 15 21:11:20 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun Mar 15 20:59:22 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237150573.6295.17.camel@jonathans-macbook> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237148709.6295.16.camel@jonathans-macbook> <200903152143.01746.daniel.is.fischer@web.de> <1237150573.6295.17.camel@jonathans-macbook> Message-ID: <2f9b2d30903151811r67bd9701k30ed7d893982e197@mail.gmail.com> On Sun, Mar 15, 2009 at 1:56 PM, Jonathan Cast wrote: >> But not if you switch the (x <- ...) and (y <- ...) parts: >> >> main = do >> ? ? r <- newIORef 0 >> ? ? v <- unsafeInterleaveIO $ do >> ? ? ? ? writeIORef r 1 >> ? ? ? ? return 1 >> ? ? y <- readIORef r >> ? ? x <- case f v of >> ? ? ? ? ? ? 0 -> return 0 >> ? ? ? ? ? ? n -> return (n - 1) >> ? ? print y >> >> Now the IORef is read before the case has a chance to trigger the writing. > > But if the compiler is free to do this itself, what guarantee do I have > that it won't? You don't really have any guarantee; the compiler is free to assume that v is a pure integer and that f is a pure function from integers to integers. Therefore, it can assume that the only observable affect of calling f v is non-termination. Note that unsafeInterleaveIO *breaks* this assumption; that is why it is unsafe. I erred previously in saying that this was allowed if f is total; it does still evaluate f v either way. But I can correct my argument as follows: the only observable effect from the (x <- ...) line is non-termination. And the compiler can prove that there *no* observable effect of "readIORef" until the value is used or the reference is written by another function. So it is free to make this reordering anyways, as the only observable effect could have been non-termination which will be observed immediately after. When you use unsafeInterleaveIO or unsafePerformIO, you are required prove that its use does not break these invariants; that, for example, you don't read or write from IORefs that could be accessed elsewhere in the program. These are proofs that the compiler can and does make in some situations; it can reorder sequential readIORef calls if it thinks one or the other might be more efficient. It can evaluate foldl as if it was foldl' if it proves the arguments strict enough that non-termination behavior is identical (ghc -O2 does this, for example). The language has them as "escape hatches" that allow you to write code that would not otherwise be possible, by shifting more of a proof obligation on to the programmer. -- ryan From jonathanccast at fastmail.fm Sun Mar 15 21:13:20 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Mar 15 21:01:23 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <2f9b2d30903151811r67bd9701k30ed7d893982e197@mail.gmail.com> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237148709.6295.16.camel@jonathans-macbook> <200903152143.01746.daniel.is.fischer@web.de> <1237150573.6295.17.camel@jonathans-macbook> <2f9b2d30903151811r67bd9701k30ed7d893982e197@mail.gmail.com> Message-ID: <1237166000.6334.10.camel@jonathans-macbook> On Sun, 2009-03-15 at 18:11 -0700, Ryan Ingram wrote: > On Sun, Mar 15, 2009 at 1:56 PM, Jonathan Cast > wrote: > >> But not if you switch the (x <- ...) and (y <- ...) parts: > >> > >> main = do > >> r <- newIORef 0 > >> v <- unsafeInterleaveIO $ do > >> writeIORef r 1 > >> return 1 > >> y <- readIORef r > >> x <- case f v of > >> 0 -> return 0 > >> n -> return (n - 1) > >> print y > >> > >> Now the IORef is read before the case has a chance to trigger the writing. > > > > But if the compiler is free to do this itself, what guarantee do I have > > that it won't? > > You don't really have any guarantee; the compiler is free to assume > that v is a pure integer and that f is a pure function from integers > to integers. Therefore, it can assume that the only observable affect > of calling f v is non-termination. Note that unsafeInterleaveIO > *breaks* this assumption; [Ignored; begging the question] jcc From alexander.dunlap at gmail.com Sun Mar 15 23:40:12 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Mar 15 23:28:14 2009 Subject: [Haskell-cafe] Data.Binary, Data.Text and errors Message-ID: <57526e770903152040l544363daja86386a4d0cc2a7a@mail.gmail.com> Hi all, I have noticed that in both Data.Binary and Data.Text (which is still experimental, but still), the "decode" functions can be undefined (i.e. bottom) if they encounter malformed input. What is the preferred way to use these functions in a safe way? For example, if one writes data to a disk using Data.Binary and wants to read it back in at a later date, how can one ensure that it is valid so that Data.Binary does not hit an error? Or do you just have to catch the exception in the IO Monad? Alex From heringtonlacey at mindspring.com Sun Mar 15 23:54:20 2009 From: heringtonlacey at mindspring.com (Dean Herington) Date: Sun Mar 15 23:42:29 2009 Subject: [Haskell-cafe] libgmp for GHC 6.10.1 on Mac OS X 10.5 Message-ID: I'm trying to install GHC 6.10.1 on Mac OS X 10.5 (PowerPC). I installed Xcode 3.1.2. I built libgmp 4.2.4 and installed it in /usr/local/lib. When I do "./configure" in GHC's dist directory, however, I get: bash-3.2$ ./configure checking build system type... powerpc-apple-darwin9.6.0 checking host system type... powerpc-apple-darwin9.6.0 checking target system type... powerpc-apple-darwin9.6.0 Which we'll further canonicalise into: powerpc-apple-darwin checking for path to top of build tree... dyld: Library not loaded: /usr/local/lib/libgmp.3.dylib Referenced from: /Users/family/Desktop/Downloads/ghc-6.10.1/dist/utils/pwd/pwd Reason: no suitable image found. Did find: /usr/local/lib/libgmp.3.dylib: mach-o, but wrong architecture /usr/local/lib/libgmp.3.dylib: mach-o, but wrong architecture configure: error: cannot determine current directory Any ideas what I'm doing wrong? Thanks. From docmach at gmail.com Mon Mar 16 00:03:10 2009 From: docmach at gmail.com (Alan Mock) Date: Sun Mar 15 23:51:14 2009 Subject: [Haskell-cafe] libgmp for GHC 6.10.1 on Mac OS X 10.5 In-Reply-To: References: Message-ID: By default GMP builds for x86_64. Do ./configure ABI=32 to build 32- bit libraries for GHC. On Mar 15, 2009, at 10:54 PM, Dean Herington wrote: > I'm trying to install GHC 6.10.1 on Mac OS X 10.5 (PowerPC). I > installed Xcode 3.1.2. I built libgmp 4.2.4 and installed it in / > usr/local/lib. When I do "./configure" in GHC's dist directory, > however, I get: > > bash-3.2$ ./configure > checking build system type... powerpc-apple-darwin9.6.0 > checking host system type... powerpc-apple-darwin9.6.0 > checking target system type... powerpc-apple-darwin9.6.0 > Which we'll further canonicalise into: powerpc-apple-darwin > checking for path to top of build tree... dyld: Library not loaded: / > usr/local/lib/libgmp.3.dylib > Referenced from: /Users/family/Desktop/Downloads/ghc-6.10.1/dist/ > utils/pwd/pwd > Reason: no suitable image found. Did find: > /usr/local/lib/libgmp.3.dylib: mach-o, but wrong architecture > /usr/local/lib/libgmp.3.dylib: mach-o, but wrong architecture > configure: error: cannot determine current directory > > Any ideas what I'm doing wrong? > > Thanks. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From bos at serpentine.com Mon Mar 16 00:13:57 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Mon Mar 16 00:01:59 2009 Subject: [Haskell-cafe] Data.Binary, Data.Text and errors In-Reply-To: <57526e770903152040l544363daja86386a4d0cc2a7a@mail.gmail.com> References: <57526e770903152040l544363daja86386a4d0cc2a7a@mail.gmail.com> Message-ID: On Sun, Mar 15, 2009 at 8:40 PM, Alexander Dunlap < alexander.dunlap@gmail.com> wrote: > > I have noticed that in both Data.Binary and Data.Text (which is still > experimental, but still), the "decode" functions can be undefined > (i.e. bottom) if they encounter malformed input. > For decoding Unicode, it's typical to provide a flexible API that can do one of the following on a bad encoding: - Substitute a character - Skip it - Return the partial decode - Throw an exception I just haven't gotten there yet. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090315/471f3655/attachment.htm From aeyakovenko at gmail.com Mon Mar 16 01:36:13 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Mon Mar 16 01:24:14 2009 Subject: [Haskell-cafe] Re: is there a version of hsffig that builds on a recent versin of haskell? In-Reply-To: <6191ca42-55aa-4731-90d2-82a24d92633c@33g2000yqm.googlegroups.com> References: <6191ca42-55aa-4731-90d2-82a24d92633c@33g2000yqm.googlegroups.com> Message-ID: i can try to fix it if i can get some help. i've never used cabal. any idea why i am getting this: anatolyy@anatolyy-linux /shared/anatolyy/hsffig-1.0 $ cabal install Warning: HSFFIG.cabal: The field "hs-source-dir" is deprecated, please use "hs-source-dirs" Warning: HSFFIG.cabal: The field "hs-source-dir" is deprecated, please use "hs-source-dirs" Warning: HSFFIG.cabal: The field "hs-source-dir" is deprecated, please use "hs-source-dirs" Resolving dependencies... Configuring HSFFIG-1.0... configure: searching for ghc in path. configure: found ghc at /usr/bin/ghc /usr/bin/ghc --version >tmp16646 configure: looking for package tool: ghc-pkg near compiler in /usr/bin/ghc configure: found package tool in /usr/bin/ghc-pkg configure: Using install prefix: /shared/anatolyy/.cabal configure: Using compiler: /usr/bin/ghc configure: Compiler flavor: GHC configure: Compiler version: 6.10.1 configure: Using package tool: /usr/bin/ghc-pkg configure: No haddock found configure: No happy found configure: No alex found configure: Using hsc2hs: /usr/bin/hsc2hs configure: No cpphs found configure: Reading installed packages... /usr/bin/ghc-pkg --user list >tmp16646 cannot parse package list cabal: Error: some packages failed to install: HSFFIG-1.0 failed during the configure step. The exception was: exit: ExitFailure 1 anatolyy@anatolyy-linux /shared/anatolyy/hsffig-1.0 $ /usr/bin/ghc-pkg --user list /usr2/anatolyy/.ghc/x86_64-linux-6.10.1/package.conf: {FiniteMap-0.1}, {HUnit-1.2.0.3}, {X11-1.4.5}, {haskell98-1.0.1.0}, {html-1.0.1.2}, {mtl-1.1.0.2}, {parsec-2.1.0.1}, {process-1.0.1.1}, {regex-base-0.93.1}, {regex-compat-0.92}, {regex-posix-0.94.1}, {text-0.1}, {xmonad-0.8.1} On Sun, Mar 15, 2009 at 11:20 AM, Dmitry Golubovsky wrote: > On Mar 15, 4:03?am, Anatoly Yakovenko wrote: >> is there a version of hsffig that builds on a recent versin of haskell? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > > Unfortunately no. There have been too many changes in GCC and GHC > since, and too low interest to the project from other developers, so I > did not maintain it. > > Dmitry. > > From leaveye.guo at gmail.com Mon Mar 16 01:49:26 2009 From: leaveye.guo at gmail.com (L.Guo) Date: Mon Mar 16 01:41:46 2009 Subject: [Haskell-cafe] A new haskell tools project Message-ID: <200903161349233127203@gmail.com> Hi all: I have just created an haskell work toolset project in google code. Currently there are only a few tools to process YUV image files I wrote before. Welcome you attend in to improve my code or to add in your tools. And also pleasure to get your advices. http://code.google.com/p/haskellworkingtools/ Regards -------------- L.Guo 2009-03-16 From ajb at spamcop.net Mon Mar 16 01:56:40 2009 From: ajb at spamcop.net (ajb@spamcop.net) Date: Mon Mar 16 01:44:16 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <49BC8960.5020608@freegeek.org> References: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> <49BC8960.5020608@freegeek.org> Message-ID: <20090316015640.26yrr8ce8wc0k404-nwo@webmail.spamcop.net> G'day all. Quoting wren ng thornton : > Most of the (particular) problems OO design patterns solve are > non-issues in Haskell because the language is more expressive. ...and vice versa. Some of the "design patterns" that we use in Haskell, for example, are to overcome the fact that Haskell doesn't have mutable global state. > A number of other patterns can > actually be written down once and for all (in higher-order functions > like foldr, map,...) instead of needing repetition. This is also true in many OO languages. A lot of the GoF book, for example, can be implemented as libraries in Ada or C++. > And then there are some things like monoids which fall somewhere > between idiom and pearl. "Things like monoids" are constructions from algebra. Abstract algebra and design patterns have a lot in common. They're based on the same idea, in fact: When a pattern keeps showing up, define it and give it a name so you can talk about it independently of any specific implementation. Or to put it another way, category theory is the pattern language of mathematics. Cheers, Andrew Bromage From martin.hofmann at uni-bamberg.de Mon Mar 16 03:37:56 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Mon Mar 16 03:25:36 2009 Subject: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime] In-Reply-To: <20090313165107.GE25888@katherina.student.utwente.nl> References: <20090312100136.F145C32490C@www.haskell.org> <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> <1236876446.6867.132.camel@ios.cogsys.wiai.uni-bamberg.de> <1236931402.6409.24.camel@ios.cogsys.wiai.uni-bamberg.de> <1768C9DF-FB23-44BD-AD35-C2CC73A95B24@ece.cmu.edu> <1236960191.6147.41.camel@ios.cogsys.wiai.uni-bamberg.de> <20090313165107.GE25888@katherina.student.utwente.nl> Message-ID: <1237189076.6155.23.camel@ios.cogsys.wiai.uni-bamberg.de> Matthijs Kooijman wrote: > I've been working on parsing core in the past few months. For an example, look > here: > http://git.stderr.nl/gitweb?p=matthijs/projects/fhdl.git;a=blob;f=Translator.hs;h=8072f85925ad1238 > > The loadModule and findBind functions are interesting. As for iterating the > AST, have a look at Flatten.hs. Thanks, Matthijs! This helps a lot and looks very promising! Only to avoid misunderstandings, you only use the ghc-api to get the AST of a CoreModule which you translate into your own data structure (VHDL). At this point, you don't use type information, right? Martin From ashley at semantic.org Mon Mar 16 04:36:26 2009 From: ashley at semantic.org (Ashley Yakeley) Date: Mon Mar 16 04:24:28 2009 Subject: [Haskell-cafe] Re: Uploading files to the wiki In-Reply-To: References: Message-ID: <49BE0F8A.4080906@semantic.org> Wouter Swierstra wrote: > I can't manage to upload files to the Haskell wiki. I've tried different > browsers, different internet connections, different machines, different > operating systems, and different user accounts - all without success. Is > this a new anti-spam measure? > > This is slightly annoying. I was looking to release the next > Monad.Reader on the wiki. Thanks for any advice, It turns out that both PHP and Apache have limits on file uploads. The PHP limit was set to 2MiB, and there was also a PHP-specific Apache configuration that limited POSTs to 0.5MiB. So Apache responded to this upload with a 413 error. MediaWiki (perhaps wisely) does not add its own upload limit, though it does issue a warning confirmation for files bigger than 150KiB. I've set both limits to 20MiB, and switched off MediaWiki's warning. I've uploaded Wouter's file to [[Image:TMR-Issue13.pdf]]. -- Ashley Yakeley From matthijs at stdin.nl Mon Mar 16 04:38:02 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Mon Mar 16 04:26:07 2009 Subject: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime] In-Reply-To: <1237189076.6155.23.camel@ios.cogsys.wiai.uni-bamberg.de> References: <20090312100136.F145C32490C@www.haskell.org> <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> <1236876446.6867.132.camel@ios.cogsys.wiai.uni-bamberg.de> <1236931402.6409.24.camel@ios.cogsys.wiai.uni-bamberg.de> <1768C9DF-FB23-44BD-AD35-C2CC73A95B24@ece.cmu.edu> <1236960191.6147.41.camel@ios.cogsys.wiai.uni-bamberg.de> <20090313165107.GE25888@katherina.student.utwente.nl> <1237189076.6155.23.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <20090316083802.GK25888@katherina.student.utwente.nl> Hi Martin, > Only to avoid misunderstandings, you only use the ghc-api to get the AST > of a CoreModule which you translate into your own data structure (VHDL). That's correct. > At this point, you don't use type information, right? I use some typing information, but that's mostly hidden away. In particular, when creating Signals using genSignalId I annotate them with the type of the expression the signal models. Later on, I translate this type to a VHDL type. To get at the type of an expression, I use the CoreUtils.exprType function, which gives you the type of any CoreExpr. Gr. Matthijs -------------- 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/20090316/a73b9fef/attachment.bin From alistair at abayley.org Mon Mar 16 04:45:10 2009 From: alistair at abayley.org (Alistair Bayley) Date: Mon Mar 16 04:33:11 2009 Subject: [Haskell-cafe] examples for error handling in takusen? In-Reply-To: References: Message-ID: <79d7c4980903160145h1eea8577y976b4b364db21ccb@mail.gmail.com> 2009/3/14 G??nther Schmidt : > Hi, > > can someone please point me to error handling examples with takusen? > > I try to run a piece of code with takusen but just get the very sparse > "Database.InternalEnumerator.DBException Hello G?nther, We use dynamic exceptions in Takusen, which is why you don't get much useful information when an exception is thrown. We will include the new extensible-exceptions code in the next release, so once that it done perhaps we can change the way we do exceptions so that you get better messages by default. There are some basic exception handling functions in Database.Enumerator which should help. Firstly, you need to add an exception handler with catchDB. Then you can choose to ignore the error, report it, or re-raise it (see basicDBExceptionReporter and reportRethrow). Also, the DBException constructors are exported, so you can pattern match on it to extract more information, like SqlState, error number, and error message. Alistair From martin.hofmann at uni-bamberg.de Mon Mar 16 04:47:06 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Mon Mar 16 04:34:40 2009 Subject: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime] In-Reply-To: <20090316083802.GK25888@katherina.student.utwente.nl> References: <20090312100136.F145C32490C@www.haskell.org> <1236868674.6867.118.camel@ios.cogsys.wiai.uni-bamberg.de> <1236876446.6867.132.camel@ios.cogsys.wiai.uni-bamberg.de> <1236931402.6409.24.camel@ios.cogsys.wiai.uni-bamberg.de> <1768C9DF-FB23-44BD-AD35-C2CC73A95B24@ece.cmu.edu> <1236960191.6147.41.camel@ios.cogsys.wiai.uni-bamberg.de> <20090313165107.GE25888@katherina.student.utwente.nl> <1237189076.6155.23.camel@ios.cogsys.wiai.uni-bamberg.de> <20090316083802.GK25888@katherina.student.utwente.nl> Message-ID: <1237193226.6155.45.camel@ios.cogsys.wiai.uni-bamberg.de> Okay, many thanks. That's exactly I need (I hope :-) ). Cheers, Martin From wss at Cs.Nott.AC.UK Mon Mar 16 04:51:44 2009 From: wss at Cs.Nott.AC.UK (Wouter Swierstra) Date: Mon Mar 16 04:39:47 2009 Subject: [Haskell-cafe] Re: Uploading files to the wiki In-Reply-To: <49BE0F8A.4080906@semantic.org> References: <49BE0F8A.4080906@semantic.org> Message-ID: <57AE86F7-F8D2-412A-835C-71BD35312392@Cs.Nott.AC.UK> > I've set both limits to 20MiB, and switched off MediaWiki's warning. > I've uploaded Wouter's file to [[Image:TMR-Issue13.pdf]]. Fantastic! Thanks for all your help, Wouter From wss at cs.nott.ac.uk Mon Mar 16 04:59:22 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Mon Mar 16 04:47:23 2009 Subject: [Haskell-cafe] ANN: The Monad.Reader (13) Message-ID: I am pleased to announce that a new issue of The Monad.Reader is now available: http://www.haskell.org/haskellwiki/The_Monad.Reader The Monad.Reader is a quarterly magazine about functional programming. Issue 13 consists of the following four articles: * Stephen Hicks Rapid Prototyping in TEX * Brent Yorgey The Typeclassopedia * Chris Eidhof, Eelco Lempsink Book Review: "Real World Haskell" * Derek Elkins Calculating Monads with Category Theory Special thanks to Ashley Yakeley for his help with publishing The Monad.Reader on the Haskell wiki. If you'd like to write something for the next issue of The Monad.Reader, please get in touch. I haven't fixed the deadline for the next issue, but it should be mid-May or thereabouts. Wouter From alexey.skladnoy at gmail.com Mon Mar 16 06:00:20 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Mon Mar 16 05:47:42 2009 Subject: [Haskell-cafe] Data.Binary, Data.Text and errors In-Reply-To: <57526e770903152040l544363daja86386a4d0cc2a7a@mail.gmail.com> References: <57526e770903152040l544363daja86386a4d0cc2a7a@mail.gmail.com> Message-ID: <200903161300.20434.alexey.skladnoy@gmail.com> On Monday 16 March 2009 06:40:12 Alexander Dunlap wrote: > Hi all, > > I have noticed that in both Data.Binary and Data.Text (which is still > experimental, but still), the "decode" functions can be undefined > (i.e. bottom) if they encounter malformed input. > > What is the preferred way to use these functions in a safe way? For > example, if one writes data to a disk using Data.Binary and wants to > read it back in at a later date, how can one ensure that it is valid > so that Data.Binary does not hit an error? Or do you just have to > catch the exception in the IO Monad? > I've used ErrorT monad transformer for decoding. With that it's possible to work around this problem. As downside one is required to do all checks and throw errors manually. It would be nice to have some kind of error handling in Data.Binary How it was done: > import Control.Monad.Error > > -- | Get monad with applied to it Error monad transformer > type Decoder = ErrorT String Get > > -- | Subequipment data > data SubEq = SubEq { subeqID :: Int > , subeqData :: ByteString } > > -- | Abort execution if function evaluates to True > dieIf :: (a -> Bool) -> String -> a -> Decoder () > dieIf f err x = when (f x) (throwError err) > > readSubEq :: Decoder SubEq > readSubEq = do > lift remaining >>= dieIf (<4) "DATE: Too short subequipment data (<4)" > -- Read header > len <- liftM (\x -> fromIntegral $ 2*x - 4) $ lift getWord16le > s_id <- liftM fromIntegral $ lift getWord16le > lift remaining >>= dieIf (< len) "DATE: Too short subequipment data" > buf <- lift $ getLazyByteString len > return $! SubEq s_id buf > > -- Actual decoding > decodeSubEq = runGet (runErrorT readSubEq) From roma at ro-che.info Mon Mar 16 05:59:15 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Mon Mar 16 05:50:45 2009 Subject: [Haskell-cafe] Hashing over equivalence classes In-Reply-To: <2f9b2d30903141136o2b14cbfbg6356ec4064355154@mail.gmail.com> References: <20090314105147.GA7258@flit> <2f9b2d30903141136o2b14cbfbg6356ec4064355154@mail.gmail.com> Message-ID: <20090316095915.GA29737@flit> * Ryan Ingram [2009-03-14 11:36:33-0700] > For the second case you might be able to come up with a commutative > hash-combiner function for && and ||. What a beautiful idea! I wish I thought of it myself. > For the lambda-term situation, I can think of a couple ways to hash > that give what you want. > > (1) Ignore variable names altogether while hashing; this gives you > what you want but has the disadvantage that (\a b. a) and (\a b. b) > hash to the same value. > (2) Hash the term with de Bruijn indices. But this is the same as > "hash the canonical element". Thanks for the reference. > I don't see that you have much other choice, though. Fortunately, due > to laziness, hash . canonicalize should not have much worse space > behavior than just hash. > > Did you have something else in mind? Not yet. > -- ryan > > On Sat, Mar 14, 2009 at 3:51 AM, Roman Cheplyaka wrote: > > Are there some known ways to define hashing (or any other) functions over > > equivalence classes? I.e. > > > > ?a ~ b => hash(a) == hash(b) > > > > where (~) is some equivalence relation. For example, you might want to > > hash lambda terms modulo alpha-equivalence or hash logical terms with > > respect to commutativity of (&&) and (||). > > > > Often we can choose 'canonical' element from each class and hash it. > > But (at least, in theory) it's not necessary. So, are there (practical) > > ways to define hash function without it? > > > > -- > > Roman I. Cheplyaka :: http://ro-che.info/ > > "Don't let school get in the way of your education." - Mark Twain > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From j.vimal at gmail.com Mon Mar 16 06:53:06 2009 From: j.vimal at gmail.com (Vimal) Date: Mon Mar 16 06:41:06 2009 Subject: [Haskell-cafe] Packet analysis framework for Haskell. Message-ID: Hi all, Is there a packet analysis framework in Haskell? The framework should abstract away the features of packet analysis in the form of a library that people can use and write extensions to perform computation on the packets flowing through the network. What are the "features" of packet analysis? 1. Support for packet packet selection, matching a particular criteria. Example: (protocol = tcp && destination_port = 80). 2. Multi-threaded. Since the process of computation on packets is inherently data-parallel, the framework should abstract away the parallelism and make use of different CPU cores if available. I believe the features in Haskell would be a great boon to easily achieve this. 3. Support for statistics. Packet analysis is usually done for a purpose. Say, I would like to collect statistics about the rate of connections to a webserver. I would want to: (a) Filter packets, using features in (1). (b) Count the number of packets that pass through after applying operation (a). (c) Generate reports if a particular condition is flagged in (b). Example: (a) protocol = tcp && SYN set in flags && destination_port = 80, (b) count the number of SYN packets, (c) report if d(count)/dt > 100. 4. Availability of efficient data structures for achieving real time performance. Example: The user might want to check if ARP spoofing is taking place. In which case, one has to cache the "already seen" mapping between protocol and hardware addresses learnt from the packets that flowed, and constantly checking new addresses against this structure for duplicates. The above are some of the features which I believe are necessary for packet analysis (or, analytics maybe?). There could be more. I was wondering if Haskell would be a good language to achieve these things. I had a brief idea and started writing an application in C and I realised the need for such a framework. The ease of parallelism offered by Haskell prompted me to think about using it. I would like to hear your comments. Also, would this qualify as a project that someone in the Haskell community would be willing to mentor for GSoC 2009? (Assuming Haskell would be on the list of mentoring organisations, although I have no reason to doubt it wouldn't.) Thanks, Regards, -- Vimal From barsoap at web.de Mon Mar 16 07:24:53 2009 From: barsoap at web.de (Achim Schneider) Date: Mon Mar 16 07:13:17 2009 Subject: [Haskell-cafe] Re: Packet analysis framework for Haskell. References: Message-ID: <20090316122453.5122c383@solaris> Vimal wrote: > The above are some of the features which I believe are necessary for > packet analysis (or, analytics maybe?). There could be more. I was > wondering if Haskell would be a good language to achieve these things. > I had a brief idea and started writing an application in C and I > realised the need for such a framework. The ease of parallelism > offered by Haskell prompted me to think about using it. I would like > to hear your comments. > I think it's a perfect fit, not only because of parallelism. Mentally combining parser combinators and state collectors a la quickcheck makes me wonder why anyone would use atrocities like iptables[1]... > Also, would this qualify as a project that someone in the Haskell > community would be willing to mentor for GSoC 2009? (Assuming Haskell > would be on the list of mentoring organisations, although I have no > reason to doubt it wouldn't.) > ZOMG! Don't ask, copy and paste your mail to the proposals! [1] says someone who actually likes iptables -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From kowey at darcs.net Mon Mar 16 08:09:38 2009 From: kowey at darcs.net (Eric Kow) Date: Mon Mar 16 07:57:39 2009 Subject: [Haskell-cafe] darcs fundraising drive - THANK-YOU! In-Reply-To: <20090314104237.GA419@Macintosh.local> References: <20090314104237.GA419@Macintosh.local> Message-ID: <20090316120937.GL25922@brighton.ac.uk> Dear darcs users and Haskellers, I wanted to thank you all for your contributions to our first darcs fundraising drive. We've done it! We managed to raise $1000, over two weeks with contributions from 22 donors. This means that we will able to help our programmers travel to the darcs hacking sprint. This fundraising drive is over, but donations will still be gratefully accepted. In the long term, we hope to raise another $5000 to pay for a summer project ($4000) and also to pay for travel (another $1000) to the third hacking sprint this October or November. Again, thank-you! -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/b6848182/attachment.bin From nonowarn at gmail.com Mon Mar 16 08:48:16 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Mon Mar 16 08:36:38 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <49BDA5A4.7070406@freegeek.org> References: <49BDA5A4.7070406@freegeek.org> Message-ID: <4504CC09-29A3-46E6-AE38-7C54AE4BFCBF@gmail.com> Hi, On 2009/03/16, at 10:04, wren ng thornton wrote: > > > next r = do n <- readIORef r > > writeIORef r (n+1) > > return n > > Now, if I use unsafeInterleaveIO: > > > main = do r <- newIORef 0 > > x <- do a <- unsafeInterleaveIO (next r) > > b <- unsafeInterleaveIO (next r) > > return (a,b) > > ... > > The values of a and b in x are entirely arbitrary, and are only set > at the point when they are first accessed. They're not just > arbitrary between which is 0 and which is 1, they could be *any* > pair of values (other than equal) since the reference r is still in > scope and other code in the ... could affect it before we access a > and b, or between the two accesses. OK, the values of a and b depend how to deconstruct x. > Moreover, let's have two pure implementations, f and g, of the same > mathematical function. Even if f and g are close enough to > correctly give the same output for inputs with _|_ in them, we may > be able to observe the fact that they arrive at those answers > differently by passing in our x. Given that such observations are > possible, it is no longer safe to exchange f and g for one another, > despite the fact that they are pure and give the same output for > all (meaningful) inputs. Hm, Does it means that in optimization, a compiler may replace implementation of a pure function that have different order of evaluation, so order of actions would be different in some environments? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/dea1d3c7/attachment.htm From haskell at list.mightyreason.com Mon Mar 16 08:50:29 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Mon Mar 16 08:38:44 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <49B9A674.4020708@list.mightyreason.com> <910ddf450903141445o5d893949wfd10e01177e6e821@mail.gmail.com> <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> Message-ID: <49BE4B15.8030709@list.mightyreason.com> Thomas Hartman wrote: > > testPcre = ( subRegex (mkRegex "(? "" ) == "asdf \n\n\nadsf" quoting from the man page for regcomp: > REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with > no special meaning in either REs or strings. With this flag, `[^' bracket expressions and `.' never > match newline, a `^' anchor matches the null string after any newline in the string in addition to > its normal function, and the `$' anchor matches the null string before any newline in the string in > addition to its normal function. This is the carried over to Text.Regex with > mkRegexWithOpts Source > :: String The regular expression to compile > -> Bool True <=> '^' and '$' match the beginning and end of individual lines respectively, and '.' does not match the newline character. > -> Bool True <=> matching is case-sensitive > -> Regex Returns: the compiled regular expression > Makes a regular expression, where the multi-line and case-sensitive options can be changed from the default settings. Or with regex-posix directly the flag is "compNewline": http://hackage.haskell.org/packages/archive/regex-posix/0.94.1/doc/html/Text-Regex-Posix-Wrap.html > The defaultCompOpt is (compExtended .|. compNewline). You want to match a \n that is not next to any other \n. So you want to turn off REG_NEWLINE. > import Text.Regex.Compat > > r :: Regex > r = mkRegexWithOpts "(^|[^\n])\n($|[^\n])" False True -- False is important here The ^ and $ take care of matching a lone newline at the start or end of the whole text. In the middle of the text the pattern is equivalent to [^\n]\n[^\n]. When substituting you can use the \1 and \2 captures to restore the matched non-newline character if one was present. From haskell at list.mightyreason.com Mon Mar 16 08:50:41 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Mon Mar 16 08:43:01 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <49B9A674.4020708@list.mightyreason.com> <910ddf450903141445o5d893949wfd10e01177e6e821@mail.gmail.com> <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> Message-ID: Thomas Hartman wrote: > > testPcre = ( subRegex (mkRegex "(? "" ) == "asdf \n\n\nadsf" quoting from the man page for regcomp: > REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with > no special meaning in either REs or strings. With this flag, `[^' bracket expressions and `.' never > match newline, a `^' anchor matches the null string after any newline in the string in addition to > its normal function, and the `$' anchor matches the null string before any newline in the string in > addition to its normal function. This is the carried over to Text.Regex with > mkRegexWithOpts Source > :: String The regular expression to compile > -> Bool True <=> '^' and '$' match the beginning and end of individual lines respectively, and '.' does not match the newline character. > -> Bool True <=> matching is case-sensitive > -> Regex Returns: the compiled regular expression > Makes a regular expression, where the multi-line and case-sensitive options can be changed from the default settings. Or with regex-posix directly the flag is "compNewline": http://hackage.haskell.org/packages/archive/regex-posix/0.94.1/doc/html/Text-Regex-Posix-Wrap.html > The defaultCompOpt is (compExtended .|. compNewline). You want to match a \n that is not next to any other \n. So you want to turn off REG_NEWLINE. > import Text.Regex.Compat > > r :: Regex > r = mkRegexWithOpts "(^|[^\n])\n($|[^\n])" False True -- False is important here The ^ and $ take care of matching a lone newline at the start or end of the whole text. In the middle of the text the pattern is equivalent to [^\n]\n[^\n]. When substituting you can use the \1 and \2 captures to restore the matched non-newline character if one was present. From apfelmus at quantentunnel.de Mon Mar 16 09:07:53 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Mon Mar 16 08:54:56 2009 Subject: [Haskell-cafe] Re: A non-inductive Haskell proof? In-Reply-To: References: Message-ID: R J wrote: > The following theorem is obviously true, but how is it proved (most cleanly and simply) > in Haskell? > > Theorem: (nondecreasing xs) => nondecreasing (insert x xs), where: > > nondecreasing :: (Ord a) => [a] -> Bool > nondecreasing [] = True > nondecreasing xxs@(x : xs) = and [a <= b | (a, b) <- zip xxs xs] > > insert :: (Ord a) => a -> [a] -> [a] > insert x xs = takeWhile (<= x) xs ++ [x] ++ dropWhile (<= x) xs Since insert involves list concatenation at the outermost level, the first step is to prove a lemma along the lines of nondecreasing xs && nondecreasing ys && (last xs <= head ys) => nondecreasing (xs ++ ys) from which the wanted theorem follows immediately. The lemma itself is proved readily by noting/proving and (xs ++ ys) = and xs && and ys zip (xs ++ ys) (tail (xs ++ ys)) ~= zip xs (tail xs) ++ [(last xs, head ys)] ++ zip ys (tail ys) Regards, apfelmus -- http://apfelmus.nfshost.com From allbery at ece.cmu.edu Mon Mar 16 09:59:42 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Mar 16 09:47:59 2009 Subject: [Haskell-cafe] Packet analysis framework for Haskell. In-Reply-To: References: Message-ID: <3B7343A9-8086-4333-AFCD-EF7C8B306D41@ece.cmu.edu> On 2009 Mar 16, at 6:53, Vimal wrote: > Is there a packet analysis framework in Haskell? The framework should > abstract away the features of packet analysis in the form of a library > that people can use and write extensions to perform computation on the > packets flowing through the network. The only one I'm aware of is http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Etherbunny but I couldn't tell you how Haskelly it is (it's in my "look at in my Copious Spare Time?" list). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/4b55cc19/PGP.bin From allbery at ece.cmu.edu Mon Mar 16 10:08:10 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Mar 16 09:56:12 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <4504CC09-29A3-46E6-AE38-7C54AE4BFCBF@gmail.com> References: <49BDA5A4.7070406@freegeek.org> <4504CC09-29A3-46E6-AE38-7C54AE4BFCBF@gmail.com> Message-ID: <3BCF7754-478D-4C3D-829B-1F9F62D869CD@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/48c171be/PGP.bin From ariep at xs4all.nl Mon Mar 16 10:26:41 2009 From: ariep at xs4all.nl (Arie Peterson) Date: Mon Mar 16 10:09:14 2009 Subject: [Haskell-cafe] Incompatibility of different (monad transformer) libraries In-Reply-To: References: <63c2e535e6a4e2f382c777103a37dc67@xs4all.nl> Message-ID: <250f340b1765fbf40cbc7de264d55434@xs4all.nl> On Sat, 14 Mar 2009 02:14:53 +0100 (CET), Henning Thielemann wrote: > I think 'transformers' exports Control.Monad.Trans.State. This should not > conflict with MTL. However, MTL's State type is different from > transformer's one. Is that your problem? No. The immediate problem is, that a module named Control.Monad.State is exported by both mtl and monads-tf (and my code needs both packages). It is indeed unfortunate that mtl:State is a different type from transformers:State, but that is not biting me right now. > Since the 'cabal' tool became better and better, today I use a cabal file > even for small programs. Cabal automatically calls GHC with the right > package exposing and hiding options. I already use cabal; my own package has mtl, transformers and monads-tf among its dependencies. Regards, Arie From jake at pikewerks.com Mon Mar 16 10:55:59 2009 From: jake at pikewerks.com (Jake McArthur) Date: Mon Mar 16 10:43:54 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: References: Message-ID: <49BE687F.7000702@pikewerks.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Yusaku Hashimoto wrote: | I was studying about what unsafeInterleaveIO is.I understood | unsafeInterleaveIO takes an IO action, and delays it. But I couldn't | find any reason why unsafeInterleaveIO is unsafe. I think it depends on what we want to take "unsafe" to mean. In my opinion, the word "unsafe" should really only be used in cases where using the function can case an otherwise well-typed program to not be well-typed. I'm pretty sure I haven't yet seen a case where this applies to unsafeInterleaveIO. The biggest problem with unsafeInterleaveIO is that it complicates the semantics of the IO monad. - - Jake -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkm+aH8ACgkQye5hVyvIUKkOygCghyHD90TdvCBR5V815fxmQbIy mKsAnjnAgtZ5jV1p1P2St5NB2li587lU =PzqF -----END PGP SIGNATURE----- From g9ks157k at acme.softbase.org Mon Mar 16 10:58:50 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Mon Mar 16 10:46:52 2009 Subject: [Haskell-cafe] Natural Numbers: Best implementation? In-Reply-To: References: <2816604275516129323@unknownmsgid> <200903130937.49012.g9ks157k@acme.softbase.org> Message-ID: <200903161558.50906.g9ks157k@acme.softbase.org> Am Samstag, 14. M?rz 2009 23:33 schrieben Sie: > On Fri, 13 Mar 2009, Wolfgang Jeltsch wrote: > > Class instances should satisfy certain laws. (Although these laws are > > often not stated explicitely, they are assumed to hold by users of the > > class and they should hold to make the instance sensible.) In the case of > > Num, I would expect num + negate num to equal num. > > "equal zero" ? Exactly. Best wishes, Wolfgang From dons at galois.com Mon Mar 16 11:05:37 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 16 10:54:29 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace Message-ID: <20090316150537.GA29292@whirlpool.galois.com> I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ From vanenkj at gmail.com Mon Mar 16 11:14:04 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Mar 16 11:02:04 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: <20090316150537.GA29292@whirlpool.galois.com> References: <20090316150537.GA29292@whirlpool.galois.com> Message-ID: How long did the haskell universe graphs take to render? On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart wrote: > I've just finished a post (and quick tool) for graphing the complete > module namespace of Haskell, taken from the core libraries and all of > Hackage. > > It's quite large: > > > http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/1ad3dfe5/attachment.htm From dons at galois.com Mon Mar 16 11:14:42 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 16 11:03:36 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: References: <20090316150537.GA29292@whirlpool.galois.com> Message-ID: <20090316151442.GB29292@whirlpool.galois.com> Oh, barely any time (maybe 30-60 seconds). It's "just" a 10k node graph with a 50k edges. :) vanenkj: > How long did the haskell universe graphs take to render? > > On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart wrote: > > I've just finished a post (and quick tool) for graphing the complete > module namespace of Haskell, taken from the core libraries and all of > Hackage. > > It's quite large: > > http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe > / > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -- > /jve From jefferson.r.heard at gmail.com Mon Mar 16 11:16:54 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Mon Mar 16 11:04:56 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: <20090316151442.GB29292@whirlpool.galois.com> References: <20090316150537.GA29292@whirlpool.galois.com> <20090316151442.GB29292@whirlpool.galois.com> Message-ID: <4165d3a70903160816m6961d3b8r1efbfe6f88bb9421@mail.gmail.com> Very impressive looking, Don. -- Jeff On Mon, Mar 16, 2009 at 11:14 AM, Don Stewart wrote: > Oh, barely any time (maybe 30-60 seconds). It's "just" a 10k node graph with a 50k edges. :) > > vanenkj: >> How long did the haskell universe graphs take to render? >> >> On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart wrote: >> >> ? ? I've just finished a post (and quick tool) for graphing the complete >> ? ? module namespace of Haskell, taken from the core libraries and all of >> ? ? Hackage. >> >> ? ? It's quite large: >> >> ? ? ? ?http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe >> ? ? / >> ? ? _______________________________________________ >> ? ? Haskell-Cafe mailing list >> ? ? Haskell-Cafe@haskell.org >> ? ? http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> >> >> -- >> /jve > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Mon Mar 16 11:17:42 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 16 11:06:35 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: <4165d3a70903160816m6961d3b8r1efbfe6f88bb9421@mail.gmail.com> References: <20090316150537.GA29292@whirlpool.galois.com> <20090316151442.GB29292@whirlpool.galois.com> <4165d3a70903160816m6961d3b8r1efbfe6f88bb9421@mail.gmail.com> Message-ID: <20090316151742.GC29292@whirlpool.galois.com> My secret hope is that Jeff will take the .dot files and doing something very cool with them.... jefferson.r.heard: > Very impressive looking, Don. > > -- Jeff > > On Mon, Mar 16, 2009 at 11:14 AM, Don Stewart wrote: > > Oh, barely any time (maybe 30-60 seconds). It's "just" a 10k node graph with a 50k edges. :) > > > > vanenkj: > >> How long did the haskell universe graphs take to render? > >> > >> On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart wrote: > >> > >> ? ? I've just finished a post (and quick tool) for graphing the complete > >> ? ? module namespace of Haskell, taken from the core libraries and all of > >> ? ? Hackage. > >> > >> ? ? It's quite large: > >> > >> ? ? ? ?http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe > >> ? ? / > >> ? ? _______________________________________________ > >> ? ? Haskell-Cafe mailing list > >> ? ? Haskell-Cafe@haskell.org > >> ? ? http://www.haskell.org/mailman/listinfo/haskell-cafe > >> > >> > >> > >> > >> -- > >> /jve > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From jnschaeffer at gmail.com Mon Mar 16 11:21:55 2009 From: jnschaeffer at gmail.com (John Schaeffer) Date: Mon Mar 16 11:09:54 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: <20090316150537.GA29292@whirlpool.galois.com> References: <20090316150537.GA29292@whirlpool.galois.com> Message-ID: Beautiful; I especially like the "neato" rendering. There's just something about the concentric circles radiating out from certain modules that just looks so...well, cool. Nice work! -John On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart wrote: > I've just finished a post (and quick tool) for graphing the complete > module namespace of Haskell, taken from the core libraries and all of > Hackage. > > It's quite large: > > > http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ > _______________________________________________ > 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/20090316/9a746dfa/attachment.htm From jefferson.r.heard at gmail.com Mon Mar 16 11:22:17 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Mon Mar 16 11:10:16 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: <20090316151742.GC29292@whirlpool.galois.com> References: <20090316150537.GA29292@whirlpool.galois.com> <20090316151442.GB29292@whirlpool.galois.com> <4165d3a70903160816m6961d3b8r1efbfe6f88bb9421@mail.gmail.com> <20090316151742.GC29292@whirlpool.galois.com> Message-ID: <4165d3a70903160822q4b387bedw125ecd38f5e6c4fd@mail.gmail.com> That's why I just asked on IRC for them :-) Also wrote most of a Hieroglyph script last night to replace the graph of daily uploads on Hackage. Will send it out tonight or tomorrow. On Mon, Mar 16, 2009 at 11:17 AM, Don Stewart wrote: > My secret hope is that Jeff will take the .dot files and doing > something very cool with them.... > > jefferson.r.heard: >> Very impressive looking, Don. >> >> -- Jeff >> >> On Mon, Mar 16, 2009 at 11:14 AM, Don Stewart wrote: >> > Oh, barely any time (maybe 30-60 seconds). It's "just" a 10k node graph with a 50k edges. :) >> > >> > vanenkj: >> >> How long did the haskell universe graphs take to render? >> >> >> >> On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart wrote: >> >> >> >> ? ? I've just finished a post (and quick tool) for graphing the complete >> >> ? ? module namespace of Haskell, taken from the core libraries and all of >> >> ? ? Hackage. >> >> >> >> ? ? It's quite large: >> >> >> >> ? ? ? ?http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe >> >> ? ? / >> >> ? ? _______________________________________________ >> >> ? ? Haskell-Cafe mailing list >> >> ? ? Haskell-Cafe@haskell.org >> >> ? ? http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> >> >> >> >> >> >> >> -- >> >> /jve >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> > From bugfact at gmail.com Mon Mar 16 12:16:23 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Mar 16 12:04:23 2009 Subject: [Haskell-cafe] Polynomial and VectorSpace Message-ID: The DSP package on Hackage seems to contain complex polynomial functions. It seems these functions are completely independent of the other DSP functions, so this package could be split of? Also, polynomials form a vector space, so could be made an instance of VectorSpace class? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/beaa3c3f/attachment.htm From mark.spezzano at chariot.net.au Mon Mar 16 12:27:31 2009 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Mon Mar 16 12:15:42 2009 Subject: [Haskell-cafe] Map in Terms of Fold in terms of Map Message-ID: <002401c9a654$1bb10720$53131560$@spezzano@chariot.net.au> Hi, I’ve noticed that it’s possible to define map as foldr and foldr as a map. Would this be sensible to define both in terms of each other in the Prelude? i.e mutually recursive? Cheers, Mark No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.15/2003 - Release Date: 15/03/2009 2:07 PM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090317/851e6387/attachment.htm From ndmitchell at gmail.com Mon Mar 16 12:31:58 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Mar 16 12:19:59 2009 Subject: [Haskell-cafe] Map in Terms of Fold in terms of Map In-Reply-To: <8510344099582368822@unknownmsgid> References: <8510344099582368822@unknownmsgid> Message-ID: <404396ef0903160931p59a3bccfxb822ca1c45288100@mail.gmail.com> Hi Mark, What's the definition of foldr in terms of map? As far as I was aware, its not possible. And as it happens, map is (or is sometimes) defined in term of foldr :-) While you can use mutual recursion, you can't define a in terms of b and b in terms of a unless one of them actually does something at the end - so it does depend exactly what the definitions are. Thanks Neil 2009/3/16 Mark Spezzano : > Hi, > > > > I?ve noticed that it?s possible to define map as foldr and foldr as a map. > Would this be sensible to define both in terms of each other in the Prelude? > ?i.e mutually recursive? > > > > Cheers, > > > > Mark > > > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.557 / Virus Database: 270.11.15/2003 - Release Date: 15/03/2009 > 2:07 PM > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From abdullah.ak2002 at gmail.com Mon Mar 16 12:51:41 2009 From: abdullah.ak2002 at gmail.com (abdullah abdul Khadir) Date: Mon Mar 16 12:39:40 2009 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 67, Issue 41 In-Reply-To: <20090316150510.483A1324852@www.haskell.org> References: <20090316150510.483A1324852@www.haskell.org> Message-ID: <719881900903160951n3797f54bhdd291b6c5406abf6@mail.gmail.com> > > > On Mon, 16 Mar 2009 08:05:37 -0700 Don Stewart wrote : > Subject: [Haskell-cafe] Visualising the Hierarchical Namespace > > I've just finished a post (and quick tool) for graphing the complete > module namespace of Haskell, taken from the core libraries and all of > Hackage. > > It's quite large: > > > http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ Hi Don, That was really good. Amazing stuff there. In fact I just (re) joined the haskell and lisp mailing lists. Course work was keeping me at bay from following my passion for functional programming paradigms except that one of my courses was in fact haskell last semester. Well, it seems as if haskell is taking the functional world by storm. Even in the lisp mailing lists I hear of people reading haskell books, "Real World Haskell" was one of them and in fact they seem to be appreciating the type system offered by haskell. Now, that really means something. You know how hard it is to impress the lisp folks. All in all an impressive run so far. Hats off to all those developers and the Haskell community at large. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/b18542a5/attachment.htm From manlio_perillo at libero.it Mon Mar 16 14:01:42 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 16 13:49:52 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: <20090316150537.GA29292@whirlpool.galois.com> References: <20090316150537.GA29292@whirlpool.galois.com> Message-ID: <49BE9406.5030105@libero.it> Don Stewart ha scritto: > I've just finished a post (and quick tool) for graphing the complete > module namespace of Haskell, taken from the core libraries and all of > Hackage. > > It's quite large: > > http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ Just a note: isn't it time to switch to SVG images? All that PNG images are pretty "useless", they are too small. Manlio From dons at galois.com Mon Mar 16 14:02:53 2009 From: dons at galois.com (Don Stewart) Date: Mon Mar 16 13:51:45 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: <49BE9406.5030105@libero.it> References: <20090316150537.GA29292@whirlpool.galois.com> <49BE9406.5030105@libero.it> Message-ID: <20090316180253.GD29587@whirlpool.galois.com> manlio_perillo: > Don Stewart ha scritto: >> I've just finished a post (and quick tool) for graphing the complete >> module namespace of Haskell, taken from the core libraries and all of >> Hackage. >> >> It's quite large: >> >> http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ > > Just a note: isn't it time to switch to SVG images? > All that PNG images are pretty "useless", they are too small. > All the .svg's are linked at the bottom. Note: they will break your browser -- Don From ryani.spam at gmail.com Mon Mar 16 14:11:10 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Mar 16 13:59:10 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <49BE687F.7000702@pikewerks.com> References: <49BE687F.7000702@pikewerks.com> Message-ID: <2f9b2d30903161111p493a5998pe6ed757c2aea5ffd@mail.gmail.com> On Mon, Mar 16, 2009 at 7:55 AM, Jake McArthur wrote: > I think it depends on what we want to take "unsafe" to mean. In my > opinion, the word "unsafe" should really only be used in cases where > using the function can case an otherwise well-typed program to not be > well-typed. I'm pretty sure I haven't yet seen a case where this applies > to unsafeInterleaveIO. I don't think unsafeInterleaveIO on its own can do this. However, I disagree with your description of what "unsafe" should be used for. "unsafe" calls out the need for the programmer to prove that what they are doing is safe semantically, instead of the compiler providing those proofs for you. Whether that is due to type safety (unsafeCoerce) or breaking the assumptions of the compiler (unsafePerformIO, unsafeInterleaveIO, unsafeIOToST), depends on the situation. For example, unsafePerformIO can make your program not type-safe, but it's convoluted to do so; in fact, at monomorphic types it can't break type safety. That's not what makes it unsafe at all. It's unsafe because it breaks the rule that pure values don't have side effects, so that the effects inside the unsafePerformIO might get executed more than once, or not at all, depending on how the compiler decides to evaluate the pure value returned. And what happens could depend on the optimization settings of the compiler, the timing of the machine you are running on, or the phase of the moon. -- ryan From manlio_perillo at libero.it Mon Mar 16 14:33:22 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 16 14:21:31 2009 Subject: [Haskell-cafe] Visualising the Hierarchical Namespace In-Reply-To: <20090316180253.GD29587@whirlpool.galois.com> References: <20090316150537.GA29292@whirlpool.galois.com> <49BE9406.5030105@libero.it> <20090316180253.GD29587@whirlpool.galois.com> Message-ID: <49BE9B72.8020006@libero.it> Don Stewart ha scritto: > manlio_perillo: >> Don Stewart ha scritto: >>> I've just finished a post (and quick tool) for graphing the complete >>> module namespace of Haskell, taken from the core libraries and all of >>> Hackage. >>> >>> It's quite large: >>> >>> http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ >> Just a note: isn't it time to switch to SVG images? >> All that PNG images are pretty "useless", they are too small. >> > > All the .svg's are linked at the bottom. > > Note: they will break your browser > FF handle them quite well. The problem is that there is too much informations :). By the way: in the SVG files there is a lot of redundant informations. Graphviz should realy use CSS instead of SVG presentation attributes. Using CSS to factor out common style should reduce image size a lot. I would like to see a Graphics package for Haskell, based on SVG/libVG/Cairo/PDF imaging model. Manlio From dan.doel at gmail.com Mon Mar 16 14:39:24 2009 From: dan.doel at gmail.com (Dan Doel) Date: Mon Mar 16 14:27:28 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <2f9b2d30903161111p493a5998pe6ed757c2aea5ffd@mail.gmail.com> References: <49BE687F.7000702@pikewerks.com> <2f9b2d30903161111p493a5998pe6ed757c2aea5ffd@mail.gmail.com> Message-ID: <200903161439.25328.dan.doel@gmail.com> On Monday 16 March 2009 2:11:10 pm Ryan Ingram wrote: > However, I disagree with your description of what "unsafe" should be > used for. "unsafe" calls out the need for the programmer to prove > that what they are doing is safe semantically, instead of the compiler > providing those proofs for you. Whether that is due to type safety > (unsafeCoerce) or breaking the assumptions of the compiler > (unsafePerformIO, unsafeInterleaveIO, unsafeIOToST), depends on the > situation. Of course, unsafeIOToST can also break the type system, because you can write: unsafePerformIO m = runST (unsafeIOToST m) > For example, unsafePerformIO can make your program not type-safe, but > it's convoluted to do so; in fact, at monomorphic types it can't break > type safety. That's not what makes it unsafe at all. It's unsafe > because it breaks the rule that pure values don't have side effects, > so that the effects inside the unsafePerformIO might get executed more > than once, or not at all, depending on how the compiler decides to > evaluate the pure value returned. And what happens could depend on > the optimization settings of the compiler, the timing of the machine > you are running on, or the phase of the moon. In practice, 'unsafe' can mean any number of things depending on the context. unsafeRead/Write on mutable arrays can (attempt to) read/write arbitrary memory locations. An index into a data structure that just calls error instead of returning a Maybe result might be called unsafe. In a similar vein, some people think head and tail should be called unsafeHead and unsafeTail. :) Technically, one can probably lay down a semantics of IO such that unsafeInterleaveIO maintains the purity of the language by the usual definitions. However, such a semantics is necessarily too vague to explain why you might want to use it in the first place, because the only real reason you'd want to do so is to have side effects triggered in response to evaluation of otherwise pure terms. At the very least, using unsafeInterleaveIO adds significant complications to reasoning about the behavior of otherwise ordinary IO, which might well justify its name. -- Dan From csaba.hruska at gmail.com Mon Mar 16 15:01:12 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Mon Mar 16 14:49:13 2009 Subject: [Haskell-cafe] Lambda-Cube 3D render engine Message-ID: <8914b92d0903161201q372af11dp892659c17ecad638@mail.gmail.com> Hi! I've created a wiki page for my project. Currently only some text and screenshot are available. Additional documentation and source code are coming soon.. :) http://www.haskell.org/haskellwiki/LambdaCubeEngine Cheers, Csaba Hruska -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/e4235517/attachment.htm From tphyahoo at gmail.com Mon Mar 16 15:24:47 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Mar 16 15:12:47 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <49B9A674.4020708@list.mightyreason.com> <910ddf450903141445o5d893949wfd10e01177e6e821@mail.gmail.com> <910ddf450903141601h184667aeic9e4f76c8f6d7c82@mail.gmail.com> Message-ID: <910ddf450903161224s4937ef4fp70fbe2133fb7de32@mail.gmail.com> Thanks, that was extremely helpful. My bad for being so sloppy reading the documentation so sloppily -- I somehow glossed over the bit that backreferences worked as one would expect. To atone for this, http://patch-tag.com/repo/haskell-learning/browse/regexStuff/pcreReplace.hs shows successful =~ s/../../ -like behavior for a pcre and a posix-like (but compatible with pcre engine) regex in the same example, which is based on pcre regex. (See testPcre, testPosix). FWIW, I still think that there should be a library subRegex function for all regex flavors, and not just Posix. If there are gotchas about how capture references work in different flavors I might backpedal on this, but Im not aware of any. 2009/3/16 ChrisK : > Thomas Hartman wrote: >> >> testPcre = ( subRegex (mkRegex "(?> "" ) == "asdf \n\n\nadsf" > > quoting from the man page for regcomp: > >> REG_NEWLINE ? Compile for newline-sensitive matching. ?By default, newline >> is a completely ordinary character with >> ? ? ? ? ? ? ?no special meaning in either REs or strings. ?With this flag, >> `[^' bracket expressions and `.' never >> ? ? ? ? ? ? ?match newline, a `^' anchor matches the null string after any >> newline in the string in addition to >> ? ? ? ? ? ? ?its normal function, and the `$' anchor matches the null >> string before any newline in the string in >> ? ? ? ? ? ? ?addition to its normal function. > > This is the carried over to Text.Regex with > >> mkRegexWithOpts Source >> :: String ? ? ? The regular expression to compile >> -> Bool True <=> '^' and '$' match the beginning and end of individual >> lines respectively, and '.' does not match the newline character. >> -> Bool True <=> matching is case-sensitive >> -> Regex ? ? ? ?Returns: the compiled regular expression >> Makes a regular expression, where the multi-line and case-sensitive >> options can be changed from the default settings. > > Or with regex-posix directly the flag is "compNewline": > http://hackage.haskell.org/packages/archive/regex-posix/0.94.1/doc/html/Text-Regex-Posix-Wrap.html >> The defaultCompOpt is (compExtended .|. compNewline). > > You want to match a \n that is not next to any other \n. > > So you want to turn off REG_NEWLINE. > >> import Text.Regex.Compat >> >> r :: Regex >> r = mkRegexWithOpts "(^|[^\n])\n($|[^\n])" False True ?-- False is >> important here > > > The ^ and $ take care of matching a lone newline at the start or end of the > whole text. ?In the middle of the text the pattern is equivalent to > [^\n]\n[^\n]. > > When substituting you can use the \1 and \2 captures to restore the matched > non-newline character if one was present. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From aslatter at gmail.com Mon Mar 16 15:27:48 2009 From: aslatter at gmail.com (Antoine Latter) Date: Mon Mar 16 15:15:47 2009 Subject: [Haskell-cafe] Incompatibility of different (monad transformer) libraries In-Reply-To: <250f340b1765fbf40cbc7de264d55434@xs4all.nl> References: <63c2e535e6a4e2f382c777103a37dc67@xs4all.nl> <250f340b1765fbf40cbc7de264d55434@xs4all.nl> Message-ID: <694519c50903161227l7c450c86n768fe7d039c37bd3@mail.gmail.com> On Mon, Mar 16, 2009 at 9:26 AM, Arie Peterson wrote: > > It is indeed unfortunate that mtl:State is a different type from > transformers:State, but that is not biting me right now. > If the type problem does ever become an issue, could the MTL use the types from the transformers package? Antoine From haskell at list.mightyreason.com Mon Mar 16 16:10:08 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Mon Mar 16 15:58:20 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <20090313172436.GH15913@whirlpool.galois.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <20090313172436.GH15913@whirlpool.galois.com> Message-ID: Don Stewart wrote: > tphyahoo: >> Is there something like subRegex... something like =~ s/.../.../ in >> perl... for haskell pcre Regexen? >> >> I mean, subRegex from Text.Regex of course: >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat >> >> Thanks for any advice, > > Basically, we should have it. Let me open the discussion with all the questions I can quickly ask: What should the "subRegex" function do, exactly? (Single replacement,global replacement,once per line,...) What should the replacement template be able to specify? (Can it refer to all text before a match or all text after?) (Can it access the start/stop offsets as numbers?) Should the replacement template be specified in a "String"? As an abstract data type or syntax tree? With combinators? What happens if the referenced capture was not made? Empty text? How will syntax errors in the template be handled (e.g. referring to a capture that does not exist in the regular expression)? Will the output text be String? ByteString? ByteString.Lazy? Seq Char? Note: String and Strict Bytestrings are poor with concatenation. Can the output text type differ from the input text type? -- Chris From lemming at henning-thielemann.de Mon Mar 16 16:50:40 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 16 16:38:58 2009 Subject: [Haskell-cafe] Polynomial and VectorSpace In-Reply-To: References: Message-ID: On Mon, 16 Mar 2009, Peter Verswyvelen wrote: > The DSP package on Hackage seems to contain complex polynomial functions. > It seems these functions are completely independent of the other DSP functions, so this > package could be split of? The matrix stuff is also independent. If you split off the polynomial stuff you might also adapt the identifiers to qualified style. > Also, polynomials form a vector space, so could be made an instance of VectorSpace class? Polynomial arithmetic is also contained in http://hackage.haskell.org/packages/archive/numeric-prelude/0.0.5/doc/html/MathObj-Polynomial.html http://darcs.haskell.org/htam/src/Polynomial.hs vector-space seems to be a tough dependency, since it relies on type families. NumericPrelude's VectorSpace class is a multi-parameter type class. From lemming at henning-thielemann.de Mon Mar 16 17:03:21 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 16 16:51:22 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> Message-ID: On Sun, 15 Mar 2009, Ryan Ingram wrote: > unsafeInterleaveIO allows embedding side effects into a pure > computation. This means you can potentially observe if some pure > value has been evaluated or not; the result of your code could change > depending how lazy/strict it is, which is very hard to predict! > > For example: > >> -- given >> f :: Integer -> Integer >> >> main = do >> r <- newIORef 0 >> v <- unsafeInterleaveIO $ do >> writeIORef r 1 >> return 1 >> x <- case f v of >> 0 -> return 0 >> n -> return (n - 1) >> y <- readIORef r >> print y >> >> -- a couple of examples: >> f x = 0 -- program prints "0" >> -- f x = x -- program prints "1" Interesting example. I have implemented the lazyio package. It asserts that unsafely interleaved IO actions are performed in order. This should prevent such problems, does it? However, they are only avoided within the LazyIO monad. Running the LazyIO monad in IO allows the same corruptions as shown above. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/lazyio From lemming at henning-thielemann.de Mon Mar 16 17:12:10 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 16 17:00:09 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> Message-ID: On Sun, 15 Mar 2009, Claus Reinke wrote: > import Data.IORef > import Control.Exception > > main = do > r <- newIORef 0 > let v = undefined > handle (\(ErrorCall _)->print "hi">>return 42) $ case f v of > 0 -> return 0 > n -> return (n - 1) > y <- readIORef r > print y I don't see what this has to do with strictness. It's just the hacky "exception handling" which allows to "catch" programming errors. From jonathanccast at fastmail.fm Mon Mar 16 17:17:54 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Mon Mar 16 17:05:54 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> Message-ID: <1237238274.6590.0.camel@jonathans-macbook> On Mon, 2009-03-16 at 22:12 +0100, Henning Thielemann wrote: > On Sun, 15 Mar 2009, Claus Reinke wrote: > > > import Data.IORef > > import Control.Exception > > > > main = do > > r <- newIORef 0 > > let v = undefined > > handle (\(ErrorCall _)->print "hi">>return 42) $ case f v of > > 0 -> return 0 > > n -> return (n - 1) > > y <- readIORef r > > print y > > I don't see what this has to do with strictness. It's just the hacky > "exception handling" which allows to "catch" programming errors. And which I have a sneaking suspicion actually *is* `unsafe'. Or, at least, incapable of being given a compositional, continuous semantics. jcc From duane.johnson at gmail.com Mon Mar 16 17:27:33 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Mon Mar 16 17:15:41 2009 Subject: [Haskell-cafe] darcs fundraising drive - THANK-YOU! In-Reply-To: <20090316120937.GL25922@brighton.ac.uk> References: <20090314104237.GA419@Macintosh.local> <20090316120937.GL25922@brighton.ac.uk> Message-ID: I'm just getting to know this community, and I have to say, I am very impressed by this. Congrats to everyone for making the world a better place :) -- Duane Johnson On Mar 16, 2009, at 6:09 AM, Eric Kow wrote: > Dear darcs users and Haskellers, > > I wanted to thank you all for your contributions to our first darcs > fundraising drive. We've done it! We managed to raise $1000, over > two > weeks with contributions from 22 donors. This means that we will able > to help our programmers travel to the darcs hacking sprint. > > This fundraising drive is over, but donations will still be gratefully > accepted. In the long term, we hope to raise another $5000 to pay > for a > summer project ($4000) and also to pay for travel (another $1000) to > the > third hacking sprint this October or November. > > Again, thank-you! > > -- > Eric Kow > PGP Key ID: 08AC04F9 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vandijk.roel at gmail.com Mon Mar 16 17:30:55 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Mar 16 17:18:55 2009 Subject: [Haskell-cafe] Polynomial and VectorSpace In-Reply-To: References: Message-ID: 2009/3/16 Peter Verswyvelen : > The DSP package on Hackage seems to contain complex polynomial functions. > It seems these functions are completely independent of the other DSP > functions, so this package could be split of? I would be interested in a separate package that deals with polynomials. I am working on a library that does various things with numerals and polynomials are a nice way to represent positional notation systems. Perhaps it would allow me to work with Knuth's quater-imaginary base :-) From vandijk.roel at gmail.com Mon Mar 16 17:45:28 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Mar 16 17:33:27 2009 Subject: [Haskell-cafe] Lambda-Cube 3D render engine In-Reply-To: <8914b92d0903161201q372af11dp892659c17ecad638@mail.gmail.com> References: <8914b92d0903161201q372af11dp892659c17ecad638@mail.gmail.com> Message-ID: 2009/3/16 Csaba Hruska : > Hi! > > I've created a wiki page for my project. > Currently only some text and screenshot are available. > Additional documentation and source code are coming soon.. :) > > http://www.haskell.org/haskellwiki/LambdaCubeEngine > > Cheers, > Csaba Hruska > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > This is really nice! I will be looking forward to the preview version. From bugfact at gmail.com Mon Mar 16 17:53:10 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Mar 16 17:41:09 2009 Subject: [Haskell-cafe] Lambda-Cube 3D render engine In-Reply-To: References: <8914b92d0903161201q372af11dp892659c17ecad638@mail.gmail.com> Message-ID: Oh yes, we will :-) On Mon, Mar 16, 2009 at 10:45 PM, Roel van Dijk wrote: > This is really nice! I will be looking forward to the preview version. > _______________________________________________ > 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/20090316/a046c8ee/attachment.htm From duncan.coutts at worc.ox.ac.uk Mon Mar 16 18:01:17 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Mar 16 17:49:29 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237238274.6590.0.camel@jonathans-macbook> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237238274.6590.0.camel@jonathans-macbook> Message-ID: <1237240877.22402.534.camel@localhost> On Mon, 2009-03-16 at 14:17 -0700, Jonathan Cast wrote: > On Mon, 2009-03-16 at 22:12 +0100, Henning Thielemann wrote: > > On Sun, 15 Mar 2009, Claus Reinke wrote: > > > > > import Data.IORef > > > import Control.Exception > > > > > > main = do > > > r <- newIORef 0 > > > let v = undefined > > > handle (\(ErrorCall _)->print "hi">>return 42) $ case f v of > > > 0 -> return 0 > > > n -> return (n - 1) > > > y <- readIORef r > > > print y > > > > I don't see what this has to do with strictness. It's just the hacky > > "exception handling" which allows to "catch" programming errors. > > And which I have a sneaking suspicion actually *is* `unsafe'. Or, at > least, incapable of being given a compositional, continuous semantics. See this paper: "A semantics for imprecise exceptions" http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm Basically if we can only catch exceptions in IO then it doesn't matter, it's just a little extra non-determinism and IO has plenty of that already. Duncan From bugfact at gmail.com Mon Mar 16 18:08:40 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Mar 16 17:56:39 2009 Subject: [Haskell-cafe] Polynomial and VectorSpace In-Reply-To: References: Message-ID: On Mon, Mar 16, 2009 at 9:50 PM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > Polynomial arithmetic is also contained in > > http://hackage.haskell.org/packages/archive/numeric-prelude/0.0.5/doc/html/MathObj-Polynomial.html > http://darcs.haskell.org/htam/src/Polynomial.hs Nice. But the above code doen't seem to contain functions to find (or approximate) all complex roots, which is the function I need (maybe with special cases for linear, quadratic, cubic, since these can be done analytically). The DSP package does, albeit only Laguerre's method, which might be good enough, although my old C# code that I wanted to port used Weierstrass method vector-space seems to be a > tough dependency, since it relies on type families. NumericPrelude's > VectorSpace class is a multi-parameter type class. NumericPrelude is very impressive, but it scares me a little, since it is so big :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090316/ef90cbb4/attachment.htm From csaba.hruska at gmail.com Mon Mar 16 18:12:52 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Mon Mar 16 18:00:55 2009 Subject: [Haskell-cafe] Lambda-Cube 3D render engine In-Reply-To: References: <8914b92d0903161201q372af11dp892659c17ecad638@mail.gmail.com> Message-ID: <8914b92d0903161512g12d54368v28683a14d8cb1664@mail.gmail.com> 2009/3/16 Duane Johnson > Looks great! > By any chance, is the mesh loading functionality separate from the texture > loading? > Yes, it is completly separated from material, it only refers to material's name. You can define the material writing a nice human readable script: http://www.ogre3d.org/docs/manual/manual_14.html#SEC23 > > -- Duane Johnson > > On Mar 16, 2009, at 1:01 PM, Csaba Hruska wrote: > > Hi! > > I've created a wiki page for my project. > Currently only some text and screenshot are available. > Additional documentation and source code are coming soon.. :) > > http://www.haskell.org/haskellwiki/LambdaCubeEngine > > Cheers, > Csaba Hruska > _______________________________________________ > 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/20090316/a81bfd44/attachment-0001.htm From jonathanccast at fastmail.fm Mon Mar 16 18:37:51 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Mon Mar 16 18:25:52 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237240877.22402.534.camel@localhost> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237238274.6590.0.camel@jonathans-macbook> <1237240877.22402.534.camel@localhost> Message-ID: <1237243071.6590.31.camel@jonathans-macbook> On Mon, 2009-03-16 at 22:01 +0000, Duncan Coutts wrote: > On Mon, 2009-03-16 at 14:17 -0700, Jonathan Cast wrote: > > On Mon, 2009-03-16 at 22:12 +0100, Henning Thielemann wrote: > > > On Sun, 15 Mar 2009, Claus Reinke wrote: > > > > > > > import Data.IORef > > > > import Control.Exception > > > > > > > > main = do > > > > r <- newIORef 0 > > > > let v = undefined > > > > handle (\(ErrorCall _)->print "hi">>return 42) $ case f v of > > > > 0 -> return 0 > > > > n -> return (n - 1) > > > > y <- readIORef r > > > > print y > > > > > > I don't see what this has to do with strictness. It's just the hacky > > > "exception handling" which allows to "catch" programming errors. > > > > And which I have a sneaking suspicion actually *is* `unsafe'. Or, at > > least, incapable of being given a compositional, continuous semantics. > > See this paper: > > "A semantics for imprecise exceptions" > http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm > > Basically if we can only catch exceptions in IO then it doesn't matter, > it's just a little extra non-determinism and IO has plenty of that > already. I'm not sure that helps much. Given the following inequalities (in the domain ordering) and equations: throw "urk! " <= 1 evaluate . throw = throwIO evaluate x = return x -- x total catch (throwIO a) h = h a catch (return x) h = return x we expect to be able to reason as follows: throw "urk"! <= return 1 ==> evaluate (throw "urk!") <= evaluate 1 ==> catch (evaluate (throw "urk!")) (const $ return 2) <= catch (evaluate 1) (const $ return 2) while catch (evaluate (throw "urk!")) (const $ return 2) = catch (throwIO "urk!") (const $ return 2) = const (return 2) "urk!" = return 2 and catch (evaluate 1) (const $ return 2) = catch (return 1) (const $ return 2) = return 1 So return 2 <= return 1, in the domain ordering? That doesn't seem right. jcc From manlio_perillo at libero.it Mon Mar 16 19:15:39 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Mar 16 19:03:42 2009 Subject: [Haskell-cafe] random shuffle and random list partition Message-ID: <49BEDD9B.5020304@libero.it> Hi. For my Netflix Prize project I have implemented two reusable modules. The first module implements a random shuffle on immutable lists. It uses http://okmij.org/ftp/Haskell/perfect-shuffle.txt, with an additional "wrapper" function, having a more friendly interface. The second module implements a function used to partition a list into n sublists of random length. I have pasted the modules here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2483 http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2485 If someone is interested (and if Oleg give me permission), I can release them as a package on Hackage. I need to improve documentation, however. In future I can add an implementation of the random shuffle algorithm on mutable arrays in the ST monad. Manlio From trentbuck at gmail.com Mon Mar 16 20:36:44 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Mon Mar 16 20:28:01 2009 Subject: [Haskell-cafe] Re: darcs fundraising drive - THANK-YOU! References: <20090314104237.GA419@Macintosh.local> <20090316120937.GL25922@brighton.ac.uk> Message-ID: <30r60x9e8z.fsf@Clio.twb.ath.cx> Eric Kow writes: > We hope to raise another $5000 to pay for a summer project ($4000) Nitpick: "summer" is hemispherist. -- Trent W. Buck, Pedant From mvanier42 at gmail.com Mon Mar 16 20:48:45 2009 From: mvanier42 at gmail.com (Michael Vanier) Date: Mon Mar 16 20:36:49 2009 Subject: [Haskell-cafe] using Typeable with STRefs Message-ID: <49BEF36D.2000504@cs.caltech.edu> Hi, I'm having a problem using Typeable with STRefs. Basically, I want to store STRefs (among other things) in a universal type. STRef is an instance of Typeable2, which means that STRef s a is Typeable if s and a are both Typeable. The problem is that the state type s is opaque and I can see no way to make it Typeable (other than making it RealWorld, and I don't want to use IO for this). If this is the case, then AFAICT there is no point in having STRefs be instances of Typeable2. Am I missing something? Here's the code I'd like to write: import Data.Typeable import Data.STRef import Control.Monad.ST data Value = forall a . Typeable a => V a deriving Typeable getValue :: Typeable a => Value -> Maybe a getValue (V v) = cast v -- I need the Typeable s constraint for the code to compile, but I'd rather leave it out. test :: Typeable s => ST s Integer test = do ref <- newSTRef (10 :: Integer) let refVal = V ref case getValue refVal of Nothing -> error "BAD" Just r -> readSTRef r -- This doesn't compile, because s is not Typeable. test2 :: Integer test2 = runST test Thanks in advance, Mike From ryani.spam at gmail.com Mon Mar 16 20:58:28 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Mar 16 20:46:26 2009 Subject: [Haskell-cafe] using Typeable with STRefs In-Reply-To: <49BEF36D.2000504@cs.caltech.edu> References: <49BEF36D.2000504@cs.caltech.edu> Message-ID: <2f9b2d30903161758w66563219k278b5ec74b0823a3@mail.gmail.com> Having the state be an instance of Typeable breaks the purity guarantees of runST; a reference could escape runST: let v = runST (V `liftM` newSTRef 0) in runST (readSTRef $ fromJust $ getValue v) Keep in mind that the state actually used by runST is "RealWorld"; runST is just a pretty name for unsafePerformIO. So the state types are actually the same, and the cast would succeed. -- ryan On Mon, Mar 16, 2009 at 5:48 PM, Michael Vanier wrote: > Hi, > > I'm having a problem using Typeable with STRefs. ?Basically, I want to store > STRefs (among other things) in a universal type. ?STRef is an instance of > Typeable2, which means that STRef s a is Typeable if s and a are both > Typeable. ?The problem is that the state type s is opaque and I can see no > way to make it Typeable (other than making it RealWorld, and I don't want to > use IO for this). ?If this is the case, then AFAICT there is no point in > having STRefs be instances of Typeable2. ?Am I missing something? > > Here's the code I'd like to write: > > import Data.Typeable > import Data.STRef > import Control.Monad.ST > > data Value = forall a . Typeable a => V a > ?deriving Typeable > > getValue :: Typeable a => Value -> Maybe a > getValue (V v) = cast v > > -- I need the Typeable s constraint for the code to compile, but I'd rather > leave it out. > test :: Typeable s => ST s Integer > test = do ref <- newSTRef (10 :: Integer) > ? ? ? ? let refVal = V ref > ? ? ? ? case getValue refVal of > ? ? ? ? ? Nothing -> error "BAD" > ? ? ? ? ? Just r -> readSTRef r > > -- This doesn't compile, because s is not Typeable. ? ? ? test2 :: Integer > test2 = runST test > > Thanks in advance, > > Mike > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mvanier42 at gmail.com Mon Mar 16 21:08:35 2009 From: mvanier42 at gmail.com (Michael Vanier) Date: Mon Mar 16 20:56:39 2009 Subject: [Haskell-cafe] using Typeable with STRefs In-Reply-To: <2f9b2d30903161758w66563219k278b5ec74b0823a3@mail.gmail.com> References: <49BEF36D.2000504@cs.caltech.edu> <2f9b2d30903161758w66563219k278b5ec74b0823a3@mail.gmail.com> Message-ID: <49BEF813.3080306@cs.caltech.edu> Ryan, So, if I understand you correctly, my only option is to use an IORef instead of an STRef? What I'm trying to do is implement a mutable box type as part of a dynamically-typed language I'm implementing in Haskell (which is mainly an exercise to improve my Haskell programming; mission accomplished). It bothers me that I have to use an IORef for this, since I don't see what this has to do with I/O. Similarly, if I wanted to have a mutable array type, I couldn't use STArray; I'd have to use IOArray. Or, I suppose I could define a richer Value type that had extra constructors for stateful types. Mike Ryan Ingram wrote: > Having the state be an instance of Typeable breaks the purity > guarantees of runST; a reference could escape runST: > > let v = runST (V `liftM` newSTRef 0) > in runST (readSTRef $ fromJust $ getValue v) > > Keep in mind that the state actually used by runST is "RealWorld"; > runST is just a pretty name for unsafePerformIO. So the state types > are actually the same, and the cast would succeed. > > -- ryan > > On Mon, Mar 16, 2009 at 5:48 PM, Michael Vanier wrote: > >> Hi, >> >> I'm having a problem using Typeable with STRefs. Basically, I want to store >> STRefs (among other things) in a universal type. STRef is an instance of >> Typeable2, which means that STRef s a is Typeable if s and a are both >> Typeable. The problem is that the state type s is opaque and I can see no >> way to make it Typeable (other than making it RealWorld, and I don't want to >> use IO for this). If this is the case, then AFAICT there is no point in >> having STRefs be instances of Typeable2. Am I missing something? >> >> Here's the code I'd like to write: >> >> import Data.Typeable >> import Data.STRef >> import Control.Monad.ST >> >> data Value = forall a . Typeable a => V a >> deriving Typeable >> >> getValue :: Typeable a => Value -> Maybe a >> getValue (V v) = cast v >> >> -- I need the Typeable s constraint for the code to compile, but I'd rather >> leave it out. >> test :: Typeable s => ST s Integer >> test = do ref <- newSTRef (10 :: Integer) >> let refVal = V ref >> case getValue refVal of >> Nothing -> error "BAD" >> Just r -> readSTRef r >> >> -- This doesn't compile, because s is not Typeable. test2 :: Integer >> test2 = runST test >> >> Thanks in advance, >> >> Mike >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> From claus.reinke at talk21.com Mon Mar 16 21:16:26 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Mar 16 21:04:30 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com><1237238274.6590.0.camel@jonathans-macbook><1237240877.22402.534.camel@localhost> <1237243071.6590.31.camel@jonathans-macbook> Message-ID: <035453A1C6AE4CA591408A9F14BBB840@cr3lt> >> > > "exception handling" which allows to "catch" programming errors. >> > And which I have a sneaking suspicion actually *is* `unsafe'. Or, at >> > least, incapable of being given a compositional, continuous semantics. >> "A semantics for imprecise exceptions" >> http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm >> Basically if we can only catch exceptions in IO then it doesn't matter, >> it's just a little extra non-determinism and IO has plenty of that >> already. > > I'm not sure that helps much. Given the following inequalities (in the > domain ordering) and equations: > throw "urk"! <= return 1 > ==> evaluate (throw "urk!") <= evaluate 1 throw (ErrorCall "urk") <= evaluate (throw (ErrorCall "urk")) as demonstrated here *Main> throw (ErrorCall "urk") `seq` () *** Exception: urk *Main> evaluate (throw (ErrorCall "urk")) `seq` () () So that first step already relies on IO (where the two are equivalent). This is very delicate territory. For instance, one might think that this 'f' seems to define a "negation function" of information content f x = Control.Exception.catch (evaluate x >> let x = x in x) (\(ErrorCall _)->return 0) >>= print and hence violates monotonicity (_|_ <= ()) => (f _|_ <= f ()) since *Main> f undefined 0 *Main> f () Interrupted. But that is really mixing context-free expression evaluation and context-sensitive execution of io operations. Most of our favourite context-free equivalences only hold within the expression evaluation part, while IO operations are subject to additional, context-sensitive rules. For instance, without execution *Main> f () `seq` () () *Main> f undefined `seq` () () but if we include execution (and the context-sensitive equivalence that implies, lets call it ~), we have f () ~ _|_ <= return 0 ~ f _|_ so 'f' shows that wrapping both sides of an inequality in 'catch' need not preserve the ordering (modulo ~) - its whole purpose is to recover from failure, making something more defined (modulo ~) by translating _|_ to something else. Which affects your second implication. If the odd properties of 'f' capture the essence of your concerns, I think the answer is to keep =, <=, and ~ clearly separate, ideally without losing any of the context-free equivalences while limiting the amount of context-sensitive reasoning required. If = and ~ are mixed up, however, monotonicity seems lost. The semantics in the "imprecise exceptions" paper combines a denotational approach for the context-free part with an operational semantics for the context-sensitive part. This tends to use the good properties of both, with a clear separation between them, but a systematic treatment of the resulting identities was left for future work. Claus From aslatter at gmail.com Mon Mar 16 22:02:18 2009 From: aslatter at gmail.com (Antoine Latter) Date: Mon Mar 16 21:50:15 2009 Subject: [Haskell-cafe] using Typeable with STRefs In-Reply-To: <49BEF813.3080306@cs.caltech.edu> References: <49BEF36D.2000504@cs.caltech.edu> <2f9b2d30903161758w66563219k278b5ec74b0823a3@mail.gmail.com> <49BEF813.3080306@cs.caltech.edu> Message-ID: <694519c50903161902g46b585ecpfd9d019f9cd2a9cc@mail.gmail.com> On Mon, Mar 16, 2009 at 8:08 PM, Michael Vanier wrote: > Ryan, > > So, if I understand you correctly, my only option is to use an IORef instead > of an STRef? ?What I'm trying to do is implement a mutable box type as part > of a dynamically-typed language I'm implementing in Haskell (which is mainly > an exercise to improve my Haskell programming; mission accomplished). ?It > bothers me that I have to use an IORef for this, since I don't see what this > has to do with I/O. ?Similarly, if I wanted to have a mutable array type, I > couldn't use STArray; I'd have to use IOArray. ?Or, I suppose I could define > a richer Value type that had extra constructors for stateful types. > Why not: data Value = forall a . Typeable a => V a type STValue s = STRef Value Then you have a dynamic, mutable box. Also, even if the language you're interpretting is dynamicaly typed, it doesn't mean that you need to use Haskell Dynamics. It should be enough to do something like: data Value = VInt Integer | VStr String | VChar Char and then: -- | Similar to Prelude.Head primOpHead :: Value -> Value primOpHead (VStr xs) = VChar $ head xs primOpHead _ = error "Type Mismatch!" I'm sure other people can point you to much better ways to do this - the point is that you don't need Dynamics to implement a dynamic language. Antoine From aslatter at gmail.com Mon Mar 16 22:03:05 2009 From: aslatter at gmail.com (Antoine Latter) Date: Mon Mar 16 21:51:03 2009 Subject: [Haskell-cafe] using Typeable with STRefs In-Reply-To: <694519c50903161902g46b585ecpfd9d019f9cd2a9cc@mail.gmail.com> References: <49BEF36D.2000504@cs.caltech.edu> <2f9b2d30903161758w66563219k278b5ec74b0823a3@mail.gmail.com> <49BEF813.3080306@cs.caltech.edu> <694519c50903161902g46b585ecpfd9d019f9cd2a9cc@mail.gmail.com> Message-ID: <694519c50903161903p135a3453w9668b5785358e3e5@mail.gmail.com> > > Why not: > > data Value = forall a . Typeable a => V a > > type STValue s = STRef Value > This should be: type STValue s = STRef s Value Antoine From jonathanccast at fastmail.fm Mon Mar 16 22:13:36 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Mon Mar 16 22:01:36 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <035453A1C6AE4CA591408A9F14BBB840@cr3lt> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237238274.6590.0.camel@jonathans-macbook> <1237240877.22402.534.camel@localhost> <1237243071.6590.31.camel@jonathans-macbook> <035453A1C6AE4CA591408A9F14BBB840@cr3lt> Message-ID: <1237256016.6590.57.camel@jonathans-macbook> On Tue, 2009-03-17 at 01:16 +0000, Claus Reinke wrote: > >> > > "exception handling" which allows to "catch" programming errors. > >> > And which I have a sneaking suspicion actually *is* `unsafe'. Or, at > >> > least, incapable of being given a compositional, continuous semantics. > >> "A semantics for imprecise exceptions" > >> http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm > >> Basically if we can only catch exceptions in IO then it doesn't matter, > >> it's just a little extra non-determinism and IO has plenty of that > >> already. > > > > I'm not sure that helps much. Given the following inequalities (in the > > domain ordering) and equations: > > throw "urk"! <= return 1 Oops, left a superfluous return in there. I meant throw "urk!" <= 1 (The inequality is at Int). > > ==> evaluate (throw "urk!") <= evaluate 1 > > throw (ErrorCall "urk") <= evaluate (throw (ErrorCall "urk")) Sure enough. But throwIO (ErrorCall "urk") /= _|_: Control.Exception> throwIO (ErrorCall "urk!") `seq` () () > So that first step already relies on IO (where the two are equivalent). Come again? > This is very delicate territory. For instance, one might think that > this 'f' seems to define a "negation function" of information content > f x = Control.Exception.catch (evaluate x >> let x = x in x) (\(ErrorCall _)->return 0) >>= > print > > and hence violates monotonicity > > (_|_ <= ()) => (f _|_ <= f ()) > > since > > *Main> f undefined > 0 > *Main> f () > Interrupted. > > But that is really mixing context-free expression evaluation and > context-sensitive execution of io operations. Most of our favourite > context-free equivalences only hold within the expression evaluation > part, while IO operations are subject to additional, context-sensitive > rules. Could you elaborate on this? It sounds suspiciously like you're saying Haskell's axiomatic semantics is unsound :: IO. > For instance, without execution > > *Main> f () `seq` () > () > *Main> f undefined `seq` () > () > > but if we include execution (and the context-sensitive equivalence > that implies, lets call it ~), So a ~ b = `The observable effects of $(x) and $(y) are equal' ? > we have > > f () ~ _|_ <= return 0 ~ f _|_ > > so 'f' shows that wrapping both sides of an inequality in 'catch' need > not preserve the ordering (modulo ~) If f _|_ <= f (), then it seems that (<=) is not a (pre-) order w.r.t. (~). So taking the quotient of IO Int over (~) gives you a set on which (<=) is not an ordering (and may not be a relation). > - its whole purpose is to recover > from failure, making something more defined (modulo ~) by translating > _|_ to something else. Which affects your second implication. > If the odd properties of 'f' capture the essence of your concerns, I think > the answer is to keep =, <=, and ~ clearly separate, ideally without losing > any of the context-free equivalences while limiting the amount of > context-sensitive reasoning required. If = and ~ are mixed up, however, > monotonicity seems lost. So catch (throwIO e) h ~ h e but it is not the case that catch (throwIO e) h = h e ? That must be correct, actually: Control.Exception> let x = Control.Exception.catch (throwIO (ErrorCall "urk!")) (\ (ErrorCall _) -> undefined) in x `seq` () () So catch is total (even if one or both arguments is erroneous), but the IO executor (a beast totally distinct from the Haskell interpreter, even if they happen to live in the same body) when executing it feels free to examine bits of the Haskell program's state it's not safe for a normal program to inspect. I'll have to think about what that means a bit more. > The semantics in the "imprecise exceptions" paper combines a > denotational approach for the context-free part with an operational > semantics [Totally OT tangent: How did operational semantics come to get its noun? The more I think about it, the more it seems like a prec?s of the implementation, rather than a truly semantic part of a language specification.] > for the context-sensitive part. This tends to use the good > properties of both, with a clear separation between them, but a > systematic treatment of the resulting identities was left for future work. jcc From lemming at henning-thielemann.de Mon Mar 16 22:19:52 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Mar 16 22:07:54 2009 Subject: [Haskell-cafe] Polynomial and VectorSpace In-Reply-To: <6353A9D7-4522-4AC2-A83A-3623BA524659@mxd120.com> References: <6353A9D7-4522-4AC2-A83A-3623BA524659@mxd120.com> Message-ID: On Mon, 16 Mar 2009, Matthew Donadio wrote: > Thy polynomial and matrix libraries weren't really developed to be stand > alone libraries. I was developing some DSP libraries that required > polynomial and matrix math, so I implemented what I needed so I could test > the DSP. Both libraries work for lower orders, but I suspect they are buggy > with big inputs. My long term goal was to interface with LAPACK and/or GSL > for the numeric heavy lifting, but that never happened. > > The same goes for the FFT library. That was written in support of the DSP > libraries, and also as a learning exercise for me (to better understand > how/why the FFT works). FFTW was the long term goal. In the meantime fftw and gsl-matrix interfaces exist on Hackage. From wren at freegeek.org Tue Mar 17 00:09:37 2009 From: wren at freegeek.org (wren ng thornton) Date: Mon Mar 16 23:57:38 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <20090316015640.26yrr8ce8wc0k404-nwo@webmail.spamcop.net> References: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> <49BC8960.5020608@freegeek.org> <20090316015640.26yrr8ce8wc0k404-nwo@webmail.spamcop.net> Message-ID: <49BF2281.3040502@freegeek.org> ajb@spamcop.net wrote: > G'day all. > > Quoting wren ng thornton : > > > Most of the (particular) problems OO design patterns solve are > > non-issues in Haskell because the language is more expressive. > > ...and vice versa. Some of the "design patterns" that we use in > Haskell, for example, are to overcome the fact that Haskell doesn't > have mutable global state. Oh sure. However, in my experience the most common design patterns of OO are the ones obviated in functional languages. And I haven't tended to need any of the global mutation patterns in Haskell[1]. Not an objective analysis by any means, but I do think it holds more water than it leaks. The whole genre of SYB papers indicates that there's no panacea. [1] The two times I've needed global mutation, one is for arbitrary unique symbol generation (uses a library), and the other is for doing some very tricky memoization with self-compaction when memory is low. The latter I'd think is certainly too special-purpose to be considered a "pattern". > > A number of other patterns can > > actually be written down once and for all (in higher-order functions > > like foldr, map,...) instead of needing repetition. > > This is also true in many OO languages. A lot of the GoF book, for > example, can be implemented as libraries in Ada or C++. I think this depends very much on the specific language in question. For dynamic OO languages with lambdas (Smalltalk, Ruby, Python, Perl) it's easy, but then it's basically the same thing. For languages with a way of doing mixins (the aforementioned, C++) it's also pretty easy. But for languages like Java, oftentimes it's a choice between impossible and grossly inefficient. I've been dealing with a lot of Java lately. Certainly it's _possible_ to do in any language (Turing tarpit et al.), but the question is one of how much boilerplate is involved and how efficient it is. I think the latter point is important not only for the projects I've worked on, but also for how widely adopted any given pattern becomes; many people are fastidious about performance. The former is also important to whether it gets spread as a "pattern" or whether it gets packaged up in a library somewhere. > > And then there are some things like monoids which fall somewhere > > between idiom and pearl. > > "Things like monoids" are constructions from algebra. > > Abstract algebra and design patterns have a lot in common. They're > based on the same idea, in fact: When a pattern keeps showing up, > define it and give it a name so you can talk about it independently > of any specific implementation. > > Or to put it another way, category theory is the pattern language of > mathematics. Indeed. Though, IMO, there's a distinction between fairly banal things (e.g. monoids), and the other more interesting bits of category theory and abstract algebra. Monoids often occur by happenstance and so their triviality lends to being more like an idiom. Similarly, functors also tend to just happen. However, once you start getting into applicative functors, natural transformations, and the like, you've made a step from incidentally using a ubiquitous pattern of mathematics, to making a concerted effort at abstraction. -- Live well, ~wren From bjpop at csse.unimelb.edu.au Tue Mar 17 02:39:31 2009 From: bjpop at csse.unimelb.edu.au (Bernie Pope) Date: Tue Mar 17 02:27:42 2009 Subject: Operational semantics. Was: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237256016.6590.57.camel@jonathans-macbook> References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237238274.6590.0.camel@jonathans-macbook> <1237240877.22402.534.camel@localhost> <1237243071.6590.31.camel@jonathans-macbook> <035453A1C6AE4CA591408A9F14BBB840@cr3lt> <1237256016.6590.57.camel@jonathans-macbook> Message-ID: On 17/03/2009, at 1:13 PM, Jonathan Cast wrote: > [Totally OT tangent: How did operational semantics come to get its > noun? > The more I think about it, the more it seems like a prec?s of the > implementation, rather than a truly semantic part of a language > specification.] I haven't followed the whole thread, so perhaps I'm missing some important context to this question. It is true that operational semantics are often used to summarise or explain an _implementation_ of a language feature, but I wouldn't say that they are always used in this way. An operational semantics may be used to define a "behaviour" function: (program x input) -> outcome. The big-step style of operational semantics style tends to be less like an implementation, and more like a specification. Perhaps the more crucial part of operational semantics is that it just deals with syntactic terms as its "values". Apologies if this has nothing to do with your question. Cheers, Bernie. From frodo at theshire.org Tue Mar 17 03:13:53 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Mar 17 03:01:50 2009 Subject: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen? In-Reply-To: <49B9A674.4020708@list.mightyreason.com> References: <910ddf450903121617w76d2f71bxa03de8eb846ee20@mail.gmail.com> <49B9A674.4020708@list.mightyreason.com> Message-ID: On Fri, Mar 13, 2009 at 1:19 AM, ChrisK wrote: > .... > At the cost of writing your own routine you get exactly what you want in a > screen or less of code, see > http://hackage.haskell.org/packages/archive/regex-compat/0.92/doc/html/src/Text-Regex.html#subRegex > for "subRegex" which is 30 lines of code. WTF! Cristiano From valheru at chariot.net.au Tue Mar 17 03:49:50 2009 From: valheru at chariot.net.au (Mark Spezzano) Date: Tue Mar 17 03:37:47 2009 Subject: [Haskell-cafe] Haskell, OpenGL on Windows Message-ID: <68a099de-999a-49e6-b168-89ebe87f510c@v1g2000prd.googlegroups.com> Hi, Can someone PLEASE help me to understand exactly how to configure OpenGL on Window using Haskell. I'm using Eclipse IDE. When I try to run the file Test1.hs in GHCi then I get the following error: Loading package syb ... linking ... done. Loading package base-3.0.3.0 ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.0 ... linking ... done. Loading package OpenGL-2.2.1.1 ... can't load .so/.DLL for: GL (addDLL: could not load DLL) Prelude Main> I've copied the GLUT dll into Windows/System32. Is there some flag or option that I need to enable to tell Haskell where to go to link in the library. What do I do with the other .h and .lib files from GLUT? Thanks Mark From artyom.shalkhakov at gmail.com Tue Mar 17 03:53:53 2009 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Tue Mar 17 03:41:53 2009 Subject: [Haskell-cafe] Haskell, OpenGL on Windows In-Reply-To: <68a099de-999a-49e6-b168-89ebe87f510c@v1g2000prd.googlegroups.com> References: <68a099de-999a-49e6-b168-89ebe87f510c@v1g2000prd.googlegroups.com> Message-ID: Hello Mark, Mark Spezzano ?????(?) ? ????? ?????? Tue, 17 Mar 2009 13:49:50 +0600: > Can someone PLEASE help me to understand exactly how to configure > OpenGL on Window using Haskell. I'm using Eclipse IDE. > > When I try to run the file Test1.hs in GHCi then I get the following > error: > Loading package syb ... linking ... done. > Loading package base-3.0.3.0 ... linking ... done. > Loading package array-0.2.0.0 ... linking ... done. > Loading package containers-0.2.0.0 ... linking ... done. > Loading package OpenGL-2.2.1.1 ... can't load .so/.DLL for: GL > (addDLL: could not load DLL) > Prelude Main> Have you tried running GHCi with the -v flag? > I've copied the GLUT dll into Windows/System32. I think it's better to leave GLUT dll in your application directory, next to the executable. -- Cheers, Artyom Shalkhakov From g9ks157k at acme.softbase.org Tue Mar 17 05:34:11 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue Mar 17 05:22:22 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <49BF2281.3040502@freegeek.org> References: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> <20090316015640.26yrr8ce8wc0k404-nwo@webmail.spamcop.net> <49BF2281.3040502@freegeek.org> Message-ID: <200903171034.11392.g9ks157k@acme.softbase.org> Am Dienstag, 17. M?rz 2009 05:09 schrieb wren ng thornton: > ajb@spamcop.net wrote: > > Or to put it another way, category theory is the pattern language of > > mathematics. > > Indeed. Though, IMO, there's a distinction between fairly banal things > (e.g. monoids), Monoids aren?t a concept of category theory. There are a generalization of groups. So they more belong to group theory. By the way, the documentation of Control.Category says that a category is a monoid (as far as I remember). This is wrong. Category laws correspond to monoid laws but monoid composition is total while category composition has the restriction that the domain of the first argument must match the codomain of the second. Best wishes, Wolfgang From colin at colina.demon.co.uk Tue Mar 17 05:54:59 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Mar 17 05:43:02 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <200903171034.11392.g9ks157k@acme.softbase.org> (Wolfgang Jeltsch's message of "Tue\, 17 Mar 2009 10\:34\:11 +0100") References: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> <20090316015640.26yrr8ce8wc0k404-nwo@webmail.spamcop.net> <49BF2281.3040502@freegeek.org> <200903171034.11392.g9ks157k@acme.softbase.org> Message-ID: >>>>> "Wolfgang" == Wolfgang Jeltsch writes: Wolfgang> By the way, the documentation of Control.Category says Wolfgang> that a category is a monoid (as far as I remember). This Wolfgang> is wrong. Category laws correspond to monoid laws but Wolfgang> monoid composition is total while category composition Wolfgang> has the restriction that the domain of the first Wolfgang> argument must match the codomain of the second. I'm reading the Barr/Wells slides at the moment, and they say the following: "Thus a category can be regarded as a generalized monoid, or a 'monoid with many objects'" -- Colin Adams Preston Lancashire From bugfact at gmail.com Tue Mar 17 06:01:52 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Mar 17 05:49:51 2009 Subject: [Haskell-cafe] GHC Core - technical document Message-ID: Does an up-to-date technical document exist describing GHC Core? Google found http://www.haskell.org/ghc/docs/papers/core.ps.gz I'm not sure this document reflects the current state of art. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090317/04d29734/attachment.htm From martijn at van.steenbergen.nl Tue Mar 17 06:39:05 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Tue Mar 17 06:27:03 2009 Subject: [Haskell-cafe] Type equality proof Message-ID: <49BF7DC9.9030004@van.steenbergen.nl> Ol? caf?, With the recent generic programming work and influences from type-dependent languages such as Agda, the following data type seems to come up often: > data (a :=: a') where > Refl :: a :=: a Everyone who needs it writes their own version; I'd like to compile a package with this data type and related utilities, if such a package doesn't exist already (I couldn't find one). Below is what I have so far; I'd much appreciate it if you added your ideas of what else the package should contain. > {-# LANGUAGE GADTs #-} > {-# LANGUAGE TypeOperators #-} > > module Eq where > > data (a :=: a') where > Refl :: a :=: a > > class Eq1 f where > eq1 :: f a -> f a' -> Maybe (a :=: a') > > class Eq2 f where > eq2 :: f a b -> f a' b' -> Maybe (a :=: a', b :=: b') > > class Eq3 f where > eq3 :: f a b c -> f a' b' c' -> Maybe (a :=: a', b :=: b', c :=: c') Thank you, Martijn. From miguelimo38 at yandex.ru Tue Mar 17 06:49:14 2009 From: miguelimo38 at yandex.ru (Yandex) Date: Tue Mar 17 06:37:19 2009 Subject: [Haskell-cafe] Type equality proof In-Reply-To: <49BF7DC9.9030004@van.steenbergen.nl> References: <49BF7DC9.9030004@van.steenbergen.nl> Message-ID: <49BF802A.7080408@yandex.ru> data (a :=: a') where Refl :: a :=: a Comm :: (a :=: a') -> (a' :=: a) Trans :: (a :=: a') -> (a' :=: a'') -> (a :=: a'') Martijn van Steenbergen wrote: > Ol? caf?, > > With the recent generic programming work and influences from > type-dependent languages such as Agda, the following data type seems > to come up often: > >> data (a :=: a') where >> Refl :: a :=: a > > Everyone who needs it writes their own version; I'd like to compile a > package with this data type and related utilities, if such a package > doesn't exist already (I couldn't find one). Below is what I have so > far; I'd much appreciate it if you added your ideas of what else the > package should contain. > >> {-# LANGUAGE GADTs #-} >> {-# LANGUAGE TypeOperators #-} >> >> module Eq where >> >> data (a :=: a') where >> Refl :: a :=: a >> >> class Eq1 f where >> eq1 :: f a -> f a' -> Maybe (a :=: a') >> >> class Eq2 f where >> eq2 :: f a b -> f a' b' -> Maybe (a :=: a', b :=: b') >> >> class Eq3 f where >> eq3 :: f a b c -> f a' b' c' -> Maybe (a :=: a', b :=: b', c :=: c') > > Thank you, > > Martijn. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From v.dijk.bas at gmail.com Tue Mar 17 06:57:07 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Tue Mar 17 06:45:04 2009 Subject: [Haskell-cafe] GHC Core - technical document In-Reply-To: References: Message-ID: 2009/3/17 Peter Verswyvelen : > Does an up-to-date technical document exist describing GHC Core? It's not really a paper, but the GHC developer wiki contains some useful info about GHC core: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType regards, Bas From gale at sefer.org Tue Mar 17 07:00:14 2009 From: gale at sefer.org (Yitzchak Gale) Date: Tue Mar 17 06:48:11 2009 Subject: [Haskell-cafe] random shuffle and random list partition In-Reply-To: <49BEDD9B.5020304@libero.it> References: <49BEDD9B.5020304@libero.it> Message-ID: <2608b8a80903170400r33382fafucd4d0cdf492d3eba@mail.gmail.com> Hi Manlio, Manlio Perillo wrote: > For my Netflix Prize project I have implemented two reusable modules. > The first module implements a random shuffle on immutable lists... > The second module implements a function used to partition a list into n > sublists of random length. Very nice! > If someone is interested (and if Oleg give me permission), I can release > them as a package on Hackage. Please do that. While I think Oleg's tree method is beautiful, in practice it may be re-inventing the wheel. I haven't tested it, but I doubt that this implementation is much better than using the classical shuffle algorithm on an IntMap. It's essentially the same tree inside. That's what I usually use for this, and it works fine. > In future I can add an implementation of the random > shuffle algorithm on mutable arrays in the ST monad. I've tried that in the past. Surprisingly, it wasn't faster than using trees. Perhaps I did something wrong. Or perhaps the difference only becomes apparent for huge lists. As you point out, your partition algorithm is not fair. Using your Random.Shuffle and a well-know trick from combinatorics, you can easily get a fair partitions function: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2485#a2495 Regards, Yitz From ketil at malde.org Tue Mar 17 07:59:17 2009 From: ketil at malde.org (Ketil Malde) Date: Tue Mar 17 07:46:30 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe In-Reply-To: <1237240877.22402.534.camel@localhost> (Duncan Coutts's message of "Mon\, 16 Mar 2009 22\:01\:17 +0000") References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com> <1237238274.6590.0.camel@jonathans-macbook> <1237240877.22402.534.camel@localhost> Message-ID: <873adc9x7u.fsf@malde.org> Duncan Coutts writes: >> [..] I have a sneaking suspicion [exceptions] actually *is* `unsafe'. Or, at >> least, incapable of being given a compositional, continuous semantics. > Basically if we can only catch exceptions in IO then it doesn't matter, > it's just a little extra non-determinism and IO has plenty of that > already. Couldn't you just substitute "catch exceptions" with "unsafePerformIO" here, and make the same argument? Similarly, can't you emulate unsafePerformIO with concurrency? Further, couldn't you, from IO, FFI into a function that examines the source code of some pure function, thus being able to differentiate funcitions that are normally "indistinguishable"? I've tried to follow this discussion, but I don't quite understand what's so bad about unsafeInterleaveIO - or rather, what's so uniquely bad about it. It seems the same issues can be found in every corner of IO. -k -- If I haven't seen further, it is by standing in the footprints of giants From g9ks157k at acme.softbase.org Tue Mar 17 08:06:10 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue Mar 17 07:54:08 2009 Subject: categories and monoids (was: Re: [Haskell-cafe] Design Patterns by Gamma or equivalent) In-Reply-To: References: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> <200903171034.11392.g9ks157k@acme.softbase.org> Message-ID: <200903171306.10237.g9ks157k@acme.softbase.org> Am Dienstag, 17. M?rz 2009 10:54 schrieben Sie: > Wolfgang Jeltsch writes: > > By the way, the documentation of Control.Category says that a category is > > a monoid (as far as I remember). This is wrong. Category laws correspond > > to monoid laws but monoid composition is total while category composition > > has the restriction that the domain of the first argument must match the > > codomain of the second. > > I'm reading the Barr/Wells slides at the moment, and they say the > following: > > "Thus a category can be regarded as a generalized monoid, What is a ?generalized monoid?? According to the grammatical construction (adjective plus noun), it should be a special kind of monoid, like a commutative monoid is a special kind of monoid. But then, monoids would be the more general concept and categories the special case, quite the opposite of how it really is. A category is not a ?generalized monoid? but categories (as a concept) are a generalization of monoids. Each category is a monoid, but not the other way round. A monoid is clearly defined as a pair of a set M and a (total) binary operation over M that is associative and has a neutral element. So, for example, the category of sets and functions is not a monoid. First, function composition is not total if you allow arbitrary functions as its arguments. Second, the collection of all sets is not itself a set (but a true class) which conflicts with the above definition which says that M has to be a set. > or a 'monoid with many objects'" What is a monoid with many objects? Best wishes, Wolfgang From mark.spezzano at chariot.net.au Tue Mar 17 08:07:38 2009 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Tue Mar 17 07:55:44 2009 Subject: [Haskell-cafe] DLL Hell: OpenGL Message-ID: <001101c9a6f8$f879c580$e96d5080$@spezzano@chariot.net.au> Hi all, I’m trying to make the Teapot OpenGL example in Haskell on Windows. It keeps coming up with this: C:\Users\Mark\workspace2\OpenGLPractice\src>ghc --make Teapot Linking Teapot.exe ... C:\ghc\ghc-6.10.1\gcc-lib\ld.exe: cannot find -lSM collect2: ld returned 1 exit status As far as I know, -lSM is to do with XWindows (not windows Vista).How do I fix this ? What’s going on? I’ve been on this problem now for hours, and all I wanted to do was get a window up on the screen. Sigh Mark Spezzano No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.15/2004 - Release Date: 16/03/2009 7:04 AM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090317/b648284b/attachment.htm From g9ks157k at acme.softbase.org Tue Mar 17 08:14:15 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue Mar 17 08:02:12 2009 Subject: [Haskell-cafe] Type equality proof In-Reply-To: <49BF802A.7080408@yandex.ru> References: <49BF7DC9.9030004@van.steenbergen.nl> <49BF802A.7080408@yandex.ru> Message-ID: <200903171314.15362.g9ks157k@acme.softbase.org> Am Dienstag, 17. M?rz 2009 11:49 schrieb Yandex: > data (a :=: a') where > Refl :: a :=: a > Comm :: (a :=: a') -> (a' :=: a) > Trans :: (a :=: a') -> (a' :=: a'') -> (a :=: a'') I don?t think, Comm and Trans should go into the data type. They are not axioms but can be proven. Refl says that each type equals itself. Since GADTs are closed, Martijn?s definition also says that two types can *only* be equal if they are actually the same. Here are the original definition and the proofs of comm and trans. Compiles fine with GHC 6.10.1. data (a :=: a') where Refl :: a :=: a comm :: (a :=: a') -> (a' :=: a) comm Refl = Refl trans :: (a :=: a') -> (a' :=: a'') -> (a :=: a'') trans Refl Refl = Refl Best wishes, Wolfgang From manlio_perillo at libero.it Tue Mar 17 08:29:44 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Mar 17 08:17:47 2009 Subject: [Haskell-cafe] random shuffle and random list partition In-Reply-To: <2608b8a80903170400r33382fafucd4d0cdf492d3eba@mail.gmail.com> References: <49BEDD9B.5020304@libero.it> <2608b8a80903170400r33382fafucd4d0cdf492d3eba@mail.gmail.com> Message-ID: <49BF97B8.2040603@libero.it> Yitzchak Gale ha scritto: > [...] > While I think Oleg's tree method is beautiful, in practice > it may be re-inventing the wheel. I haven't tested it, but > I doubt that this implementation is much better than > using the classical shuffle algorithm on an IntMap. Do you have a working implementation? > It's essentially the same tree inside. That's what I > usually use for this, and it works fine. > Oleg implementation is rather efficient, but it requires a lot of memory for huge lists. Here, as an example, two programs, one in Python and one in Haskell. The default Python generator in Python use the Mersenne Twister, but returning floats number in the range [0, 1]. # Python version from random import shuffle n = 10000000 m = 10 l = range(1, n + 1) shuffle(l) print l[:m] -- Haskell version module Main where import Random.Shuffle import System.Random.Mersenne.Pure64 (newPureMT) n = 10000000 m = 10 l = [1 .. n] main = do gen <- newPureMT print $ take m $ shuffle' l n gen The Python version performances are: real 0m16.812s user 0m16.469s sys 0m0.280s 150 MB memory usage The Haskell version performances are: real 0m8.757s user 0m7.920s sys 0m0.792s 800 MB memory usage >> In future I can add an implementation of the random >> shuffle algorithm on mutable arrays in the ST monad. > > I've tried that in the past. Surprisingly, it wasn't faster > than using trees. Perhaps I did something wrong. Or > perhaps the difference only becomes apparent for > huge lists. > Can you try it on the list I have posted above? > As you point out, your partition algorithm is not fair. > Using your Random.Shuffle and a well-know trick > from combinatorics, you can easily get a fair > partitions function: > > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2485#a2495 > Thanks, this is very nice. I have to run some benchmarks to see if it is efficient. Regards Manlio From gue.schmidt at web.de Tue Mar 17 08:37:44 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Tue Mar 17 08:25:55 2009 Subject: [Haskell-cafe] How can I check which thunks are piling up on the stack? Message-ID: Hi, How can I check which thunks are piling up on the stack? G?nther From claus.reinke at talk21.com Tue Mar 17 08:40:58 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Mar 17 08:29:02 2009 Subject: [Haskell-cafe] What unsafeInterleaveIO is unsafe References: <2f9b2d30903151302w1c92cb96yda84c2acada12a2d@mail.gmail.com><1237238274.6590.0.camel@jonathans-macbook><1237240877.22402.534.camel@localhost><1237243071.6590.31.camel@jonathans-macbook><035453A1C6AE4CA591408A9F14BBB840@cr3lt> <1237256016.6590.57.camel@jonathans-macbook> Message-ID: <47D4ACD85F404F8D8D55E814E4A48B62@cr3lt> >> So that first step already relies on IO (where the two are equivalent). > Come again? The first step in your implication chain was (without the return) throw (ErrorCall "urk!") <= 1 ==> evaluate (throw (ErrorCall "urk!")) <= evaluate 1 but, using evaluation only (no context-sensitive IO), we have >> throw (ErrorCall "urk") <= evaluate (throw (ErrorCall "urk")) > Sure enough. meaning that first step replaced a smaller with a bigger item on the smaller side of the inequation. Unless the reasoning includes context- sensitive IO rules, in which case the IO rule for evaluate brings the throw to the top (evaluate (throw ..) -> (throw ..)), making the two terms equivalent (modulo IO), and hence the step valid (modulo IO). Unless you just rely on >But throwIO (ErrorCall "urk") /= _|_: > Control.Exception> throwIO (ErrorCall "urk!") `seq` () > () in which case that step relies on not invoking IO, so it can't be mixed with the later step involving IO for catch (I think). >> This is very delicate territory. For instance, one might think that >> this 'f' seems to define a "negation function" of information content > >> f x = Control.Exception.catch (evaluate x >> let x = x in x) (\(ErrorCall _)->return 0) >>= >> print >> >> and hence violates monotonicity >> >> (_|_ <= ()) => (f _|_ <= f ()) >> >> since >> >> *Main> f undefined >> 0 >> *Main> f () >> Interrupted. >> >> But that is really mixing context-free expression evaluation and >> context-sensitive execution of io operations. Most of our favourite >> context-free equivalences only hold within the expression evaluation >> part, while IO operations are subject to additional, context-sensitive >> rules. > > Could you elaborate on this? It sounds suspiciously like you're saying > Haskell's axiomatic semantics is unsound :: IO. Not really unsound, if the separation is observed. One could probably construct a non-separated semantics (everything denotational), but at the cost of mapping everything to computations rather than values. Then computations like that 'f' above would, eg, take an extra context argument (representing "the world", or at least aspects of the machine running the computation), and the missing information needed to take 'f _|_'[world] to '()'[world'] would come from that context parameter (somewhere in the computational context, there is a representation of the computation, which allows the context to read certain kinds of '_|_' as exceptions; the IO rule for 'catch' takes that external information and injects it back from the computational context into the functional program, as data structure representations of exceptions). That price is too high, though, as we'd now have to do all reasoning in context-sensitive terms which, while more accurate, would bury us in irrelevant details. Hence we usually try to use context-free reasoning whenever we can get away with it (the non-IO portions of Haskell program runs), resorting to context-sensitive reasoning only when necessary (the IO steps of Haskell program runs). This gives us convenience when the context is irrelevant as well as accuracy when the context does matter - we just have to be careful when combining the two kinds of reasoning. >> For instance, without execution >> >> *Main> f () `seq` () >> () >> *Main> f undefined `seq` () >> () >> >> but if we include execution (and the context-sensitive equivalence >> that implies, lets call it ~), > > So > > a ~ b = `The observable effects of $(x) and $(y) are equal' > > ? Observational equivalence is one possibility, there are various forms of equivalences/bi-similarities, with different ratios of convenience and discriminatory powers (the folks studying concurrent languages and process calculi have been fighting with this kind of situation for a long time, and have built up a wealth of experience in terms of reasoning). The main distinction I wanted to make here was that '=' was a context-free equivalence (valid in all contexts, involving only context-free evaluation rules) while '~' was a context-sensitive equivalence (valid only in IO contexts, involving both context-free and context-sensitive rules). >> we have >> >> f () ~ _|_ <= return 0 ~ f _|_ >> >> so 'f' shows that wrapping both sides of an inequality in 'catch' need >> not preserve the ordering (modulo ~) > > If f _|_ <= f (), then it seems that (<=) is not a (pre-) order w.r.t. > (~). So taking the quotient of IO Int over (~) gives you a set on which > (<=) is not an ordering (and may not be a relation). As I said, mixing '=' and '~', without accounting for the special nature of the latter, is dangerous. If we want to mix the two, we have to shift all reasoning into the context-sensitive domain, so we'd have something like f () [world] ~ _|_ [world''] <= return 0 [world'] ~ f _|_ [world] (assuming that '<=' is lifted to compare values in contexts). And now the issue goes away, because 'f' doesn't look at the '_|_', but at the representation of '_|_' in the 'world' (the representation of '_|_' in GHC's runtime system, say). >> - its whole purpose is to recover >> from failure, making something more defined (modulo ~) by translating >> _|_ to something else. Which affects your second implication. > >> If the odd properties of 'f' capture the essence of your concerns, I think >> the answer is to keep =, <=, and ~ clearly separate, ideally without losing >> any of the context-free equivalences while limiting the amount of >> context-sensitive reasoning required. If = and ~ are mixed up, however, >> monotonicity seems lost. > > So > > catch (throwIO e) h ~ h e > > but it is not the case that > > catch (throwIO e) h = h e > > ? That must be correct, actually: > > Control.Exception> let x = Control.Exception.catch (throwIO > (ErrorCall "urk!")) (\ (ErrorCall _) -> undefined) in x `seq` () > () > > So catch is total (even if one or both arguments is erroneous), but the > IO executor (a beast totally distinct from the Haskell interpreter, even > if they happen to live in the same body) when executing it feels free to > examine bits of the Haskell program's state it's not safe for a normal > program to inspect. I'll have to think about what that means a bit > more. Yes, exactly!-) > [Totally OT tangent: How did operational semantics come to get its noun? > The more I think about it, the more it seems like a prec?s of the > implementation, rather than a truly semantic part of a language > specification.] There's bad taste associated with the term, stemming from older forms of operational semantics that were indeed unnecessarily close to the implementations (well, actually, such close resemblance can still be useful to guide implementations, or to prove things about implementations, so there are many forms of operational semantics, varying in levels of abstraction to accommodate the target areas of study). Modern forms of operational semantics (when studying languages, not implementations) are much more abstract than that, closer to inference rules of a programming logic. Oversimplified: they study equivalence classes of semantics, using syntactic terms as canonical representatives. This use of syntax tends to confuse denotational semantics adherents, who say that syntax should be irrelevant in order to achieve sufficiently abstract semantics. But if we have two denotational semantics, S1 and S2, mapping constructs of language L to D1 and D2, respectively, then the only thing they are going to have in common are the constructs of L and, hopefully, the relations between the things these constructs are mapped to. So, if we want to abstract over the specific denotational semantics Sx, and its specific domain Dx, we just talk about [| L |] or, by abuse of notation, about L. So, when abstract operational semantics talk about 'X ~ Y' for some X,Y in L, they are really talking about 'forall semantics S :: L -> D. S[| X |]::D ~ S[| Y |]::D', without the repetitive details. In other words, when abstract operational semantics focus on syntax, they only focus on those aspects of syntax that are relevant to all semantics, such as composition and relations. Hey, who put me on that hobby-horse again?-) Claus From gale at sefer.org Tue Mar 17 07:59:50 2009 From: gale at sefer.org (Yitzchak Gale) Date: Tue Mar 17 08:54:10 2009 Subject: [Haskell-cafe] Need an overview of FP-related research topics Message-ID: <2608b8a80903170459j52b779e3p3cac96ba7f6583df@mail.gmail.com> I spoke to a faculty member in a decent Computer Science department in which no one has ever done anything related to FP. (You may say that is an inherent contradiction, but what can I do, the department does have a good reputation. I am withholding names to protect the innocent.) This faculty member happens to be the one who was forced to teach the single programming languages course offered by the department, due to his having the least seniority in the department. As such, he is now actually starting to become a bit interested in FP and Haskell. I gave him a few links to Haskell resources, which he appreciated. But coming from more of a pragmatic non-research point of view, I didn't really know what to say. The best I could do was to point him to the Haskell Wikibook, and to the "Why FP Matters" paper. I would like some links that would give such a person a nice overview of the various active areas of FP-related research these days, leaning towards Haskell. I want to give him a fairly broad view of what is interesting and exciting, why various topics are important, where to find ideas for collaboration and applications to other areas, etc. I actually know about a few departments like that. This could be a good strategy for drumming up more research interest in Haskell. In some cases, the person in question has already been influenced somewhat by the lisp fanatics, so I would like some help in how to deal with that also. Thanks, Yitz From eelco at lempsink.nl Tue Mar 17 09:06:32 2009 From: eelco at lempsink.nl (Eelco Lempsink) Date: Tue Mar 17 08:54:35 2009 Subject: [Haskell-cafe] Haskell Logo Voting has started! Message-ID: Hi there! I updated a couple of logo versions and ungrouped and regrouped the (former) number 31. Other than that, there was nothing standing in the way of the voting to begin imho, so I started up the competition. By now, I suppose everybody should have received their ballot. If you think you should have received it but didn't, please report it, I can resend the invitation. Also, for people not directly subscribed to the haskell-cafe mailing list, you can still send ballot requests until the end of the competition (March 24, 12:00 UTC). Make sure the message contains 'haskell logo voting ballot request' (e.g. in the subject). Depending on the winner of this voting round we can decide whether we need to continue with variations. Jared Updike already offered to donate a bit of time to help create several variations. But for now, good luck with sorting those options! :) -- Regards, Eelco Lempsink -------------- 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/20090317/c4176103/PGP.bin From rturk at science.uva.nl Tue Mar 17 10:17:29 2009 From: rturk at science.uva.nl (Remi Turk) Date: Tue Mar 17 10:05:38 2009 Subject: [Haskell-cafe] ANNOUNCE: libffi 0.1 released Message-ID: <20090317141729.GA20381@ow127.science.uva.nl> I am happy to announce libffi 0.1, binding to the C library libffi, allowing C functions to be called whose types are not known before run-time. Why? Sometimes you can't use the haskell foreign function interface because you parse the type of the function from somewhere else, i.e. you're writing an interpreter for a language that has an FFI itself. What? The main function it exports is: callFFI :: FunPtr a -> RetType b -> [Arg] -> IO b And because code is worth a thousand words, here a small program that uses C to write a 1Gb buffer of random garbage to a file: > import System.Posix.DynamicLinker > import Foreign.LibFFI > > main = do > malloc <- dlsym Default "malloc" > creat <- dlsym Default "creat" > write <- dlsym Default "write" > let sz = 2 ^ 30 > buf <- callFFI malloc (retPtr retVoid) [argCSize sz] > fd <- callFFI creat retCInt [argString "/tmp/test", argCUInt 0o644] > n <- callFFI write retCSize [argCInt fd, argPtr buf, argCSize sz] > putStrLn $ show n ++ " bytes written" It should work on any 32/64bits machine on which libffi works, but has been primarily tested on linux x86_64. The current libffi is not exception-safe (exception = memory leak) and callFFI has quite some overhead that would be unnecessary with another api. It is, however, very easy to use :) More interesting examples are included in examples/ in the package. Where? Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/libffi Module docs: http://www.science.uva.nl/~rturk/doc/libffi-0.1 Cheers, Remi From apfelmus at quantentunnel.de Tue Mar 17 10:24:28 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Mar 17 10:11:31 2009 Subject: [Haskell-cafe] Re: Haskell Logo Voting has started! In-Reply-To: References: Message-ID: Eelco Lempsink wrote: > Hi there! > > I updated a couple of logo versions and ungrouped and regrouped the > (former) number 31. Other than that, there was nothing standing in the > way of the voting to begin imho, so I started up the competition. > > By now, I suppose everybody should have received their ballot. If you > think you should have received it but didn't, please report it, I can > resend the invitation. Also, for people not directly subscribed to the > haskell-cafe mailing list, you can still send ballot requests until the > end of the competition (March 24, 12:00 UTC). Make sure the message > contains 'haskell logo voting ballot request' (e.g. in the subject). > > Depending on the winner of this voting round we can decide whether we > need to continue with variations. Jared Updike already offered to > donate a bit of time to help create several variations. But for now, > good luck with sorting those options! :) Thanks for organizing this, finally I can choose ... Oh my god! How am I supposed to make a vote? I can barely remember 3 of the 113 logos, let alone memorize that #106 is the narwhal. There are lots of very good or just good candidates and I would like to order them all to my liking, but without instant visual feedback on the voting ballot, this is a hopeless task. Since I have about 10 minutes to spare for voting, I'm just going to pick 5 candidates at random and order these? Actually, I think I prefer to be completely paralyzed by the overwhelming choice instead and not vote at all. Alternatively, it seems that it's possible to upload rankings from a file. But which format? And is there a zip file with the logo proposals so I can try to arrange them via drag&drop in some picture gallery application? A simple majority vote is clearly inadequate for this vote, but I'm afraid that without assisting technology (instant and visual feedback), the voting process will more or less deteriorate to that due to the difficulty of creating quality input votes. Regards, apfelmus -- http://apfelmus.nfshost.com From mads_lindstroem at yahoo.dk Tue Mar 17 10:23:54 2009 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Tue Mar 17 10:13:10 2009 Subject: [Haskell-cafe] SQL Parsers in Haskell Message-ID: <1237299834.4354.10.camel@localhost.localdomain> Hi Haskelleers Has anybody written a SQL parser in Haskell (and is willing to share the code) ? Greetings, Mads Lindstr?m From bjorn.buckwalter at gmail.com Tue Mar 17 10:38:11 2009 From: bjorn.buckwalter at gmail.com (Bjorn Buckwalter) Date: Tue Mar 17 10:26:08 2009 Subject: [Haskell-cafe] Apologies for spamming Planet Haskell Message-ID: <8b2a1a960903170738jb8aacd3v9a4b9e66b00711d7@mail.gmail.com> Dear Planet Haskell readers, Just want to apologize for spamming Planet Haskell. I did some minor formatting edits of old posts and it seems Planet Haskell picked them up and republished them. I didn't expect this to happen (Google Reader doesn't do that) and will be more careful about gratuitously editing old posts in the future. Thanks, Bjorn Buckwalter From bjpop at csse.unimelb.edu.au Tue Mar 17 09:33:06 2009 From: bjpop at csse.unimelb.edu.au (Bernie Pope) Date: Tue Mar 17 10:47:45 2009 Subject: [Haskell-cafe] Need an overview of FP-related research topics In-Reply-To: <2608b8a80903170459j52b779e3p3cac96ba7f6583df@mail.gmail.com> References: <2608b8a80903170459j52b779e3p3cac96ba7f6583df@mail.gmail.com> Message-ID: <0CCCBAAD-B92E-4F8A-9DA5-4F0309A9E8D9@csse.unimelb.edu.au> On 17/03/2009, at 10:59 PM, Yitzchak Gale wrote: > I would like some links that would give such a person > a nice overview of the various active areas of > FP-related research these days, leaning towards > Haskell. I want to give him a fairly broad view of what > is interesting and exciting, why various topics are > important, where to find ideas for collaboration and > applications to other areas, etc. Some ideas off the top of my head: - Lambda the Ultimate (not Haskell or fp specific) http://lambda-the-ultimate.org/ - Browse recent editions of the Journal of Functional Programming (perhaps they even subscribe to it at the Uni in question) and perhaps TOPLAS. - Browse the recent proceedings of various conferences and workshops such as International Conference on Functional Programming, Trends in Functional Programming, the Haskell Symposium, Practical Aspects of Declarative Languages, Principles and Practice of Declarative Programming, International Summer School on Advanced Functional Programming (and many others). - Check the home pages and blogs of well-known and active researchers (I won't list them). - Maybe http://www.readscheme.org/, though not Haskell specific. (not sure if http://haskell.readscheme.org/ is working anymore). - There's quite a list of papers on haskell.org, under http://www.haskell.org/haskellwiki/Research_papers . Cheers, Bernie. From leather at cs.uu.nl Tue Mar 17 10:55:11 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Mar 17 10:47:55 2009 Subject: [Haskell-cafe] Need an overview of FP-related research topics In-Reply-To: <2608b8a80903170459j52b779e3p3cac96ba7f6583df@mail.gmail.com> References: <2608b8a80903170459j52b779e3p3cac96ba7f6583df@mail.gmail.com> Message-ID: <3c6288ab0903170755q61efd516oad30823e9e242b38@mail.gmail.com> > I would like some links that would give such a person > a nice overview of the various active areas of > FP-related research these days, leaning towards > Haskell. > It seems the "History of Haskell" paper would be useful for background and pointers to further reading on the research that has led Haskell to its current status. Of course, it is long (55 pages, two columns), but perhaps it's a nice read, nonetheless. http://research.microsoft.com/en-us/um/people/simonpj/papers/history-of-haskell/index.htm Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090317/1b451884/attachment.htm From all.are.wonders at gmail.com Tue Mar 17 11:01:53 2009 From: all.are.wonders at gmail.com (Larry Coleman) Date: Tue Mar 17 10:49:50 2009 Subject: [Haskell-cafe] RE: SQL Parsers in Haskell Message-ID: <893f52620903170801g2b59e70dlb4c72039ce304198@mail.gmail.com> > Hi Haskelleers > > Has anybody written a SQL parser in Haskell (and is willing to share the > code) ? > > Greetings, > > Mads Lindstr?m I have a mostly-working SQL parser that I wrote to help with DBA tasks at work. I'm under one of the standard employment IP agreements, however, so my employer owns the code. I have asked about having it released, but that process will take some time. I'll post to the group if/when it ever happens. Larry Coleman From greenrd at greenrd.org Mon Mar 16 23:58:58 2009 From: greenrd at greenrd.org (Robin Green) Date: Tue Mar 17 10:58:45 2009 Subject: [Haskell-cafe] Re: Haskell Logo Voting has started! In-Reply-To: References: Message-ID: <20090317035858.4e82c518@greenrd.org> On Tue, 17 Mar 2009 15:24:28 +0100 Heinrich Apfelmus wrote: > A simple majority vote is clearly inadequate for this vote, but I'm > afraid that without assisting technology (instant and visual > feedback), the voting process will more or less deteriorate to that > due to the difficulty of creating quality input votes. Even worse, the buttons for moving items up and down are buggy - at least on my browser (Firefox 3.1 beta 2 on Linux). They sometimes reorder my other votes! Even assuming that the list box code is not buggy (which I now doubt), not being able to use the buttons makes this form almost unusable! -- Robin From tom.davie at gmail.com Tue Mar 17 11:11:54 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Tue Mar 17 10:59:54 2009 Subject: [Haskell-cafe] Re: Haskell Logo Voting has started! In-Reply-To: References: Message-ID: On 17 Mar 2009, at 15:24, Heinrich Apfelmus wrote: > Eelco Lempsink wrote: >> Hi there! >> >> I updated a couple of logo versions and ungrouped and regrouped the >> (former) number 31. Other than that, there was nothing standing in >> the >> way of the voting to begin imho, so I started up the competition. >> >> By now, I suppose everybody should have received their ballot. If >> you >> think you should have received it but didn't, please report it, I can >> resend the invitation. Also, for people not directly subscribed to >> the >> haskell-cafe mailing list, you can still send ballot requests until >> the >> end of the competition (March 24, 12:00 UTC). Make sure the message >> contains 'haskell logo voting ballot request' (e.g. in the subject). >> >> Depending on the winner of this voting round we can decide whether we >> need to continue with variations. Jared Updike already offered to >> donate a bit of time to help create several variations. But for now, >> good luck with sorting those options! :) > > Thanks for organizing this, finally I can choose ... Oh my god! How > am I > supposed to make a vote? > > > I can barely remember 3 of the 113 logos, let alone memorize that #106 > is the narwhal. There are lots of very good or just good candidates > and > I would like to order them all to my liking, but without instant > visual > feedback on the voting ballot, this is a hopeless task. > > Since I have about 10 minutes to spare for voting, I'm just going to > pick 5 candidates at random and order these? Actually, I think I > prefer > to be completely paralyzed by the overwhelming choice instead and not > vote at all. > > Alternatively, it seems that it's possible to upload rankings from a > file. But which format? And is there a zip file with the logo > proposals > so I can try to arrange them via drag&drop in some picture gallery > application? > > > A simple majority vote is clearly inadequate for this vote, but I'm > afraid that without assisting technology (instant and visual > feedback), > the voting process will more or less deteriorate to that due to the > difficulty of creating quality input votes. I have to agree that the UI for voting is not the best I've ever seen. On the other hand, it's pretty easy to select the few logos that you like, and push them all to the top, select the ones you'd accept, and push them up just below, and finally select the ones you absolutely don't like and push them all the way down. That at least is what I did. Bob From greenrd at greenrd.org Tue Mar 17 00:12:53 2009 From: greenrd at greenrd.org (Robin Green) Date: Tue Mar 17 11:12:39 2009 Subject: [Haskell-cafe] Re: Haskell Logo Voting has started! In-Reply-To: References: Message-ID: <20090317041253.20fd2a6b@greenrd.org> On Tue, 17 Mar 2009 16:11:54 +0100 Thomas Davie wrote: > I have to agree that the UI for voting is not the best I've ever > seen. On the other hand, it's pretty easy to select the few logos > that you like, and push them all to the top, select the ones you'd > accept, and push them up just below, and finally select the ones you > absolutely don't like and push them all the way down. > > That at least is what I did. Did you check that code bugs hadn't reordered your votes? I am worried about this destroying the validity of the election. -- Robin From greenrd at greenrd.org Tue Mar 17 00:18:57 2009 From: greenrd at greenrd.org (Robin Green) Date: Tue Mar 17 11:18:48 2009 Subject: [Haskell-cafe] Re: Haskell Logo Voting has started! In-Reply-To: References: Message-ID: <20090317041857.24134866@greenrd.org> I am also concerned that the default behaviour of the buttons will lead to arbitrary preference rankings favouring those with entries that start more towards the top or bottom of the list. You shouldn't have to go to a lot of extra effort to create a tie between several entries, if you can't decide (or don't want to decide) between them. However, this isn't as significant as the buggy reordering behaviour I'm seeing. -- Robin From jonathanccast at fastmail.fm Tue Mar 17 11:32:36 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Tue Mar 17 11:20:34 2009 Subject: categories and monoids (was: Re: [Haskell-cafe] Design Patterns by Gamma or equivalent) In-Reply-To: <200903171306.10237.g9ks157k@acme.softbase.org> References: <009701c9a238$5e75da60$1b618f20$@spezzano@chariot.net.au> <200903171034.11392.g9ks157k@acme.softbase.org> <200903171306.10237.g9ks157k@acme.softbase.org> Message-ID: <1237303956.6311.1.camel@jonathans-macbook> On Tue, 2009-03-17 at 13:06 +0100, Wolfgang Jeltsch wrote: > Am Dienstag, 17. M?rz 2009 10:54 schrieben Sie: > > Wolfgang Jeltsch writes: > > > By the way, the documentation of Control.Category says that a category is > > > a monoid (as far as I remember). This is wrong. Category laws correspond > > > to monoid laws but monoid composition is total while category composition > > > has the restriction that the domain of the first argument must match the > > > codomain of the second. > > > > I'm reading the Barr/Wells slides at the moment, and they say the > > following: > > > > "Thus a category can be regarded as a generalized monoid, > > What is a ?generalized monoid?? According to the grammatical construction > (adjective plus noun), it should be a special kind of monoid, like a > commutative monoid is a special kind of monoid. But then, monoids would be > the more general concept and categories the special case, quite the opposite > of how it really is. > > A category is not a ?generalized monoid? but categories (as a concept) are a > generalization of monoids. Each category is a monoid, but not the other way > round. You mean ``each monoid is a category, but not the other way round''. > A monoid is clearly defined as a pair of a set M and a (total) binary > operation over M that is associative and has a neutral element. So, for > example, the category of sets and functions is not a monoid. First, function > composition is not total if you allow arbitrary functions as its arguments. > Second, the collection of all sets is not itself a set (but a true class) > which conflicts with the above definition which says that M has to be a set. > > > or a 'monoid with many objects'" > > What is a monoid with many objects? A categorical definition of a monoid (that is, a plain old boring monoid in Set) is that it is a category with a single object. A category is thus a monoid with the restriction to a single object lifted :) jcc From rick.richardson at gmail.com Tue Mar 17 11:33:54 2009 From: rick.richardson at gmail.com (Rick R) Date: Tue Mar 17 11:21:50 2009 Subject: [Haskell-cafe] Re: Haskell Logo Voting has started! In-Reply-To: <20090317041253.20fd2a6b@greenrd.org> References: <20090317041253.20fd2a6b@greenrd.org> Message-ID: <9810b81b0903170833l3938f5c0s14d64c06780da14c@mail.gmail.com> And we thought butterfly ballots were bad. I just went through the logo page and wrote down my favorite 20 logos in one column, and gave them a rank in the other. Then translated that into the voting list using the combo boxes (not the buttons). The total process took 20 minutes. I am on FF3 on windows and didn't notice any reordering aside the (un?)expected reordering by rank. On Tue, Mar 17, 2009 at 12:12 AM, Robin Green wrote: > On Tue, 17 Mar 2009 16:11:54 +0100 > Thomas Davie wrote: > > > I have to agree that the UI for voting is not the best I've ever > > seen. On the other hand, it's pretty easy to select the few logos > > that you like, and push them all to the top, select the ones you'd > > accept, and push them up just below, and finally select the ones you > > absolutely don't like and push them all the way down. > > > > That at least is what I did. > > Did you check that code bugs hadn't reordered your votes? I am worried > about this destroying the validity of the election. > -- > Robin > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- We can't solve problems by using the same kind of thinking we used when we created them. - A. Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090317/7aaa3e80/attachment.htm From gwern0 at gmail.com Tue Mar 17 11:34:29 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Mar 17 11:22:27 2009 Subject: [Haskell-cafe] Haskell Logo Voting has started! In-Reply-To: References: Message-ID: 2009/3/17 Eelco Lempsink : > Hi there! > > I updated a couple of logo versions and ungrouped and regrouped the (former) > number 31. ?Other than that, there was nothing standing in the way of the > voting to begin imho, so I started up the competition. > > By now, I suppose everybody should have received their ballot. ?If you think > you should have received it but didn't, please report it, I can resend the > invitation. ?Also, for people not directly subscribed to the haskell-cafe > mailing list, you can still send ballot requests until the end of the > competition (March 24, 12:00 UTC). ?Make sure the message contains 'haskell > logo voting ballot request' (e.g. in the subject). > > Depending on the winner of this voting round we can decide whether we need > to continue with variations. ?Jared Updike already offered to donate a bit > of time to help create several variations. ?But for now, good luck with > sorting those options! :) > > -- > Regards, > > Eelco Lempsink I've personally voted, but it's true that 113 logos is a bit much even if you only vote on about 20 of them! Can we assume that the next round will be more like 10? Also, what is the plan if one of the joke logos (like the boobies one) makes it into the final round? Will it just be quietly removed? Finally, I'd like to make a suggestion as to the final results. Typically there's a tension between a Free & trademarked logo and a just Free logo. ie. see how Debian does it: http://www.debian.org/logos/ "Although Debian can be obtained for free and will always remain that way, events such as the problem with the ownership of the term ?Linux? have shown that Debian needs to protect its property from any use which could hurt its reputation. Debian has decided to create two logos: one logo is for official Debian use; the other logo falls under an open use type license." We could have the top result be the official logo, and the second result be unofficial. In this way, both logos win: the former will appear in all the official high-prestige locations, but the latter will likely get reused more. Admittedly, it's unlikely the two top finishers will have quite the same thematic unity as the two Debian logos, but I think it's a suggestion worth entertaining. -- gwern From dev at mobileink.com Tue Mar 17 11:47:17 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Tue Mar 17 11:35:14 2009 Subject: [Haskell-cafe] Design Patterns by Gamma or equivalent In-Reply-To: <-223952846378897397@unknownmsgid> References: <-223952846378897397@unknownmsgid> Message-ID: <75cc17ac0903170847y7ca24c2ds18aaf0f587cba93@mail.gmail.com> 2009/3/11 Mark Spezzano : > I?m very familiar with the concept of Design Patterns for OOP in Java and > C++. They?re basically a way of fitting components of a program so that > objects/classes fit together nicely like Lego blocks and it?s useful because > it also provides a common ?language? to talk about concepts, like Abstract > Factory, or an Observer to other programmers. In this way one programmer can > instantly get a feel what another programmer is talking about even though > the concepts are fundamentally abstract. > > Because Haskell is not OO, it is functional, I was wondering if there is > some kind of analogous ?design pattern?/?template? type concept that > describe commonly used functions that can be ?factored out? in a general > sense to provide the same kind of usefulness that Design Patterns do for > OOP. Basically I?m asking if there are any kinds of ?common denominator? > ?function compositions that are used again and again to solve problems. If > so, what are they called? > You might find it useful to read the original works upon which the whole "design pattern" economy is based, namely Christopher Alexander's books (http://www.patternlanguage.com/leveltwo/booksframe.htm?/leveltwo/../bookstore/bookstore.htm). I liked "Notes on the Synthesis of Form", which predates his pattern language stuff. My $0.02: design patterns became popular in the imperative language community precisely because such languages lack the formal discipline of functional languages. Alexander came up with the notion of a pattern language in order to bring some kind of discipline and abstraction to observed regularities in architecture, urban design, etc. By definition such a language cannot have anything close to formal semantics, any more than a natural language lexicon can have formal semantics. Alexander's