From ajb at spamcop.net Wed Jul 1 00:00:50 2009 From: ajb at spamcop.net (ajb@spamcop.net) Date: Tue Jun 30 23:43:34 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701013126.GK22067@sliver.repetae.net> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> Message-ID: <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> G'day all. On Tue, Jun 30, 2009 at 08:02:48PM -0400, Daniel Peebles wrote: > But we don't want to imply it's commutative either. Having something > "bidirectional" like <> or <+> feels more commutative than associative > to me. Quoting John Meacham : > Not really, think of '++', which doesn't commute but is visually > symmetric, or Data.Sequence.<>, or the common use of <> to mean > concatination in pretty printers. Other good examples are && and ||. Cheers, Andrew Bromage From ketil at malde.org Wed Jul 1 02:12:05 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Jul 1 01:54:40 2009 Subject: [Haskell-cafe] ORM for haskell? In-Reply-To: <1246397641.4349.7.camel@supermule.opasia.dk> ("Mads =?utf-8?Q?Lindstr=C3=B8m=22's?= message of "Tue\, 30 Jun 2009 23\:34\:01 +0200") References: <20090630175208.GE6272@gmx.de> <1246397641.4349.7.camel@supermule.opasia.dk> Message-ID: <87prclc4p6.fsf@malde.org> Mads Lindstr?m writes: > I do not get this explanation, could you expand? I would have thought it > should be: "difference? Because SQLAlchemy knows about the relationships > (not relations, but relation_ships_), it do not have to explicitly join > on foreign keys.". I think this is a common terminology issue - lots of people think "relational" refers linking tables together (foreign keys), and not the mathematical definition of a relation as a subset of T1 x T2 x ... x Tn -- i.e. a table. -k -- If I haven't seen further, it is by standing in the footprints of giants From ketil at malde.org Wed Jul 1 02:24:08 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Jul 1 02:06:49 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090630235129.nre9tqg4u8sk0os8-nwo@webmail.spamcop.net> (ajb@spamcop.net's message of "Tue\, 30 Jun 2009 23\:51\:29 -0400") References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090630235129.nre9tqg4u8sk0os8-nwo@webmail.spamcop.net> Message-ID: <87ljn8dipj.fsf@malde.org> You know, this might be the right time to start expanding our vocabulary beyond seven bits. Since we're likely to keep mappend around as an alias for some time, people would have a grace period to adjust. How about U+2295 (circle with plus inside it)? Or, if we would like to stick to the 8-bit subset to keep those 8859-1 users happy, how about ? (funny circle over an x, U+00A4) -k -- If I haven't seen further, it is by standing in the footprints of giants From alexander.dunlap at gmail.com Wed Jul 1 02:45:24 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Wed Jul 1 02:28:21 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <87ljn8dipj.fsf@malde.org> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090630235129.nre9tqg4u8sk0os8-nwo@webmail.spamcop.net> <87ljn8dipj.fsf@malde.org> Message-ID: <57526e770906302345v47bd63f4h19e6f1d487d1ae6@mail.gmail.com> On Tue, Jun 30, 2009 at 11:24 PM, Ketil Malde wrote: > > You know, this might be the right time to start expanding our > vocabulary beyond seven bits. ?Since we're likely to keep mappend > around as an alias for some time, people would have a grace period to > adjust. > > How about U+2295 (circle with plus inside it)? > > Or, if we would like to stick to the 8-bit subset to keep those 8859-1 > users happy, how about ? (funny circle over an x, U+00A4) > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > The major disadvantage of that is that those symbols are not on my keyboard and thus are more of a pain to type, especially on the Linux console where compose key is not available... Alex From jochem at functor.nl Wed Jul 1 03:34:44 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Wed Jul 1 03:17:07 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090630235129.nre9tqg4u8sk0os8-nwo@webmail.spamcop.net> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090630235129.nre9tqg4u8sk0os8-nwo@webmail.spamcop.net> Message-ID: <4A4B1194.1000706@functor.nl> ajb@spamcop.net wrote: > G'day all. > > Quoting John Meacham : > >> (+>) seems to imply to me that the operator is non-associative. Something >> like (<>) or (<+>) would be better. > > I tend to agree. Moreover, and I realise this may be a losing battle, > I want (++) to be the generic operator. I totally agree. (+>) is too asymmetric for my taste, like (>>=) and (*>) it suggests asymmetry between the arguments. (++) is symmetric and suggests an associative operator to me. -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From dav.vire+haskell at gmail.com Wed Jul 1 04:38:31 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Jul 1 04:21:05 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <4A4B1194.1000706@functor.nl> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090630235129.nre9tqg4u8sk0os8-nwo@webmail.spamcop.net> <4A4B1194.1000706@functor.nl> Message-ID: <4c88418c0907010138m27b3b9a5o8323bee712bfee21@mail.gmail.com> On Wed, Jul 1, 2009 at 9:34 AM, Jochem Berndsen wrote: > ajb@spamcop.net wrote: >> I tend to agree. ?Moreover, and I realise this may be a losing battle, >> I want (++) to be the generic operator. > I totally agree. So do I. David. From matthias.goergens at googlemail.com Wed Jul 1 05:25:49 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Jul 1 05:08:23 2009 Subject: [Haskell-cafe] List spine traversal In-Reply-To: <2a774a0c0906301329h2861ee31w95f3c6daf492c631@mail.gmail.com> References: <4A482153.1030903@gmail.com> <4A487CB9.5030003@van.steenbergen.nl> <7b501d5c0906290214q4b891cdbhceb45ab7468af487@mail.gmail.com> <87tz1zidz2.fsf@malde.org> <79e6290e0906291936i5c163fc2ude5e244ecc2c65da@mail.gmail.com> <2f9b2d30906292330w746ffe63h2b814fd08fcac58e@mail.gmail.com> <2a774a0c0906301329h2861ee31w95f3c6daf492c631@mail.gmail.com> Message-ID: > As a side note, (allowing seq and unsafePerformIO if necessary) is it > possible to implement a map that preserves cycles (instead of > transparently replacing them with infinite copies? ?Not horribly > useful, but would be quite cute. Baltasar Trancon y Widemann gave a talk on a generalized version of this problem at HaL4. Short answer: The problem is tractable in theory, but you need heavy math. Matthias. From duncan.coutts at worc.ox.ac.uk Wed Jul 1 06:38:48 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 1 06:27:51 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701013126.GK22067@sliver.repetae.net> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> Message-ID: <1246444728.28197.1655.camel@localhost> On Tue, 2009-06-30 at 18:31 -0700, John Meacham wrote: > On Tue, Jun 30, 2009 at 08:02:48PM -0400, Daniel Peebles wrote: > > But we don't want to imply it's commutative either. Having something > > "bidirectional" like <> or <+> feels more commutative than associative > > to me. Of course in Text.PrettyPrint, both <> and <+> are associative but not commutative (with identity empty). > Not really, think of '++', which doesn't commute but is visually > symmetric, or Data.Sequence.<>, or the common use of <> to mean > concatination in pretty printers. I think there is a fair amount of > precedence for using '<>' actually. As it appears when it is used, it > is also the natural mappend operator for the Monoid instance. I agree, if we can't use ++ then <> is the next best thing. As John says it's already a monoid operator for Data.Sequence and Text.PrettyPrint. Duncan From duncan.coutts at worc.ox.ac.uk Wed Jul 1 06:44:54 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 1 06:27:52 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <20090701015953.GM22067@sliver.repetae.net> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <20090701015953.GM22067@sliver.repetae.net> Message-ID: <1246445094.28197.1660.camel@localhost> On Tue, 2009-06-30 at 18:59 -0700, John Meacham wrote: > On Tue, Jun 30, 2009 at 01:18:32AM +0100, Duncan Coutts wrote: > > On IA32 structs/unions passed as parameters go by value on the stack. > > For structs/unions as function results, they are stored into a > > caller-allocated area on the stack, pointed to by a "hidden" first arg. > > > > It's different on each arch, but it's all completely specified. > > > > > moreover, even for pointers-to-structures, there is no definitive > > > layout due to packing problem > > > > Actually the padding is also specified by the C ABI. See section 3-3. > > Compiler pragmas to use packed layout are not ABI conformant (and so > > typically are only used internally). > > Yup. Unfortunately this doesn't help us, since in order to pass > structures we need to know more than just the layout (offset and size) > of the type, but we need to know the underlying C types as well which a > Storable instance doesn't give us. depending on the ABI, struct passing > may not be as simple as 'pass on stack' vs 'pass in registers'. it may > be something like 'the floating point components get pulled out and put > in registers, which the other components get pushed onto the stack'. So, > without some compiler magic, like a 'deriving Storable' instance that > derived some hidden methods to contain this extra information, or > additions to storable, this won't work in general. Yeah, I'm not suggesting going via Storable (for all those reasons), just extending the FFI to say tuples of FFI types get passed as the corresponding C ABI structs. All the magic to match the current platform C ABI then lives in the compiler. I was only half-serious in suggesting this btw, though as far as I can see it should actually work. It doesn't help with unions of course and it adds complexity to the compiler. Duncan From deniz.a.m.dogan at gmail.com Wed Jul 1 07:29:22 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Wed Jul 1 07:11:56 2009 Subject: [Haskell-cafe] gtk2hs tray icon disappears when using GHCi Message-ID: <7b501d5c0907010429l7d274a1wfa869d18e3e31711@mail.gmail.com> Hi I'm just trying out gtk2hs for the first time and I quite like it. However, for some reason my tray icon (...Gtk.Display.StatusIcon) disappears after a split second when I run my program using GHCi. What's the reason for this? Perhaps this is even a bug? It works just fine if I compile an .exe. I'm using Windows XP with GHC 6.10.3 and gtk2hs 0.10.1. import Graphics.UI.Gtk import Graphics.UI.Gtk.Display.StatusIcon main :: IO () main = do initGUI window <- windowNew tray <- statusIconNewFromFile "c:/Program Files/TortoiseHg/icons/commit.png" window `onDestroy` mainQuit widgetShowAll window mainGUI -- Deniz Dogan From jules at jellybean.co.uk Wed Jul 1 08:18:13 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Wed Jul 1 08:00:46 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <1246444728.28197.1655.camel@localhost> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> Message-ID: <4A4B5405.2000509@jellybean.co.uk> Duncan Coutts wrote: > I agree, if we can't use ++ then <> is the next best thing. As John says > it's already a monoid operator for Data.Sequence and Text.PrettyPrint. > I agree, if we can't use +> and <+ then <> is the next best thing. ;) Jules From dav.vire+haskell at gmail.com Wed Jul 1 08:52:40 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Jul 1 08:35:14 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <4A4B5405.2000509@jellybean.co.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <4A4B5405.2000509@jellybean.co.uk> Message-ID: <4c88418c0907010552i592ec07fjad8d90723beaa0b3@mail.gmail.com> On Wed, Jul 1, 2009 at 2:18 PM, Jules Bean wrote: > Duncan Coutts wrote: >> I agree, if we can't use ++ then <> is the next best thing. As John says >> it's already a monoid operator for Data.Sequence and Text.PrettyPrint. > I agree, if we can't use +> and <+ then <> is the next best thing. > ;) I see what you did there :-P From byorgey at seas.upenn.edu Wed Jul 1 08:56:26 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Jul 1 08:38:58 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> Message-ID: <20090701125626.GA8372@seas.upenn.edu> On Wed, Jul 01, 2009 at 12:00:50AM -0400, ajb@spamcop.net wrote: > G'day all. > > On Tue, Jun 30, 2009 at 08:02:48PM -0400, Daniel Peebles wrote: > >> But we don't want to imply it's commutative either. Having something >> "bidirectional" like <> or <+> feels more commutative than associative >> to me. > > Quoting John Meacham : > >> Not really, think of '++', which doesn't commute but is visually >> symmetric, or Data.Sequence.<>, or the common use of <> to mean >> concatination in pretty printers. > > Other good examples are && and ||. ..wha? But those ARE commutative. Unless you mean with respect to strictness? -Brent From ekmett at gmail.com Wed Jul 1 10:46:27 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Jul 1 10:29:00 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701125626.GA8372@seas.upenn.edu> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> Message-ID: <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> I'm rather fond of the (<>) suggestion, but would be happy with anything better than mappend! ;) -Ed On Wed, Jul 1, 2009 at 8:56 AM, Brent Yorgey wrote: > On Wed, Jul 01, 2009 at 12:00:50AM -0400, ajb@spamcop.net wrote: > > G'day all. > > > > On Tue, Jun 30, 2009 at 08:02:48PM -0400, Daniel Peebles wrote: > > > >> But we don't want to imply it's commutative either. Having something > >> "bidirectional" like <> or <+> feels more commutative than associative > >> to me. > > > > Quoting John Meacham : > > > >> Not really, think of '++', which doesn't commute but is visually > >> symmetric, or Data.Sequence.<>, or the common use of <> to mean > >> concatination in pretty printers. > > > > Other good examples are && and ||. > > ..wha? But those ARE commutative. Unless you mean with respect to > strictness? > > -Brent > _______________________________________________ > 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/20090701/970f8aa1/attachment.html From tom.davie at gmail.com Wed Jul 1 10:53:05 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Jul 1 10:35:40 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> Message-ID: On 1 Jul 2009, at 16:46, Edward Kmett wrote: > I'm rather fond of the (<>) suggestion, but would be happy with > anything better than mappend! ;) I find it rather ugly, it has a lot of connotations of "does not equals" from other languages. Personally I'm in favor of <+>, simply because it looks most like a circle with a plus in it. Bob From dagit at codersbase.com Wed Jul 1 10:55:02 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed Jul 1 10:37:35 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> Message-ID: On Wed, Jul 1, 2009 at 7:53 AM, Thomas Davie wrote: > > On 1 Jul 2009, at 16:46, Edward Kmett wrote: > > I'm rather fond of the (<>) suggestion, but would be happy with anything >> better than mappend! ;) >> > > I find it rather ugly, it has a lot of connotations of "does not equals" > from other languages. Personally I'm in favor of <+>, simply because it > looks most like a circle with a plus in it. This is my favorite of the suggestions as well. Then again, I don't mind typing mappend. Yay for bikesheds :) Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090701/d361c91e/attachment.html From martijn at van.steenbergen.nl Wed Jul 1 11:03:02 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Jul 1 10:45:44 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: Message-ID: <4A4B7AA6.8060000@van.steenbergen.nl> I suggest you all add your name and vote here: http://doodle.com/4yrfd7qaw5man3rm Perhaps we'll find one of the options is clearly in favor. Martijn. Bryan O'Sullivan wrote: > I've thought for a while that it would be very nice indeed if the Monoid > class had a more concise operator for infix appending than "a `mappend` > b". I wonder if other people are of a similar opinion, and if so, > whether this is worth submitting a libraries@ proposal over. > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From robgreayer at gmail.com Wed Jul 1 11:11:47 2009 From: robgreayer at gmail.com (Robert Greayer) Date: Wed Jul 1 10:54:24 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> Message-ID: <4ec472cb0907010811v434ac162x41748edd7d3a084@mail.gmail.com> I'm sure there's some important historical reason... but why isn't '&' used in something more prominent than the fgl package? I understand why it's not used for bitwise AND in Data.Bits (I assume because the corresponding bitwise '|' operator isn't available), but all the other single-character operators** (in the ASCII range) are used in some core library (if not the Prelude itself). But not '&'. Why? It makes sense (to me) as a Monoid 'append'. ** - according to Hoogle On Wed, Jul 1, 2009 at 10:46 AM, Edward Kmett wrote: > I'm rather fond of the (<>) suggestion, but would be happy with anything > better than mappend! ;) > > -Ed > > On Wed, Jul 1, 2009 at 8:56 AM, Brent Yorgey wrote: >> >> On Wed, Jul 01, 2009 at 12:00:50AM -0400, ajb@spamcop.net wrote: >> > G'day all. >> >> > >> > On Tue, Jun 30, 2009 at 08:02:48PM -0400, Daniel Peebles wrote: >> > >> >> But we don't want to imply it's commutative either. Having something >> >> "bidirectional" like <> or <+> feels more commutative than associative >> >> to me. >> > >> > Quoting John Meacham : >> > >> >> Not really, think of '++', which doesn't commute but is visually >> >> symmetric, or Data.Sequence.<>, or the common use of <> to mean >> >> concatination in pretty printers. >> > >> > Other good examples are && and ||. >> >> ..wha? ?But those ARE commutative. ?Unless you mean with respect to >> strictness? >> >> -Brent >> _______________________________________________ >> 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 ross at soi.city.ac.uk Wed Jul 1 11:14:52 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Wed Jul 1 10:57:26 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> Message-ID: <20090701151452.GA7160@soi.city.ac.uk> On Wed, Jul 01, 2009 at 04:53:05PM +0200, Thomas Davie wrote: > > On 1 Jul 2009, at 16:46, Edward Kmett wrote: > >> I'm rather fond of the (<>) suggestion, but would be happy with >> anything better than mappend! ;) > > I find it rather ugly, it has a lot of connotations of "does not equals" > from other languages. Forget Pascal: think of it as a diamond. From leimy2k at gmail.com Wed Jul 1 11:17:14 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Jul 1 10:59:49 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <4A4B5405.2000509@jellybean.co.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <4A4B5405.2000509@jellybean.co.uk> Message-ID: <3e1162e60907010817v312ae122u42506204d52e5d85@mail.gmail.com> On Wed, Jul 1, 2009 at 5:18 AM, Jules Bean wrote: > Duncan Coutts wrote: > >> I agree, if we can't use ++ then <> is the next best thing. As John says >> it's already a monoid operator for Data.Sequence and Text.PrettyPrint. >> >> > I agree, if we can't use +> and <+ then <> is the next best thing. > > ;) > > Jules I like this thinking as well. I kind of wish Haskell didn't overload operators to begin with but oh well :-) Just because the compiler can figure out what I mean because it has a great type system, I might not be able to figure out what I mean a year from now if I see ++ everywhere. In some sense, I prefer misleading function names to overly overloaded operators. Dave > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090701/b6162ea7/attachment.html From chris at eidhof.nl Wed Jul 1 11:30:44 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Wed Jul 1 11:13:18 2009 Subject: [Haskell-cafe] ORM for haskell? In-Reply-To: <20090630175208.GE6272@gmx.de> References: <20090630175208.GE6272@gmx.de> Message-ID: <2DFE45C5-EC7E-4EC6-AD77-815C9236FE47@eidhof.nl> Hey Marc, On 30 jun 2009, at 19:52, Marc Weber wrote: > Is there anyone interested in helping building a library which > a) let's you define kind of model of you data > b) let's you store you model in any backend (maybe a relational > database) > c) does static checking of your queries at compilation time? > > [...] > Maybe this does already exist and I've missed it? I've something working that sort of does this. You define your model in the following way: data User = User {name :: String, password :: String, age :: Int, post :: BelongsTo Post} data Post = Post {title :: String, body :: String} Then there's some boilerplate code (that ultimately will be generated by TH), and from that moment on you can do things like this: test = do conn <- connectSqlite3 "example.sqlite3" runDB conn $ do user <- fromJust <$> find typeUser 1 user' <- fillBelongsTo user relPost return (post user') By default, no relations will be fetched, but by doing the fillBelongsTo the user will be updated. I currently have support for new, update and find. All of this code is very alpha, and only works using HDBC and Sqlite3, but still. You can find and fork my code on http://github.com/chriseidhof/ generics. I'll be happy to answer any questions about the code or the ideas behind it. -chris From andrewhhunter at gmail.com Wed Jul 1 12:32:43 2009 From: andrewhhunter at gmail.com (Andrew Hunter) Date: Wed Jul 1 12:15:16 2009 Subject: [Haskell-cafe] List spine traversal In-Reply-To: References: <4A482153.1030903@gmail.com> <4A487CB9.5030003@van.steenbergen.nl> <7b501d5c0906290214q4b891cdbhceb45ab7468af487@mail.gmail.com> <87tz1zidz2.fsf@malde.org> <79e6290e0906291936i5c163fc2ude5e244ecc2c65da@mail.gmail.com> <2f9b2d30906292330w746ffe63h2b814fd08fcac58e@mail.gmail.com> <2a774a0c0906301329h2861ee31w95f3c6daf492c631@mail.gmail.com> Message-ID: <2a774a0c0907010932q33aba384m811a27ab49f174ba@mail.gmail.com> 2009/7/1 Matthias G?rgens : >> As a side note, (allowing seq and unsafePerformIO if necessary) is it >> possible to implement a map that preserves cycles (instead of >> transparently replacing them with infinite copies? ?Not horribly >> useful, but would be quite cute. > > Baltasar Trancon y Widemann gave a talk on a generalized version of > this problem at HaL4. ?Short answer: The problem is tractable in > theory, but you need heavy math. > Pretty cool--any paper/slides/transcript/video? AHH From gue.schmidt at web.de Wed Jul 1 13:18:21 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Wed Jul 1 13:01:04 2009 Subject: [Haskell-cafe] ghc static linking on Windows Message-ID: Hi, I tried to compile an app that uses sqlite3.dll with the -optl-static flag and the error message is: C:\ghc\ghc-6.10.3\gcc-lib\ld.exe: cannot find -lsqlite3 collect2: ld returned 1 exit status From briqueabraque at yahoo.com Wed Jul 1 13:22:36 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Wed Jul 1 13:05:23 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <1246445094.28197.1660.camel@localhost> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <20090701015953.GM22067@sliver.repetae.net> <1246445094.28197.1660.camel@localhost> Message-ID: > Yeah, I'm not suggesting going via Storable (for all those reasons), > just extending the FFI to say tuples of FFI types get passed as the > corresponding C ABI structs. All the magic to match the current platform > C ABI then lives in the compiler. Agree. The tuples idea is far better than my first sugestion on Storable instances. > I was only half-serious in suggesting this btw, though as far as I can > see it should actually work. It doesn't help with unions of course and > it adds complexity to the compiler. :( The only known case I have of this beeing important is on GNU GSL, where the complex functions use a complex type defined as a struct (with a size 2 array as the only member). This actually just emulates the 'complex' type of C99, I'm almost sure. Do you imagine an objection on creating a ticket asking for something like CComplex on Foreign.C.Types? Maur?cio From bos at serpentine.com Wed Jul 1 13:55:39 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed Jul 1 13:38:12 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <1246444728.28197.1655.camel@localhost> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> Message-ID: On Wed, Jul 1, 2009 at 3:38 AM, Duncan Coutts wrote: > > I agree, if we can't use ++ then <> is the next best thing. Okay, here's a tentative plan that will help to figure out the answer. I'll build a fiddled base package that rewires the Monoid class to have (++) be the binary operator, and mappend as a synonym for it. I'll import the Monoid (++) into the Prelude. I'll see how much breaks. If that much builds smoothly, I'll see how much of the rest of Hackage builds, both with and without this custom base package. I'll follow up here with the results, along with a suggestion of how acceptable I think the observed level of breakage is. Seem reasonable? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090701/c96a1c1f/attachment.html From huschi at gmx.org Wed Jul 1 14:17:50 2009 From: huschi at gmx.org (Martin Huschenbett) Date: Wed Jul 1 14:00:23 2009 Subject: [Haskell-cafe] List spine traversal In-Reply-To: <2a774a0c0907010932q33aba384m811a27ab49f174ba@mail.gmail.com> References: <4A482153.1030903@gmail.com> <4A487CB9.5030003@van.steenbergen.nl> <7b501d5c0906290214q4b891cdbhceb45ab7468af487@mail.gmail.com> <87tz1zidz2.fsf@malde.org> <79e6290e0906291936i5c163fc2ude5e244ecc2c65da@mail.gmail.com> <2f9b2d30906292330w746ffe63h2b814fd08fcac58e@mail.gmail.com> <2a774a0c0906301329h2861ee31w95f3c6daf492c631@mail.gmail.com> <2a774a0c0907010932q33aba384m811a27ab49f174ba@mail.gmail.com> Message-ID: <4A4BA84E.6060305@gmx.org> Hi Andrew, you will find it there but it's written in German. http://opus.kobv.de/tuberlin/volltexte/2008/1755/ Regards, Martin. Andrew Hunter schrieb: > 2009/7/1 Matthias G?rgens : >>> As a side note, (allowing seq and unsafePerformIO if necessary) is it >>> possible to implement a map that preserves cycles (instead of >>> transparently replacing them with infinite copies? Not horribly >>> useful, but would be quite cute. >> Baltasar Trancon y Widemann gave a talk on a generalized version of >> this problem at HaL4. Short answer: The problem is tractable in >> theory, but you need heavy math. >> > > Pretty cool--any paper/slides/transcript/video? > > AHH > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From leimy2k at gmail.com Wed Jul 1 14:24:01 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Jul 1 14:06:33 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> Message-ID: <3e1162e60907011124k7d06377dw4096e1fd7da55f6e@mail.gmail.com> On Wed, Jul 1, 2009 at 10:55 AM, Bryan O'Sullivan wrote: > On Wed, Jul 1, 2009 at 3:38 AM, Duncan Coutts > wrote: > >> >> I agree, if we can't use ++ then <> is the next best thing. > > > Okay, here's a tentative plan that will help to figure out the answer. I'll > build a fiddled base package that rewires the Monoid class to have (++) be > the binary operator, and mappend as a synonym for it. I'll import the Monoid > (++) into the Prelude. I'll see how much breaks. If that much builds > smoothly, I'll see how much of the rest of Hackage builds, both with and > without this custom base package. I'll follow up here with the results, > along with a suggestion of how acceptable I think the observed level of > breakage is. > > Seem reasonable? > It's more reasonable than sitting around waxing philosophical on the notation I suppose :-) > > > _______________________________________________ > 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/20090701/fd2764d6/attachment.html From ross at soi.city.ac.uk Wed Jul 1 14:26:51 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Wed Jul 1 14:09:25 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> Message-ID: <20090701182651.GA9344@soi.city.ac.uk> On Wed, Jul 01, 2009 at 10:55:39AM -0700, Bryan O'Sullivan wrote: > Okay, here's a tentative plan that will help to figure out the answer. I'll > build a fiddled base package that rewires the Monoid class to have (++) be the > binary operator, and mappend as a synonym for it. I'll import the Monoid (++) > into the Prelude. I'll see how much breaks. If that much builds smoothly, I'll > see how much of the rest of Hackage builds, both with and without this custom > base package. I'll follow up here with the results, along with a suggestion of > how acceptable I think the observed level of breakage is. Generalizing (++) will break some Haskell 98 code, e.g. append = (++) I think that's a show-stopper. From martijn at van.steenbergen.nl Wed Jul 1 14:44:53 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Jul 1 14:27:29 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701182651.GA9344@soi.city.ac.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> Message-ID: <4A4BAEA5.3030407@van.steenbergen.nl> Ross Paterson wrote: > Generalizing (++) will break some Haskell 98 code, e.g. > > append = (++) > > I think that's a show-stopper. Is the monomorphism restriction the only situation in which stuff breaks? Martijn. From matthias.goergens at googlemail.com Wed Jul 1 14:58:39 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Jul 1 14:41:12 2009 Subject: [Haskell-cafe] List spine traversal In-Reply-To: <4A4BA84E.6060305@gmx.org> References: <4A482153.1030903@gmail.com> <4A487CB9.5030003@van.steenbergen.nl> <7b501d5c0906290214q4b891cdbhceb45ab7468af487@mail.gmail.com> <87tz1zidz2.fsf@malde.org> <79e6290e0906291936i5c163fc2ude5e244ecc2c65da@mail.gmail.com> <2f9b2d30906292330w746ffe63h2b814fd08fcac58e@mail.gmail.com> <2a774a0c0906301329h2861ee31w95f3c6daf492c631@mail.gmail.com> <2a774a0c0907010932q33aba384m811a27ab49f174ba@mail.gmail.com> <4A4BA84E.6060305@gmx.org> Message-ID: > you will find it there but it's written in German. Yes. But at least there's an English abstract. Matthias. From nominolo at googlemail.com Wed Jul 1 15:30:40 2009 From: nominolo at googlemail.com (Thomas Schilling) Date: Wed Jul 1 15:13:15 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <4A4B7AA6.8060000@van.steenbergen.nl> References: <4A4B7AA6.8060000@van.steenbergen.nl> Message-ID: <916b84820907011230q252e0ebs35b703735ffc6336@mail.gmail.com> 2009/7/1 Martijn van Steenbergen : > I suggest you all add your name and vote here: > > ? http://doodle.com/4yrfd7qaw5man3rm > > Perhaps we'll find one of the options is clearly in favor. Doesn't doodle allow multiple choice tests? Requiring to pick only one is kind of skewing the results towards the possibly not backwards compatible (++). > > Martijn. > > > Bryan O'Sullivan wrote: >> >> I've thought for a while that it would be very nice indeed if the Monoid >> class had a more concise operator for infix appending than "a `mappend` b". >> I wonder if other people are of a similar opinion, and if so, whether this >> is worth submitting a libraries@ proposal over. >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> 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 > -- Push the envelope. Watch it bend. From nominolo at googlemail.com Wed Jul 1 15:32:03 2009 From: nominolo at googlemail.com (Thomas Schilling) Date: Wed Jul 1 15:14:36 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701151452.GA7160@soi.city.ac.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> <20090701151452.GA7160@soi.city.ac.uk> Message-ID: <916b84820907011232n7a5cf1f2gd364c2631e1b8e61@mail.gmail.com> 2009/7/1 Ross Paterson : >>> I'm rather fond of the (<>) suggestion, but would be happy with >>> anything better than mappend! ;) >> >> I find it rather ugly, it has a lot of connotations of "does not equals" >> from other languages. > > Forget Pascal: think of it as a diamond. Yep, it's definitely a diamond. -- Push the envelope. Watch it bend. From nominolo at googlemail.com Wed Jul 1 15:38:21 2009 From: nominolo at googlemail.com (Thomas Schilling) Date: Wed Jul 1 15:20:56 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <3e1162e60907010817v312ae122u42506204d52e5d85@mail.gmail.com> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <4A4B5405.2000509@jellybean.co.uk> <3e1162e60907010817v312ae122u42506204d52e5d85@mail.gmail.com> Message-ID: <916b84820907011238h23c57d02u546b8d04ff98f013@mail.gmail.com> 2009/7/1 David Leimbach > I like this thinking as well. ?I kind of wish Haskell didn't overload > operators to begin with but oh well :-) > Just because the compiler can figure out what I mean because it has a great > type system, I might not be able to figure out what I mean a year from now > if I see ++ everywhere. > In some sense, I prefer misleading function names to overly overloaded > operators. Yep, had the same experience. On the one hand, using monoids lets you delay some design decisions for later and lets you reuse more library code. On the other hand, it sometimes makes it really hard to see what the code is actually doing--especially if you use more than one monoid. For this reason on of the first advanced features I implemented in the (yet unreleased) scion IDE library allows you to look up the instantiated type of an identifier. Unfortunately, jumping to the definition (or documentation) of the monoid instance is a bit more difficult. Haddock should allow documentation on instance declarations... > Dave > >> >> _______________________________________________ >> 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 > > -- Push the envelope. Watch it bend. From martijn at van.steenbergen.nl Wed Jul 1 15:55:34 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Jul 1 15:38:13 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <916b84820907011238h23c57d02u546b8d04ff98f013@mail.gmail.com> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <4A4B5405.2000509@jellybean.co.uk> <3e1162e60907010817v312ae122u42506204d52e5d85@mail.gmail.com> <916b84820907011238h23c57d02u546b8d04ff98f013@mail.gmail.com> Message-ID: <4A4BBF36.9090500@van.steenbergen.nl> Thomas Schilling wrote: > Haddock should allow documentation on instance > declarations... +1! From cetin.sert at gmail.com Wed Jul 1 16:14:57 2009 From: cetin.sert at gmail.com (Cetin Sert) Date: Wed Jul 1 15:57:51 2009 Subject: [Haskell-cafe] Happy GLR mode build failures Message-ID: <1ff5dedc0907011314r70e02994g7c875ac7cdf0a24e@mail.gmail.com> Hi, It's not possible to build the Happy glr examples using GHC 6.10.3 and Happy 1.18.4: cetin@unique:~/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr$ make make loop CMD=run make[1]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr' for d in expr-eval expr-tree expr-monad hidden-leftrec highly-ambiguous packing nlp bio-eg; do (cd $d && make run); done make[2]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/expr-eval' # might want to run happy with --ghc ghc -I../common -i../common -package data -O -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Error 1 make[2]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/expr-eval' make[2]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/expr-tree' # might want to run happy with --ghc ghc -I../common -i../common -package data -O2 -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Error 1 make[2]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/expr-tree' make[2]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/expr-monad' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Error 1 make[2]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/expr-monad' make[2]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/hidden-leftrec' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Error 1 make[2]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/hidden-leftrec' make[2]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/highly-ambiguous' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Error 1 make[2]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/highly-ambiguous' make[2]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/packing' Makefile:8: warning: overriding commands for target `.y.hs' ../Makefile.defs:15: warning: ignoring old commands for target `.y.hs' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Error 1 make[2]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/packing' make[2]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/nlp' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o english --make Main.lhs : unknown package: data make[2]: *** [english] Error 1 make[2]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/nlp' make[2]: Entering directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/bio-eg' Making BioData.hs WITHOUT optimisation (for speed) ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -funfolding-use-threshold0 -fno-strictness -c BioData.hs : unknown package: data make[2]: *** [BioData.hi] Error 1 make[2]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr/bio-eg' make[1]: *** [loop] Error 2 make[1]: Leaving directory `/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr' make: *** [all] Error 2 cetin@unique:~/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr$ cabal update Downloading the latest package list from hackage.haskell.org cetin@unique:~/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr$ cabal install data cabal: There is no package named data cetin@unique:~/.cabal/packages/ hackage.haskell.org/happy/1.18.4/happy-1.18.4/examples/glr$ happy --version; ghc --version Happy Version 1.18.4 Copyright (c) 1993-1996 Andy Gill, Simon Marlow (c) 1997-2005 Simon Marlow Happy is a Yacc for Haskell, and comes with ABSOLUTELY NO WARRANTY. This program is free software; you can redistribute it and/or modify it under the terms given in the file 'LICENSE' distributed with the Happy sources. The Glorious Glasgow Haskell Compilation System, version 6.10.3 or GHC 6.10.1 and Happy 1.18.2: cetin@sweethome:~/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr$ makemake loop CMD=run make[1]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr' for d in expr-eval expr-tree expr-monad hidden-leftrec highly-ambiguous packing nlp bio-eg; do (cd $d && make run); done make[2]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/expr-eval' # might want to run happy with --ghc ghc -I../common -i../common -package data -O -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Fehler 1 make[2]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/expr-eval' make[2]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/expr-tree' # might want to run happy with --ghc ghc -I../common -i../common -package data -O2 -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Fehler 1 make[2]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/expr-tree' make[2]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/expr-monad' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Fehler 1 make[2]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/expr-monad' make[2]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/hidden-leftrec' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Fehler 1 make[2]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/hidden-leftrec' make[2]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/highly-ambiguous' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Fehler 1 make[2]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/highly-ambiguous' make[2]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/packing' Makefile:8: Warnung: Die Befehle f?r das Ziel ?.y.hs? werden ?berschrieben ../Makefile.defs:15: Warnung: Alte Befehle f?r das Ziel ?.y.hs? werden ignoriert ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o expr --make Main.lhs : unknown package: data make[2]: *** [expr] Fehler 1 make[2]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/packing' make[2]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/nlp' ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -o english --make Main.lhs : unknown package: data make[2]: *** [english] Fehler 1 make[2]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/nlp' make[2]: Betrete Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/bio-eg' Making BioData.hs WITHOUT optimisation (for speed) ghc -I../common -i../common -package data -cpp -fglasgow-exts -package lang -funfolding-use-threshold0 -fno-strictness -c BioData.hs : unknown package: data make[2]: *** [BioData.hi] Fehler 1 make[2]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr/bio-eg' make[1]: *** [loop] Fehler 2 make[1]: Verlasse Verzeichnis '/home/cetin/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr' make: *** [all] Fehler 2 cetin@sweethome:~/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr$ happy --version; ghc --version Happy Version 1.18.2 Copyright (c) 1993-1996 Andy Gill, Simon Marlow (c) 1997-2005 Simon Marlow Happy is a Yacc for Haskell, and comes with ABSOLUTELY NO WARRANTY. This program is free software; you can redistribute it and/or modify it under the terms given in the file 'LICENSE' distributed with the Happy sources. The Glorious Glasgow Haskell Compilation System, version 6.10.1 When I try to manually build something out of a .y file, I keep getting: cetin@sweethome:~/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr$ find | grep -E "y$" | xargs -n 1 echo happy -gcal happy -gcal ./packing/Expr.y happy -gcal ./highly-ambiguous/Expr.y happy -gcal ./expr-eval/Expr.y happy -gcal ./expr-monad/Expr.y happy -gcal ./nlp/English.y happy -gcal ./hidden-leftrec/Expr.y happy -gcal ./expr-tree/Expr.y happy -gcal ./bio-eg/Bio.y cetin@sweethome:~/.cabal/packages/ hackage.haskell.org/happy/1.18.2/happy-1.18.2/examples/glr$ find | grep -E "y$" | xargs -n 1 happy -gcal reduce/reduce conflicts: 2 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 7 reduce/reduce conflicts: 1 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 9 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 9 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 2 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 4 reduce/reduce conflicts: 1 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) shift/reduce conflicts: 9 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) unused rules: 20 shift/reduce conflicts: 35 reduce/reduce conflicts: 68 happy: src/ProduceGLRCode.lhs:190:11-76: Irrefutable pattern failed for pattern (pre, drop_me : post) Does anyone have solution for this? The irrefutable pattern failure issue is especially bothersome for me as I ran into it in a Fortran grammar I'm writing and got stuck. Best Regards, Cetin Sert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090701/517fc43b/attachment.html From shinnonoir at gmail.com Wed Jul 1 16:17:13 2009 From: shinnonoir at gmail.com (Raynor Vliegendhart) Date: Wed Jul 1 15:59:50 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: Message-ID: <6d961e560907011317p281e84dbr5082ff071f272041@mail.gmail.com> On Tue, Jun 30, 2009 at 6:45 PM, Bryan O'Sullivan wrote: > I've thought for a while that it would be very nice indeed if the Monoid > class had a more concise operator for infix appending than "a `mappend` b". > I wonder if other people are of a similar opinion, and if so, whether this > is worth submitting a libraries@ proposal over. > We could use (Control.Category..) as an operator, but this would require an additional wrapping layer if we wish to use the existing Monoid instances: > import Prelude hiding (id, (.)) > import Control.Category > import Data.Monoid > > -- Category wrapper for existing Monoid instances > newtype MonoidC m a b = MonoidC {unwrapMC :: m} deriving (Show) > > instance Monoid m => Category (MonoidC m) where > id = MonoidC mempty > MonoidC m . MonoidC n = MonoidC $ m `mappend` n Furthermore, writing Category instances for monoids require dummy type parameters: > -- Example instance > newtype SumC m a b = SumC {getSumC :: m} deriving (Show, Eq) > > instance Num a => Category (SumC a) where > id = SumC (fromIntegral 0) > SumC x . SumC y = SumC $ x + y Another disadvantage of this approach is that we cannot have a default monoid instance for lists (kind mismatch). From john at repetae.net Wed Jul 1 17:07:58 2009 From: john at repetae.net (John Meacham) Date: Wed Jul 1 16:50:32 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <20090701015953.GM22067@sliver.repetae.net> <1246445094.28197.1660.camel@localhost> Message-ID: <20090701210758.GN22067@sliver.repetae.net> On Wed, Jul 01, 2009 at 02:22:36PM -0300, Maur??cio wrote: >> Yeah, I'm not suggesting going via Storable (for all those reasons), >> just extending the FFI to say tuples of FFI types get passed as the >> corresponding C ABI structs. All the magic to match the current platform >> C ABI then lives in the compiler. > > Agree. The tuples idea is far better than my first sugestion > on Storable instances. > >> I was only half-serious in suggesting this btw, though as far as I can >> see it should actually work. It doesn't help with unions of course and >> it adds complexity to the compiler. > > :( > > The only known case I have of this beeing important is on GNU GSL, > where the complex functions use a complex type defined as a struct > (with a size 2 array as the only member). This actually just > emulates the 'complex' type of C99, I'm almost sure. I don't know whether it is required that Complex be represented in such a way though. > Do you imagine an objection on creating a ticket asking for > something like CComplex on Foreign.C.Types? No, I would like it. Also add a 'CBool' that maps to the calling convention for _Bool while you are at it. You would need CComplexFloat and CComplexDouble... or perhaps we should just define that 'Complex CFloat' and 'Complex CDouble' are FFI-able types in the obvious way. that is probably better actually. Another FFI related extension I have wanted at times is making user defined types that derive an 'Enum' instance FFI-able, with an 'int' calling convention, translated via toEnum and fromEnum. -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From nominolo at googlemail.com Wed Jul 1 17:09:07 2009 From: nominolo at googlemail.com (Thomas Schilling) Date: Wed Jul 1 16:51:40 2009 Subject: [Haskell-cafe] Suggestions for simulating Object ID In-Reply-To: <2f9b2d30906300944h566e2b55sc97c32abb48f780c@mail.gmail.com> References: <60d0a32f0906300255re231ddbsc13e48e02f631601@mail.gmail.com> <20090630123109.GB31294@kira.casa> <60d0a32f0906300727x59b4394ekcd35ae2e5f4cb444@mail.gmail.com> <20090630161615.GB1823@kira.casa> <2f9b2d30906300944h566e2b55sc97c32abb48f780c@mail.gmail.com> Message-ID: <916b84820907011409n3bbed005g44de034c2235a3e1@mail.gmail.com> This is implemented in Data.Supply (http://hackage.haskell.org/package/value-supply). The difference is: Data.Unique is *globally* unique, while Data.Supply is only locally unique. I ran into problems with this when writing tests. 2009/6/30 Ryan Ingram : > On Tue, Jun 30, 2009 at 9:16 AM, Felipe Lessa wrote: >> On Tue, Jun 30, 2009 at 07:57:07PM +0530, Hemanth Kapila wrote: >>> Can't we come up with something like this staying within the >>> limits of purity? >> >> No, because that would break referential transparency :(. ?I.e., >> it would be possible to distinguish things that should be >> "equal", such as '3' from '1+2'. > > This isn't entirely true; you can do something like this: > >> newtype Unique = U Integer deriving (Eq) >> newtype UniqueM a = UniqueM (State Integer a) deriving Monad >> runUniqueM (UniqueM a) = evalState a 0 > >> newUnique = UniqueM $ do >> ? ?u <- get >> ? ?put $! (u+1) >> ? ?return (U u) > > Also, if you are willing to go inside of IO/ST for some bits of your > code, you can use some tricks with unsafeInterleaveIO/ST to create > data structures with unique ids that only get created if they are > used; this allows creating infinite data structures and still keeping > object ID. ?The returned data structure is still pure if the "U" > constructor is hidden; all we can do is compare uniques for equality. > You can relax this slightly by adding an Ord derivation; this > technically allows you to observe creation order for the uniques which > is wrong, but it's quite useful to be able to use Uniques as map keys. > >> data Tree a = Tree a (Tree a) (Tree a) >> infTree :: IO (Tree Unique) >> infTree = do >> ? ?r <- newIORef 0 >> ? ?mkTree r >> mkTree :: IORef Integer -> IO (Tree Unique) >> mkTree r = unsafeInterleaveIO $ do >> ? ? v <- readIORef r >> ? ? writeIORef r $! (v+1) >> ? ? l <- mkTree r >> ? ? r <- mkTree r >> ? ? return (Tree (U v) l r) > > I believe GHC uses this technique internally. > > ?-- ryan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Push the envelope. Watch it bend. From bulat.ziganshin at gmail.com Wed Jul 1 17:26:12 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jul 1 17:10:59 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <1246321112.28197.858.camel@localhost> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> Message-ID: <434008226.20090702012612@gmail.com> Hello Duncan, Tuesday, June 30, 2009, 4:18:32 AM, you wrote: > Actually passing structs and unions as arguments or function results is > specified by the C ABI. See for example the IA32 ABI: > http://www.caldera.com/developers/devspecs/abi386-4.pdf > linked from the LSB: > http://refspecs.linux-foundation.org/LSB_3.1.0/LSB-Core-IA32/LSB-Core-IA32/normativerefs.html sorry, it's "System V ABI, IA32 Supplement" so situation is still the same - afaik, there is no common ABI for all C compilers on x86 platform that describes structures passing and alignment -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From duncan.coutts at worc.ox.ac.uk Wed Jul 1 18:57:29 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 1 18:39:54 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <434008226.20090702012612@gmail.com> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <434008226.20090702012612@gmail.com> Message-ID: <1246489049.7418.12.camel@localhost> On Thu, 2009-07-02 at 01:26 +0400, Bulat Ziganshin wrote: > Hello Duncan, > > Tuesday, June 30, 2009, 4:18:32 AM, you wrote: > > > Actually passing structs and unions as arguments or function results is > > specified by the C ABI. See for example the IA32 ABI: > > > http://www.caldera.com/developers/devspecs/abi386-4.pdf > > > linked from the LSB: > > http://refspecs.linux-foundation.org/LSB_3.1.0/LSB-Core-IA32/LSB-Core-IA32/normativerefs.html > > sorry, it's "System V ABI, IA32 Supplement" > > so situation is still the same - afaik, there is no common ABI for all > C compilers on x86 platform that describes structures passing and alignment You don't need it to be the same between Windows and Unix, it just has to be standard on each platform, which it is. There are really only two ABIs in common use on x86, the System V ABI and the MS one (which apart from the stdcall calling convention only differs in the bitfield layout iirc). But within each platform it most definitely is the same between C compilers[*], that's the whole point. These days there's even a standard C++ ABI. That took ages to standardise, the C one has been around for much much longer. Duncan [*] On Windows gcc can do both normal and MS layout of bitfields. From bulat.ziganshin at gmail.com Wed Jul 1 19:01:48 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jul 1 18:44:28 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <1246489049.7418.12.camel@localhost> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <434008226.20090702012612@gmail.com> <1246489049.7418.12.camel@localhost> Message-ID: <1125425151.20090702030148@gmail.com> Hello Duncan, Thursday, July 2, 2009, 2:57:29 AM, you wrote: > You don't need it to be the same between Windows and Unix, it just has > to be standard on each platform, which it is. There are really only two > ABIs in common use on x86, the System V ABI and the MS one (which apart > from the stdcall calling convention only differs in the bitfield layout > iirc). you mean that on windows gcc, msvc and all other C compilers use the same ABI for passing and packing structs? (at least it does noting common to document you shown, it says about SysV ABI, that may be common for all modern unicies - i don't know) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From duncan.coutts at worc.ox.ac.uk Wed Jul 1 19:46:56 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 1 19:31:50 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <1125425151.20090702030148@gmail.com> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <434008226.20090702012612@gmail.com> <1246489049.7418.12.camel@localhost> <1125425151.20090702030148@gmail.com> Message-ID: <1246492016.7418.19.camel@localhost> On Thu, 2009-07-02 at 03:01 +0400, Bulat Ziganshin wrote: > Hello Duncan, > > Thursday, July 2, 2009, 2:57:29 AM, you wrote: > > > You don't need it to be the same between Windows and Unix, it just has > > to be standard on each platform, which it is. There are really only two > > ABIs in common use on x86, the System V ABI and the MS one (which apart > > from the stdcall calling convention only differs in the bitfield layout > > iirc). > > you mean that on windows gcc, msvc and all other C compilers use the > same ABI for passing and packing structs? When using the gcc option -mms-bitfields then yes, gcc and msvc use the same ABI for packing structs. As the name suggests, the only difference otherwise is that MSVC uses a non-standard layout for bitfields, but since it's the de-facto native compiler it kind of defines the native C ABI. So as it happens this isn't relevant for the FFI because it does not support bitfields. Duncan From briqueabraque at yahoo.com Wed Jul 1 20:05:06 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Wed Jul 1 19:47:51 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <20090701210758.GN22067@sliver.repetae.net> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <20090701015953.GM22067@sliver.repetae.net> <1246445094.28197.1660.camel@localhost> <20090701210758.GN22067@sliver.repetae.net> Message-ID: >> Do you imagine an objection on creating a ticket asking for >> something like CComplex on Foreign.C.Types? > > No, I would like it. Also add a 'CBool' that maps to the calling > convention for _Bool while you are at it. Here is a draft. Please comment: Proposal: complement Foreign.C.Types A few more types could be usefull in Foreign.C.Types. These are sugested to be included: * CBool Related to 'bool' (or _Bool) from stdbool.h. * CComplexFloat, CComplexDouble Related to 'float complex' and 'double complex'. Pros: Cons: From john at repetae.net Wed Jul 1 20:24:31 2009 From: john at repetae.net (John Meacham) Date: Wed Jul 1 20:07:04 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: References: <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <20090701015953.GM22067@sliver.repetae.net> <1246445094.28197.1660.camel@localhost> <20090701210758.GN22067@sliver.repetae.net> Message-ID: <20090702002431.GO22067@sliver.repetae.net> On Wed, Jul 01, 2009 at 09:05:06PM -0300, Maur??cio wrote: >>> Do you imagine an objection on creating a ticket asking for >>> something like CComplex on Foreign.C.Types? >> >> No, I would like it. Also add a 'CBool' that maps to the calling >> convention for _Bool while you are at it. > > Here is a draft. Please comment: > > > > Proposal: complement Foreign.C.Types > > A few more types could be usefull in Foreign.C.Types. These > are sugested to be included: > > * CBool > Related to 'bool' (or _Bool) from stdbool.h. Good. It appears from the FFI spec that it is possible to define HsBool as '_Bool' and let 'Bool' translate to a 'bool' calling convention. However, it is not guarenteed so a CBool type that is guarenteed to map to _Bool is still good. It would be odd to define CBool as an intergral type though, perhaps we should specify it be defined as newtype CBool = CBool Bool so we can convert between haskell Bool and CBool easily. Though, for consistency with other C types, we may want to > * CComplexFloat, CComplexDouble > Related to 'float complex' and 'double complex'. We need a way to actually examine the values, since 'fromIntegral' won't work. I think the easiest way is to actually reuse Complex which is already in Haskell 98, defining Complex Foo where Foo is a FFI marshable type translates to the complex version of said type. so 'Complex CDouble' translates to the external C type of 'double complex'. We may also want to add 'long double' as a c marshable type too. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From geoffrey.marchant at gmail.com Wed Jul 1 22:24:59 2009 From: geoffrey.marchant at gmail.com (Geoffrey Marchant) Date: Wed Jul 1 22:07:50 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701182651.GA9344@soi.city.ac.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> Message-ID: <79e6290e0907011924t16bb131bwd4697e1aa0a47a35@mail.gmail.com> Obviously `mappend` is good enough as it is. Choosing (+>) or (<>) are just for prettifying code. Generalizing (++) not only makes the code prettier, but also brings Monoid into the Prelude. You can either Do It Right(tm), or be conservative and try to maintain backwards compatibility as much as possible. I suspect most people in the community understand the trade-offs here, and would agree on the proper solution. If that means rewriting the standard, then so be it. On Wed, Jul 1, 2009 at 12:26 PM, Ross Paterson wrote: > On Wed, Jul 01, 2009 at 10:55:39AM -0700, Bryan O'Sullivan wrote: > > Okay, here's a tentative plan that will help to figure out the answer. > I'll > > build a fiddled base package that rewires the Monoid class to have (++) > be the > > binary operator, and mappend as a synonym for it. I'll import the Monoid > (++) > > into the Prelude. I'll see how much breaks. If that much builds smoothly, > I'll > > see how much of the rest of Hackage builds, both with and without this > custom > > base package. I'll follow up here with the results, along with a > suggestion of > > how acceptable I think the observed level of breakage is. > > Generalizing (++) will break some Haskell 98 code, e.g. > > append = (++) > > I think that's a show-stopper. > _______________________________________________ > 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/20090701/0126d3c4/attachment.html From briqueabraque at yahoo.com Wed Jul 1 22:40:19 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Wed Jul 1 22:23:02 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <20090702002431.GO22067@sliver.repetae.net> References: <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <20090701015953.GM22067@sliver.repetae.net> <1246445094.28197.1660.camel@localhost> <20090701210758.GN22067@sliver.repetae.net> <20090702002431.GO22067@sliver.repetae.net> Message-ID: >> * CComplexFloat, CComplexDouble >> Related to 'float complex' and 'double complex'. > > We need a way to actually examine the values, since 'fromIntegral' won't > work. I think the easiest way is to actually reuse Complex which is > already in Haskell 98, defining What do you think of newtype CComplexFloat = CComplexFloat {crealf, cimagf :: CFloat} 'crealf' and 'cimagf' actually belong to the standard, and are supposed to be used to read the real and imaginary part of a float complex. There are also 'creal', 'cimag', 'creall', 'cimagl' that we would use in CComplexDouble and CComplexLDouble. > We may also want to add 'long double' as a c marshable type too. I think it's already there. Isn't it CLDouble? Maur?cio From dave at zednenem.com Thu Jul 2 01:11:00 2009 From: dave at zednenem.com (David Menendez) Date: Thu Jul 2 00:53:31 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <916b84820907011238h23c57d02u546b8d04ff98f013@mail.gmail.com> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <4A4B5405.2000509@jellybean.co.uk> <3e1162e60907010817v312ae122u42506204d52e5d85@mail.gmail.com> <916b84820907011238h23c57d02u546b8d04ff98f013@mail.gmail.com> Message-ID: <49a77b7a0907012211w5570a8fmdeabeea5d3b18dec@mail.gmail.com> In Wed, Jul 1, 2009 at 3:38 PM, Thomas Schilling wrote: > 2009/7/1 David Leimbach >> Just because the compiler can figure out what I mean because it has a great >> type system, I might not be able to figure out what I mean a year from now >> if I see ++ everywhere. > Yep, had the same experience. ?On the one hand, using monoids lets you > delay some design decisions for later and lets you reuse more library > code. ?On the other hand, it sometimes makes it really hard to see > what the code is actually doing--especially if you use more than one > monoid. > > For this reason on of the first advanced features I implemented in the > (yet unreleased) scion IDE library allows you to look up the > instantiated type of an identifier. ?Unfortunately, jumping to the > definition (or documentation) of the monoid instance is a bit more > difficult. ?Haddock should allow documentation on instance > declarations... I disagree. The solution is to not create instances when it isn't obvious what the instance does. That's why we have Sum and Prod in Data.Monoid instead of declaring instances directly for Int. With Monoid, I'd go further and say that you should not use mempty and mappend unless you are writing polymorphic code. If you are writing to a specific monoid instance, you should use a specific function. -- Dave Menendez From mxcantor at gmail.com Thu Jul 2 01:26:01 2009 From: mxcantor at gmail.com (Max Cantor) Date: Thu Jul 2 01:08:54 2009 Subject: [Haskell-cafe] Leksah works! In-Reply-To: <3e1162e60906300903m61f80f85sf940408712d23b70@mail.gmail.com> References: <5e0214850906292215q77f12853j311ec1e327ff7208@mail.gmail.com> <24272909.post@talk.nabble.com> <3e1162e60906300903m61f80f85sf940408712d23b70@mail.gmail.com> Message-ID: I emphatically second this.. (except for using vim instead of emacs) -Max On Jul 1, 2009, at 12:03 AM, David Leimbach wrote: > I would love to have a standalone Mac OS X compatible build to try. > As it stands, I have not been successful getting a Cocoa/Carbon GTK > running on Leopard, and can't afford the time to fight with making > it work. > > I too typically use Emacs, but also like to use Yi once in a while > as well. > > Dave > > On Tue, Jun 30, 2009 at 7:28 AM, jutaro wrote: > > As Leksah developer I approve your comment. > > Even better we will soon have a new release that integrates GHCi and a > !visual debugger! plus other useful features like much enhanced text > search > with regex and grep and enhanced GUI framework with a tentative > support > for multiple screens. So stay tuned and we appreciate help of any > kind. > > J?rgen > > > jkff wrote: > > > > Hi. > > Quite a while ago I launched Leksah and couldn't get anything done > at > > all; so I thought it is probably never be completed and abandoned > > attempts to find an IDE for Haskell. > > > > However, 3 days ago I launched the new version and it works > fantastic! > > It has an IntelliSense popup with type annotations, a module > browser, > > build-on-the-fly and other things, even though I used it only for 15 > > minutes (then the ICFP contest began, where I wrote in Python and > > Java). > > > > Main point: It seems a vastly more convenient IDE for Haskell than > vim > > (don't know about emacs-mode). > > > > So, I'd like to encourage haskellers to install it and give it a > try :) > > > > -- > > Eugene Kirpichov > > Web IR developer, market.yandex.ru > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > View this message in context: http://www.nabble.com/Leksah-works%21-tp24266240p24272909.html > Sent from the Haskell - Haskell-Cafe mailing list archive at > Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ttencate at gmail.com Thu Jul 2 05:40:59 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Thu Jul 2 05:23:32 2009 Subject: [Haskell-cafe] ghc static linking on Windows In-Reply-To: References: Message-ID: You cannot link statically to a .dll file. Either link statically with the so-called "import library" (.lib) (there are tools to generate one from a .dll, I believe), or link statically with a static build of SQLite, which is also a .lib file. Hope that helps, Thomas On Wed, Jul 1, 2009 at 19:18, G??nther Schmidt wrote: > Hi, > > I tried to compile an app that uses sqlite3.dll with the -optl-static flag > and the error message is: > > C:\ghc\ghc-6.10.3\gcc-lib\ld.exe: cannot find -lsqlite3 > collect2: ld returned 1 exit status > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jon.fairbairn at cl.cam.ac.uk Thu Jul 2 06:36:09 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Thu Jul 2 06:18:59 2009 Subject: [Haskell-cafe] golf, predicate check function for MonadPlus (was Re: How to read safely?) References: <3bd412d40906240240q13fd4cf4oc7062cd08ae72fb@mail.gmail.com> <200906240556.17953.dan.doel@gmail.com> Message-ID: Dan Doel writes: > There was talk of adding a readMaybe a while ago, but apparently it > never happened. > > As it is, you can use reads, "read s" becomes: > > case reads s of > [(a, rest)] | all isSpace rest -> > _ -> > > which ensures that you have an unambiguous parse with only trailing > whitespace. You can, of course, modify that if you don't care about > ambiguity or trailing characters. I was wondering about a more algebraic way of writing that; here's a version (that doesn't care about ambiguity) readMaybe :: Read a => String -> Maybe a readMaybe = join . fmap no_trailing_garbage . listToMaybe . reads where no_trailing_garbage = fmap fst . check (all isSpace . snd) check :: (MonadPlus m) => (a -> Bool) -> a -> m a check p a | p a = return a | otherwise = mzero I tried Hoogling for a function like check, but couldn't find it. Surely there's one in a library somewhere? It looks useful to me. (I'm rather taken by way the "check (all isSpace . snd)" part reads) Monad.guard comes close but fails to get the cigar; in fact guard b == check (const b) () So check is more general. Also, I don't see a singletonListToMaybe that one could use in place of listToMaybe to require unambiguity. Could do isSingleton [a] = True isSingleton _ = False and then use "listToMaybe . join . check isSingleton" -- aha! Another use for check! J?n [Footnote: I thought of writing "guard == flip (check . const) ()" but then realised it was pointless] -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From uzytkownik2 at gmail.com Thu Jul 2 07:31:59 2009 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Thu Jul 2 07:14:33 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers Message-ID: <1246534319.28235.197.camel@notebook.piechotka.com.pl> 1. Learning haskell I discovered that I/O should be avoided nearly 'at all costs'. The problem is that the IO monad is the only one which have more interactive work flow. There is Reader/Writer monad but in fact AFAIU first one is about the environment and second one is about logging. Implementation of Writer can be defined in terms of handles but it is rather limited (either non-full implementation which may be confusing or need of caching the result for pass etc.). I searched the hackage but I didn't find package with pure I/O. Such package may look like: class (Monad m, Monoid v) => MonadInput v m where -- | Gets an element from input (line of text [with \n], 4096 bytes, -- or something like that). mzero on end getChunk :: m v class (Monad m, Monoid v) => MonadOutput v m where -- | Puts an element putChunk :: v -> m () In similar way filters (for example buffered input) can be defined: class (MonadInput v m) => MonadBufferedInput m where -- | If not whole chunk has been consumed at once (for example only -- first 3 elements from list) rest can be returned. It will be -- returned as part of the input on next getChunk call. returnChunk :: v -> m () data (MonadInput v m, Monoid v) => BufferedInputT v m a = BufferedInputT a v Also pipes may be defined (as far as I understand but I'm not 100% sure) which probably will simplify the writing of network tests: -- | Evaluates the first argument. If the getChunk is called the -- evaluation is passed to second argument until the putChunk is -- called, which argument is returned in the first argument callPipeT :: (Monad m, Monoid v) => PipeInputT v m a -> PipeOutputT v m b -> m (a, b) I've started some tests but I'd be grateful for comments (well - probably I'm not the first who come to this idea so a) there is such package or b) my level of Haskell does not allow me to see the problems). 2. I find writing monad transformers annoying. Additionally if package defines transformer A and another transformer B they need to be connected 'by hand'. I find a simple solution which probably is incorrect as it hasn't been used: instance (MonadState s n, Monad (m n), MonadTrans m) => MonadState s (m n) where get = lift get put = lift . put (requires FlexibleInstances MultiParamTypeClasses FlexibleContexts UndecidableInstances - two last are not extensions used by mtl) Regards From bulat.ziganshin at gmail.com Thu Jul 2 07:43:26 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jul 2 07:26:08 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers In-Reply-To: <1246534319.28235.197.camel@notebook.piechotka.com.pl> References: <1246534319.28235.197.camel@notebook.piechotka.com.pl> Message-ID: <17192247.20090702154326@gmail.com> Hello Maciej, Thursday, July 2, 2009, 3:31:59 PM, you wrote: > class (Monad m, Monoid v) => MonadInput v m where > -- | Gets an element from input (line of text [with \n], 4096 bytes, > -- or something like that). mzero on end > getChunk :: m v > class (Monad m, Monoid v) => MonadOutput v m where > -- | Puts an element > putChunk :: v -> m () how about interact function? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jules at jellybean.co.uk Thu Jul 2 07:46:37 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Thu Jul 2 07:29:08 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701182651.GA9344@soi.city.ac.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> Message-ID: <4A4C9E1D.30606@jellybean.co.uk> Ross Paterson wrote: > On Wed, Jul 01, 2009 at 10:55:39AM -0700, Bryan O'Sullivan wrote: >> Okay, here's a tentative plan that will help to figure out the answer. I'll >> build a fiddled base package that rewires the Monoid class to have (++) be the >> binary operator, and mappend as a synonym for it. I'll import the Monoid (++) >> into the Prelude. I'll see how much breaks. If that much builds smoothly, I'll >> see how much of the rest of Hackage builds, both with and without this custom >> base package. I'll follow up here with the results, along with a suggestion of >> how acceptable I think the observed level of breakage is. > > Generalizing (++) will break some Haskell 98 code, e.g. > > append = (++) > > I think that's a show-stopper. I agree it's an issue; and it's the reason I didn't even suggest it myself, favouring a new symbol. I don't think it's a show stopper, in principle. In principle you can imagine a -h98 flag which you pass to compilers which choose a strictly h98-compliant prelude as opposed to a slightly generalised newer one. I'm not the person who would have to maintain that arrangement. I guess that's a call for the people who would have to do the work. There is already a haskell98 package, I think, which is the first step? Jules From uzytkownik2 at gmail.com Thu Jul 2 07:59:31 2009 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Thu Jul 2 07:42:06 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers In-Reply-To: <17192247.20090702154326@gmail.com> References: <1246534319.28235.197.camel@notebook.piechotka.com.pl> <17192247.20090702154326@gmail.com> Message-ID: <1246535971.28235.211.camel@notebook.piechotka.com.pl> On Thu, 2009-07-02 at 15:43 +0400, Bulat Ziganshin wrote: > Hello Maciej, > > Thursday, July 2, 2009, 3:31:59 PM, you wrote: > > > class (Monad m, Monoid v) => MonadInput v m where > > -- | Gets an element from input (line of text [with \n], 4096 bytes, > > -- or something like that). mzero on end > > getChunk :: m v > > class (Monad m, Monoid v) => MonadOutput v m where > > -- | Puts an element > > putChunk :: v -> m () > > how about interact function? > Well. As far as I know there is no way of using it with network. Additionally there is hard to put monadic code in it: myFunc :: (MonadInput i, MonadOutput o) => (String -> m a) -> MyMonad i o m [a] If m == IO - which may be a case in normal code it requires unsafePerformIO with all it's problems. In testing I can use pipes and Identity simplifying the whole testing - allowing user to use it's own monads. The other problem is that the order sometimes matters. Consider: main = interact (\x -> "What's your name?\n" ++ "Hello:\n" ++ x) For human being it is annoying but sometimes it is for example against RFC. Regards From simonpj at microsoft.com Thu Jul 2 10:18:45 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Jul 2 10:01:20 2009 Subject: [Haskell-cafe] Fun with type functions Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C34391910CF7@EA-EXMSG-C334.europe.corp.microsoft.com> Friends Ken, Oleg, and I have finished Version 2 of our paper "Fun with Type Functions", which gives a programmer's tour of what type functions are and how they are useful. http://haskell.org/haskellwiki/Simonpj/Talk:FunWithTypeFuns If you have a moment to look at, and wanted to help us improve it, the above link goes to a wiki page where you can comment on the paper or discuss it. We still have time to improve it. Thanks Simon From apfelmus at quantentunnel.de Thu Jul 2 12:04:54 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Jul 2 11:47:31 2009 Subject: [Haskell-cafe] Re: Monoid wants a (++) equivalent In-Reply-To: <20090701151452.GA7160@soi.city.ac.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> <20090701151452.GA7160@soi.city.ac.uk> Message-ID: Ross Paterson wrote: > On Wed, Jul 01, 2009 at 04:53:05PM +0200, Thomas Davie wrote: >> On 1 Jul 2009, at 16:46, Edward Kmett wrote: >> >>> I'm rather fond of the (<>) suggestion, but would be happy with >>> anything better than mappend! ;) >> I find it rather ugly, it has a lot of connotations of "does not equals" >> from other languages. > > Forget Pascal: think of it as a diamond. I too like shiny diamonds, as exemplified in http://apfelmus.nfshost.com/monoid-fingertree.html Regards, apfelmus -- http://apfelmus.nfshost.com From hectorg87 at gmail.com Thu Jul 2 12:35:17 2009 From: hectorg87 at gmail.com (Hector Guilarte) Date: Thu Jul 2 12:18:06 2009 Subject: [Haskell-cafe] A Strict GCL Interpreter in Haskell Message-ID: <69630b260907020935i3b6d7b2esf281c1bd173ab63@mail.gmail.com> Hi everyone! (First of all, I don't know Monads!) I made a GCL (Guarded Command Language) Compiler and Interpreter for my Languages and Machines course in my University with alex, happy and ghc. I still have a doubt: 1) Since Haskell is Lazy, and my GCL program is being interpreted in Haskell then my GCL is Lazy too (I know is not as simple as that but believe me, somehow it is behaving lazy). The problem is that it can't be lazy (said to me by my teacher on monday) so I tried using seq, but it didn't work, I'll paste the code after this: Programs in GCL like: a) var i : value main i <- 1 / 0 end b) var i : value main i <- 1 / 0; show i end c) var i : value var foo : array of 2 main i <- foo[42] end d) var i : value var foo : array of 2 main i <- foo[42]; show i end act like this: a and c finish interpretation b throws division by zero error and finish interpretation d throws index out of bounds error and finish interpretation Now the code: (it is in Spanish. ListLValue is a List of L-Values for the assigments, ListExpr is the list of Expressions to be assigned, Tabla is the Symbol Table (Data.Map), actualizarVar updates a Variable in the Symbol Table with the new value "valor", ActualizarArray updates the position "indice" of an array in the Symbol Table. evalExpr evaluates an arithmetic Expression and returns an Int. Inside evalExpr are the verifications for division by zero of modulo by zero.) evalAsignacion:: ListLvalue -> ListExpr -> Tabla -> Tabla evalAsignacion [] [] tabla = tabla evalAsignacion ((Lid id):valueList) (expr:exprList) tabla = let valor = (evalExpr expr tabla) in valor `seq` evalAsignacion valueList exprList (actualizarVar id valor tabla) evalAsignacion ((LArrayPosition id exprArray):valueList) (expr:exprList) tabla = let valor = (evalExpr expr tabla) indice = (evalExpr exprArray tabla) in valor `seq` indice `seq` evalAsignacion valueList exprList (actualizarArray id indice valor tabla) evalExpr:: Expr -> Tabla -> Int evalExpr expr tabla = let salida = (snd (evalAritmetico expr tabla)) in salida `seq` if (isLeft salida) then error (getLeft salida) else getRight salida --((Int,Int) is the Line and Colum, that's for error reporting) evalAritmetico :: Expr -> Tabla -> ((Int,Int),(Either String Int)) --LET ME KNOW IF YOU NEED THIS PART TOO Thanks in advance, Hector Guilarte -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090702/5a9eb4b6/attachment.html From alexander.dunlap at gmail.com Thu Jul 2 12:36:16 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Thu Jul 2 12:19:05 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <20090701182651.GA9344@soi.city.ac.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> Message-ID: <57526e770907020936y56f3ab6bsda8f51de1f57a6eb@mail.gmail.com> On Wed, Jul 1, 2009 at 11:26 AM, Ross Paterson wrote: > On Wed, Jul 01, 2009 at 10:55:39AM -0700, Bryan O'Sullivan wrote: >> Okay, here's a tentative plan that will help to figure out the answer. I'll >> build a fiddled base package that rewires the Monoid class to have (++) be the >> binary operator, and mappend as a synonym for it. I'll import the Monoid (++) >> into the Prelude. I'll see how much breaks. If that much builds smoothly, I'll >> see how much of the rest of Hackage builds, both with and without this custom >> base package. I'll follow up here with the results, along with a suggestion of >> how acceptable I think the observed level of breakage is. > > Generalizing (++) will break some Haskell 98 code, e.g. > > ?append = (++) > > I think that's a show-stopper. > _______________________________________________ Could we use some default rules to keep H98 code working? I don't know much about defaulting, but times = (*) works fine and defaults to type Integer. Could we not do the same thing with monoids, having monoids default to type []? Alex From dominic.orchard at cl.cam.ac.uk Thu Jul 2 12:43:33 2009 From: dominic.orchard at cl.cam.ac.uk (Dominic Orchard) Date: Thu Jul 2 12:26:02 2009 Subject: [Haskell-cafe] [ghc] kind of the function arrow Message-ID: <4A4CE3B5.1020202@cl.cam.ac.uk> I was just playing around and noticed that the kind of the function arrow in GHC is (?? -> ? -> *) when I (naively) expected it to be (* -> * -> *). After looking at (http://hackage.haskell.org/packages/archive/ghc/6.10.2/doc/html/Type.html#5) I see that the kind of (->) means that the parameter type cannot be an unboxed tuple, whilst the result type can be anything. Why is this? After reading this documentation I would expect the kind (? -> ? -> *). I'm now wondering if the kind of (->) could cause problems if the following style of declaration is requried: > type FunArg a b = (a -> b, a) *Main> :k FunArg FunArg :: * -> * -> * By using type variables, whose default kind is *, the function type is fixed to use only boxed types. But if one wanted to allow unboxed type parameters the kind would be wrong, and an explicit kind signature of # or ? can't be given as they are not part of Haskell's source language. I guess my question is why the (?? -> ? -> *) kind on (->) and what to do if synonyms or data types over (->) are required such as the example just stated. I'm just curious. Thanks, Dominic From alexander.dunlap at gmail.com Thu Jul 2 12:43:42 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Thu Jul 2 12:26:31 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <49a77b7a0907012211w5570a8fmdeabeea5d3b18dec@mail.gmail.com> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <4A4B5405.2000509@jellybean.co.uk> <3e1162e60907010817v312ae122u42506204d52e5d85@mail.gmail.com> <916b84820907011238h23c57d02u546b8d04ff98f013@mail.gmail.com> <49a77b7a0907012211w5570a8fmdeabeea5d3b18dec@mail.gmail.com> Message-ID: <57526e770907020943q2cb38fc1o1922d140aa11aca3@mail.gmail.com> On Wed, Jul 1, 2009 at 10:11 PM, David Menendez wrote: > In Wed, Jul 1, 2009 at 3:38 PM, Thomas Schilling wrote: >> 2009/7/1 David Leimbach >>> Just because the compiler can figure out what I mean because it has a great >>> type system, I might not be able to figure out what I mean a year from now >>> if I see ++ everywhere. > >> Yep, had the same experience. ?On the one hand, using monoids lets you >> delay some design decisions for later and lets you reuse more library >> code. ?On the other hand, it sometimes makes it really hard to see >> what the code is actually doing--especially if you use more than one >> monoid. >> >> For this reason on of the first advanced features I implemented in the >> (yet unreleased) scion IDE library allows you to look up the >> instantiated type of an identifier. ?Unfortunately, jumping to the >> definition (or documentation) of the monoid instance is a bit more >> difficult. ?Haddock should allow documentation on instance >> declarations... > > I disagree. The solution is to not create instances when it isn't > obvious what the instance does. That's why we have Sum and Prod in > Data.Monoid instead of declaring instances directly for Int. > > With Monoid, I'd go further and say that you should not use mempty and > mappend unless you are writing polymorphic code. If you are writing to > a specific monoid instance, you should use a specific function. > > -- > Dave Menendez > > _______________________________________________ I tend to disagree. I think that Haskell has seen a lot of syntax bloat in the interest of monomorphism. We have List.append, Map.union, Set.union, Sequence.><, etc., all with different notation, even though these all denote the same operation: taking two of (whatever) and combining them into one. With mappend, you know exactly what the function is supposed to do: combine two things together, and it doesn't matter what datatypes you're using, because that's always what it means. Alex From ross at soi.city.ac.uk Thu Jul 2 12:49:11 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Thu Jul 2 12:31:43 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <4A4C9E1D.30606@jellybean.co.uk> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> <4A4C9E1D.30606@jellybean.co.uk> Message-ID: <20090702164911.GA8308@soi.city.ac.uk> On Thu, Jul 02, 2009 at 12:46:37PM +0100, Jules Bean wrote: > I'm not the person who would have to maintain that arrangement. I guess > that's a call for the people who would have to do the work. There is > already a haskell98 package, I think, which is the first step? The Prelude is in the base package. From uzytkownik2 at gmail.com Thu Jul 2 12:45:52 2009 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Thu Jul 2 12:32:31 2009 Subject: [Haskell-cafe] Re: Monoid wants a (++) equivalent References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090630235129.nre9tqg4u8sk0os8-nwo@webmail.spamcop.net> <87ljn8dipj.fsf@malde.org> Message-ID: Ketil Malde malde.org> writes: > > You know, this might be the right time to start expanding our > vocabulary beyond seven bits. Since we're likely to keep mappend > around as an alias for some time, people would have a grace period to > adjust. > > How about U+2295 (circle with plus inside it)? > > Or, if we would like to stick to the 8-bit subset to keep those 8859-1 > users happy, how about ? (funny circle over an x, U+00A4) > > -k I can work with any symbols as long as they are easily typeable. ++ is 3 easy key press. `mappend` is 9. In both cases I don't need to look on keyboard as I know exactly where they are. However there is no way I can remember where U+00A4 is - probably it is not on all keyboards (reversing " and @ gives me a lot of problems in UK keyboards. FR keyboards was nightmare just because a few keys where at different place). In fact I'd need to open keyboard mapping and search for symbol. A lot of trouble just for single symbol. To summarise - It doesn't matter is symbol is or isn't in ASCII or ISO 8859-1 as long as it can be produced easily. Regards From johan.tibell at gmail.com Thu Jul 2 12:58:23 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Thu Jul 2 12:41:12 2009 Subject: [Haskell-cafe] Re: Monoid wants a (++) equivalent In-Reply-To: References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090630235129.nre9tqg4u8sk0os8-nwo@webmail.spamcop.net> <87ljn8dipj.fsf@malde.org> Message-ID: <90889fe70907020958h7336b248t4229db3a01b81c5e@mail.gmail.com> On Thu, Jul 2, 2009 at 6:45 PM, Maciej Piechotka wrote: > I can work with any symbols as long as they are easily typeable. ++ is 3 > easy > key press. `mappend` is 9. In both cases I don't need to look on keyboard > as I > know exactly where they are. However there is no way I can remember where > U+00A4 > is - probably it is not on all keyboards (reversing " and @ gives me a lot > of > problems in UK keyboards. FR keyboards was nightmare just because a few > keys > where at different place). In fact I'd need to open keyboard mapping and > search > for symbol. A lot of trouble just for single symbol. > > To summarise - It doesn't matter is symbol is or isn't in ASCII or ISO > 8859-1 as > long as it can be produced easily. > I would like for my font to have a glyph for it as well so my code doesn't look like tofu. -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090702/3e1b570c/attachment.html From daniel.is.fischer at web.de Thu Jul 2 13:54:06 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Jul 2 13:37:34 2009 Subject: [Haskell-cafe] A Strict GCL Interpreter in Haskell In-Reply-To: <69630b260907020935i3b6d7b2esf281c1bd173ab63@mail.gmail.com> References: <69630b260907020935i3b6d7b2esf281c1bd173ab63@mail.gmail.com> Message-ID: <200907021954.06741.daniel.is.fischer@web.de> Am Donnerstag 02 Juli 2009 18:35:17 schrieb Hector Guilarte: > Hi everyone! > > (First of all, I don't know Monads!) > > I made a GCL (Guarded Command Language) Compiler and Interpreter for my > Languages and Machines course in my University with alex, happy and ghc. I > still have a doubt: > > 1) Since Haskell is Lazy, and my GCL program is being interpreted in > Haskell then my GCL is Lazy too (I know is not as simple as that but > believe me, somehow it is behaving lazy). The problem is that it can't be > lazy (said to me by my teacher on monday) so I tried using seq, but it > didn't work, I'll paste the code after this: > Programs in GCL like: > a) > var i : value > main > i <- 1 / 0 > end > > b) > var i : value > main > i <- 1 / 0; > show i > end > > c) > var i : value > var foo : array of 2 > main > i <- foo[42] > end > > d) > var i : value > var foo : array of 2 > main > i <- foo[42]; > show i > end > > act like this: > a and c finish interpretation > b throws division by zero error and finish interpretation > d throws index out of bounds error and finish interpretation Sorry, I don't quite get that. Do you mean that in your interpreter a) and c) run to completion without raising an error, although they should raise an error and terminate upon that? And b) and d) raise their respective error as they should? Or what is the expected behaviour and what is the actual behaviour? > > Now the code: > (it is in Spanish. ListLValue is a List of L-Values for the assigments, > ListExpr is the list of Expressions to be assigned, Tabla is the Symbol > Table (Data.Map), actualizarVar updates a Variable in the Symbol Table with > the new value "valor", ActualizarArray updates the position "indice" of an > array in the Symbol Table. evalExpr evaluates an arithmetic Expression and > returns an Int. Inside evalExpr are the verifications for division by zero > of modulo by zero.) > > evalAsignacion:: ListLvalue -> ListExpr -> Tabla -> Tabla > evalAsignacion [] [] tabla = tabla > evalAsignacion ((Lid id):valueList) (expr:exprList) tabla = > let valor = (evalExpr expr tabla) > in valor `seq` evalAsignacion valueList exprList (actualizarVar id > valor tabla) > evalAsignacion ((LArrayPosition id exprArray):valueList) (expr:exprList) > tabla = > let valor = (evalExpr expr tabla) > indice = (evalExpr exprArray tabla) > in valor `seq` indice `seq` evalAsignacion valueList exprList > (actualizarArray id indice valor tabla) > > evalExpr:: Expr -> Tabla -> Int > evalExpr expr tabla = > let salida = (snd (evalAritmetico expr tabla)) > in salida `seq` if (isLeft salida) then error (getLeft salida) > else getRight salida > > --((Int,Int) is the Line and Colum, that's for error reporting) > evalAritmetico :: Expr -> Tabla -> ((Int,Int),(Either String Int)) > --LET ME KNOW IF YOU NEED THIS PART TOO > > > Thanks in advance, > > Hector Guilarte From ekmett at gmail.com Thu Jul 2 14:11:16 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Jul 2 13:53:46 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <6d961e560907011317p281e84dbr5082ff071f272041@mail.gmail.com> References: <6d961e560907011317p281e84dbr5082ff071f272041@mail.gmail.com> Message-ID: <7fb8f82f0907021111jdf2c509g485bcff08d1c1f8f@mail.gmail.com> Wed, Jul 1, 2009 at 4:17 PM, Raynor Vliegendhart wrote: > We could use (Control.Category..) as an operator, but this would > require an additional wrapping layer if we wish to use the existing > Monoid instances: > > > import Prelude hiding (id, (.)) > > import Control.Category > > import Data.Monoid > > > > -- Category wrapper for existing Monoid instances > > newtype MonoidC m a b = MonoidC {unwrapMC :: m} deriving (Show) > > > > instance Monoid m => Category (MonoidC m) where > > id = MonoidC mempty > > MonoidC m . MonoidC n = MonoidC $ m `mappend` n > > Furthermore, writing Category instances for monoids require dummy type > parameters: > > > -- Example instance > > newtype SumC m a b = SumC {getSumC :: m} deriving (Show, Eq) > > > > instance Num a => Category (SumC a) where > > id = SumC (fromIntegral 0) > > SumC x . SumC y = SumC $ x + y > I have a monoid-as-category and category-endomorphism as monoid in: http://comonad.com/haskell/monoids/dist/doc/html/monoids/Data-Monoid-Categorical.html but there are issues. 1.) these completely change the typing involved 2.) the monoid as category-with-one-object is pretty scary to someone without a category theory background. 3.) This doesn't properly represent the category-with-one-object because at best the two phantom types yield you something like a category like Hask, which has been fully connected * M where M is the category of your monoid. Even if you use GADTs to cut down the phantom types to one where the head and tail of the arrow are the same object and |.| takes a category to its discrete category (discarding all non-identity arrows) you are looking at a category like |Hask| * M because of the phantom type. data CMonoid m n o where M :: Monoid m => m -> CMonoid m a a instance Monoid m => Category (CMonoid m) where id = M mempty M a . M b = M (a `mappend` b) Attempting to go any further and railroad that type to equal m fails when you go to define id. So the categorical notion of a monoid is pretty much a non-starter in Haskell. -Edward Kmett On Another disadvantage of this approach is that we cannot have a default monoid instance for lists (kind mismatch). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090702/530f47f5/attachment-0001.html From alexander.dunlap at gmail.com Thu Jul 2 15:16:38 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Thu Jul 2 14:59:27 2009 Subject: [Haskell-cafe] golf, predicate check function for MonadPlus (was Re: How to read safely?) In-Reply-To: References: <3bd412d40906240240q13fd4cf4oc7062cd08ae72fb@mail.gmail.com> <200906240556.17953.dan.doel@gmail.com> Message-ID: <57526e770907021216m68017d27jb7256cc30fa496ce@mail.gmail.com> On Thu, Jul 2, 2009 at 3:36 AM, Jon Fairbairn wrote: > Dan Doel writes: > >> There was talk of adding a readMaybe a while ago, but apparently it >> never happened. >> >> As it is, you can use reads, "read s" becomes: >> >> ? ? case reads s of >> ? ? ? [(a, rest)] | all isSpace rest -> >> ? ? ? _ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-> >> >> which ensures that you have an unambiguous parse with only trailing >> whitespace. You can, of course, modify that if you don't care about >> ambiguity or trailing characters. > > I was wondering about a more algebraic way of writing that; here's a > version (that doesn't care about ambiguity) > > readMaybe :: Read a => String -> Maybe a > readMaybe > ? ?= join . fmap no_trailing_garbage . listToMaybe . reads > ? ? ?where no_trailing_garbage = fmap fst . check (all isSpace . snd) > > check :: (MonadPlus m) => (a -> Bool) -> a -> m a > check p a > ? ?| p a = return a > ? ?| otherwise = mzero > > > I tried Hoogling for a function like check, but couldn't find it. Surely > there's one in a library somewhere? It looks useful to me. (I'm rather > taken by way the "check (all isSpace . snd)" part reads) > > Monad.guard comes close but fails to get the cigar; in fact > > guard b == check (const b) () > > So check is more general. > > > Also, I don't see a singletonListToMaybe that one could use in place of > listToMaybe to require unambiguity. Could do > > isSingleton [a] = True > isSingleton _ = False > > and then use "listToMaybe . join . check isSingleton" -- aha! Another > use for check! > > > > > ?J?n > > > [Footnote: I thought of writing "guard == flip (check . const) ()" but > then realised it was pointless] > > -- > J?n Fairbairn ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Jon.Fairbairn@cl.cam.ac.uk > You can use the Kleisli composition operator (<=<) to make it a little nicer. singletonListToMaybe :: [a] -> Maybe a singletonListToMaybe [x] = Just x singletonListToMaybe _ = Nothing check :: MonadPlus m => (a -> Bool) -> a -> m a check p a | p a = return a | otherwise = mzero readMaybe = fmap fst.check (all isSpace.snd) <=< singletonListToMaybe.reads Alex From lrpalmer at gmail.com Thu Jul 2 16:18:21 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Jul 2 16:00:50 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers In-Reply-To: <1246534319.28235.197.camel@notebook.piechotka.com.pl> References: <1246534319.28235.197.camel@notebook.piechotka.com.pl> Message-ID: <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> On Thu, Jul 2, 2009 at 5:31 AM, Maciej Piechotka wrote: > 2. I find writing monad transformers annoying. > Additionally if package defines transformer A and another transformer B > they need to be connected 'by hand'. You have not given any concrete problems or examples, so it's hard for me to comment. But at first glance, I would conjecture that you are relying too heavily on monads and sequential thinking. Consider what your code would look like without a single monad. Obviously you cannot talk to the network without IO, but your program can still be * modeled* purely, and then toss in IO at the last second to tie it to the network. This model may be difficult for you because it requires your brain to be rewired; feel free to mail this list with concrete modeling problems and we will help you out. As for the pure model, throw away Reader, Writer, State -- everything, and just use pure functions. Then add monads back in *at small scopes* when they clean things up. I used to approach problems by designing a monad for my whole program, using an appropriate stack of transformers. I suspect such an approach led to the claim that "monads are not appropriate for large software systems" in a popular paper a few months ago. As I have gained more experience, I found that this is the *wrong* way to go about using them. Now my primary use of monads is within the scope of a single function, to tie together the helper functions in the where clause. Luke > > I find a simple solution which probably is incorrect as it hasn't been > used: > > instance (MonadState s n, Monad (m n), MonadTrans m) => > MonadState s (m n) where > get = lift get > put = lift . put > > (requires FlexibleInstances MultiParamTypeClasses FlexibleContexts > UndecidableInstances - two last are not extensions used by mtl) > > Regards > > _______________________________________________ > 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/20090702/9e3aea9d/attachment.html From dagit at codersbase.com Thu Jul 2 16:30:28 2009 From: dagit at codersbase.com (Jason Dagit) Date: Thu Jul 2 16:12:57 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers In-Reply-To: <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> References: <1246534319.28235.197.camel@notebook.piechotka.com.pl> <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> Message-ID: On Thu, Jul 2, 2009 at 1:18 PM, Luke Palmer wrote: > > I used to approach problems by designing a monad for my whole program, > using an appropriate stack of transformers. I suspect such an approach led > to the claim that "monads are not appropriate for large software systems" in > a popular paper a few months ago. > Link please! I googled but I couldn't find it :( I'd like to find out what you and the authors have learned about the inappropriateness of monads for large software systems. Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090702/d25e65d1/attachment.html From bulat.ziganshin at gmail.com Thu Jul 2 16:52:50 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jul 2 16:43:24 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers In-Reply-To: <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> References: <1246534319.28235.197.camel@notebook.piechotka.com.pl> <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> Message-ID: <130669679.20090703005250@gmail.com> Hello Luke, Friday, July 3, 2009, 12:18:21 AM, you wrote: > I used to approach problems by designing a monad for my whole > program, using an appropriate stack of transformers.? I suspect such > an approach led to the claim that "monads are not appropriate for > large software systems" in a popular paper a few months ago.? As I > have gained more experience, I found that this is the wrong way to > go about using them.? was it ghc authors paper? :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From mads_lindstroem at yahoo.dk Thu Jul 2 17:01:41 2009 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Thu Jul 2 16:44:11 2009 Subject: [Haskell-cafe] ORM for haskell? In-Reply-To: <20090630221434.GA1780@gmx.de> References: <20090630175208.GE6272@gmx.de> <1246398580.4349.10.camel@supermule.opasia.dk> <20090630221434.GA1780@gmx.de> Message-ID: <1246568501.4370.40.camel@supermule.opasia.dk> Hi Marc Weber > Hi Mads! > > On Tue, Jun 30, 2009 at 11:49:40PM +0200, Mads Lindstr?m wrote: > > Hi Marc Weber > > > > > Another example: Updating the age of a pupil: > > > > > > row = SELECT * FROM pupils where age = 13; > > > UPDATE pupils SET age = 14 WHERE id = > > > > > > p = session.query(Pupil).filter(Pupil.age==13).one().age=14 > > > session.commit() > > > > > > difference? > > > You don't have to care about ids. you just assign a new value and > > > tell > > > the engine that it should commit. > > > So again less chances to get something wrong. > > > > > > > Could you not do in SQL: > > > > UPDATE pupils SET age = 14 WHERE age = 13 > Of course. > But: you can pass around that pupil object to another function and still assign a new age > then run session.commit(). > When passing around the pupile you can follow the relation_ships > (relations?) back to school. > > def doSomething(pupil): > pupil['age'] = 13 > pupil.teacher.school.rating += 1 > > doSomething(session.query(Pupil).filter(Pupil.age==13)) > session.commit() > > Now how would you do this using SQL? As far as I know, you cannot. And it is very nice. On the other hand you sometimes want to execute more of the logic on the DBMS, as it leads to better performance. But maybe we can somehow have our cake and eat it too. E.g. if the user still have some control about where the logic is executed. > > Sorry about the confustion (relation / relation-ship). I mixed up the terminology. > Anyway I guess you can see here how powerful an ORM can be and why > we should write such a library for haskell. Don't be sorry about that. I know people often confuse the terms and I could have replied just asking if you had not swapped the two terms. In my native language relation can mean both relation and to relationship. Guess, it is the same in other languages... > > I think it's very hard to invent such a short synax in haskell cause > you have to take monads into account etc.. > > And it matters how much time you have to spend writing code. Yes and yes. I think (my gut tells me so) you will need to use Template Haskell, if you want something as succinct as the Python code you showed. Or maybe if you give up type safety, but I guess your are not willing to do that. But it could be fun (and challenging) coming up with something really nice. > > Thanks for your feedback. I hope there will be some more. > > Marc Weber I may have sounded a bit negative in my previous mails. But I really can see something cool about what you describe. That said, I think people are sometimes too eager to replace SQL. As you properly are already aware, SQL+Relational databases has some very nice properties (list below is form the top of my head, there are other advantages): * They are accessed with a declarative language (SQL) * They can make high-level optimization automatically and guided by the user * They can, transparently, execute queries/updates using multiple servers/CPUs. It may require some changes to the database, but it can be done without changing your SQL * They are based on a nice theoretical foundation * If databases are normalized properly, data are a lot more transparent than other ways of organizing data. At least other ways I have seen. * Normalization provides a lot less ambiguous guidance, than other "development methodologies". * Transaction support But as you point out yourself, everything is not rosy. And in addition to what you write, all the (un)marshaling you need when accessing databases from Haskell is quite cumbersome. And I realize that you are not trying to replace RDBs, just building a nicer interface to them. I am just concerned that some of the nice properties are lost in the process. I think my main concern comes from seeing people create databases, by automatically generating tables from OO-classes. They invariably ends up with something not nearly as nice, as if they had constructed the database in a more traditional fashion. To summarize, what you propose is cool. Just do not throw the baby out with the bathwater. Greetings, Mads Lindstr?m -------------- 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/20090702/1a9dda9b/attachment.bin From uzytkownik2 at gmail.com Thu Jul 2 17:05:05 2009 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Thu Jul 2 16:47:39 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers In-Reply-To: <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> References: <1246534319.28235.197.camel@notebook.piechotka.com.pl> <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> Message-ID: <1246568705.28235.242.camel@notebook.piechotka.com.pl> On Thu, 2009-07-02 at 14:18 -0600, Luke Palmer wrote: > On Thu, Jul 2, 2009 at 5:31 AM, Maciej Piechotka > wrote: > 2. I find writing monad transformers annoying. > Additionally if package defines transformer A and another > transformer B > they need to be connected 'by hand'. > > You have not given any concrete problems or examples, so it's hard for > me to comment. But at first glance, I would conjecture that you are > relying too heavily on monads and sequential thinking. > > Consider what your code would look like without a single monad. > Obviously you cannot talk to the network without IO, but your program > can still be modeled purely, and then toss in IO at the last second to > tie it to the network. This model may be difficult for you because it > requires your brain to be rewired; feel free to mail this list with > concrete modeling problems and we will help you out. > > As for the pure model, throw away Reader, Writer, State -- everything, > and just use pure functions. Then add monads back in at small scopes > when they clean things up. > AFAIU you comment the 2de point only. I look at this moment from library, not program point of view. So consider the library IOMonad which defined some MonadInput v m monad. Then you have NNTP library which has NntpT m monad. Each of them defines appropriate stack such as that NntpT (State s) is instance of MonadState. But if there is NntpT MyInput, where MyInput isinstance of MonadInput, is not MonadInput. To do it with current approach the libraries would have to be interlinked. Also it is quite boring to include for all monad instance ... => ... where f1 = lift f1 f2 = lift f2 ... > I used to approach problems by designing a monad for my whole program, > using an appropriate stack of transformers. I thought about others which might have want to use my monads in their functions... > I suspect such an approach led to the claim that "monads are not > appropriate for large software systems" in a popular paper a few > months ago. I'd appreciate the link - google find nothing. I fall in love in Haskell about a week or two ago and I fall in love just after I started learning it ;) > As I have gained more experience, I found that this is the wrong way > to go about using them. Now my primary use of monads is within the > scope of a single function, to tie together the helper functions in > the where clause. > > Luke > Regards From gwern0 at gmail.com Thu Jul 2 17:26:06 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Jul 2 17:08:34 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers In-Reply-To: <1246568705.28235.242.camel@notebook.piechotka.com.pl> References: <1246534319.28235.197.camel@notebook.piechotka.com.pl> <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> <1246568705.28235.242.camel@notebook.piechotka.com.pl> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Thu, Jul 2, 2009 at 5:05 PM, Maciej Piechotka wrote: > I'd appreciate the link - google find nothing. I fall in love in Haskell > about a week or two ago and I fall in love just after I started learning > it ;) "Research programming languages like Haskell [22] and ML [20] didn't seem to offer any near-term solution. Diatchki's work on fine-grain representation in Haskell [25] is not yet main-stream, and had not yet started when we began work on BitC. Support for state in Haskell exists in the form of the I/O monad [23], but in our opinion the monadic idiom does not scale well to large, complexly stateful programs,1 and imposes constraints that are unnatural in the eyes of systems programmers." Oh, and not only do our monads not scale, they're slow to boot: " Ultimately, the problem with Haskell and ML for our purposes is that the brightest and most aggressive programmers in those languages, using the most aggressive optimization techniques known to the research community, remain unable to write systems codes that compete reasonably with C or C++. The most successful attempt to date is probably the FoxNet TCP/IP protocol stack, which incurred a 10x increase in system load and a 40x penalty in accessing external memory relative to a conventional (and less aggressively optimized) C implemenation. [ 4 ,6 ]" http://www.bitc-lang.org/docs/bitc/bitc-origins.html - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkpNJWoACgkQvpDo5Pfl1oLpeQCcDXUnfBaitwii3rhortVqO8Fr SXIAnAiKY5EGg/ssZHOaooP1ag1xGIE4 =iugB -----END PGP SIGNATURE----- From rendel at cs.au.dk Thu Jul 2 17:44:24 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Thu Jul 2 17:26:59 2009 Subject: [Haskell-cafe] A Strict GCL Interpreter in Haskell In-Reply-To: <69630b260907020935i3b6d7b2esf281c1bd173ab63@mail.gmail.com> References: <69630b260907020935i3b6d7b2esf281c1bd173ab63@mail.gmail.com> Message-ID: <4A4D2A38.9080704@cs.au.dk> Hi Hector, Hector Guilarte wrote: > 1) Since Haskell is Lazy, and my GCL program is being interpreted in Haskell > then my GCL is Lazy too (I know is not as simple as that but believe me, > somehow it is behaving lazy). The problem is that it can't be lazy (said to > me by my teacher on monday). > evalExpr:: Expr -> Tabla -> Int > evalExpr expr tabla = > let salida = (snd (evalAritmetico expr tabla)) > in salida `seq` if (isLeft salida) then error (getLeft salida) > else getRight salida I think the problem with your code is that you call error, instead of reporting the error back to the caller. evalExpr can go wrong (consider 5 / 0), but this fact is not represented in the type: evalExpr:: Expr -> Tabla -> Int The type says that for all expressions and all symbol tables, you can produce an int result. But that is not true! So try using this more adequate type: evalExpr :: Expr -> Tabla -> Either String Int Now, for all expressions and symbol tables, evalExpr either can compute an integer result, or it informs you that something went wrong. If you have these kinds of types on all your functions, your main program becomes something like: main = do code <- readAndParseFile "somefile" case evalProgram code of Left error -> putStrLn ("Error: " ++ error) Right () -> putStrLn "Worked fine!" So if you need fine-grained control over error-handling, add explicit error handling, and do not use the error function. Good luck! Tillmann From a.biurvOir4 at asuhan.com Thu Jul 2 17:52:27 2009 From: a.biurvOir4 at asuhan.com (Kim-Ee Yeoh) Date: Thu Jul 2 17:34:56 2009 Subject: [Haskell-cafe] Flipping *->*->* kinds, or monadic finally-tagless madness Message-ID: <24314553.post@talk.nabble.com> I'm trying to write HOAS Show instances for the finally-tagless type-classes using actual State monads. The original code: http://okmij.org/ftp/Computation/FLOLAC/EvalTaglessF.hs Two type variables are needed: one to vary over the Symantics class (but only as a phantom type) and another to vary over the Monad class. Hence, the use of 2-variable type constructors. > type VarCount = int > newtype Y b a = Y {unY :: VarCount -> (b, VarCount)} Not knowing of a type-level 'flip', I resort to newtype isomorphisms: > newtype Z a b = Z {unZ :: Y b a} > instance Monad (Z a) where > return x = Z $ Y $ \c -> (x,c) > (Z (Y m)) >>= f = Z $ Y $ \c0 -> let (x,c1) = m c0 in (unY . unZ) (f > x) c1 -- Pace, too-strict puritans > instance MonadState String (Z a) where > get = Z $ Y $ \c -> (show c, c) > put x = Z $ Y $ \_ -> ((), read x) So far so good. Now for the Symantics instances (abridged). > class Symantics repr where > int :: Int -> repr Int -- int literal > add :: repr Int -> repr Int -> repr Int > lam :: (repr a -> repr b) -> repr (a->b) > instance Symantics (Y String) where > int = unZ . return . show > add x y = unZ $ do > sx <- Z x > sy <- Z y > return $ "(" ++ sx ++ " + " ++ sy ++ ")" The add function illustrates the kind of do-sugaring we know and love that I want to use for Symantics. > lam f = unZ $ do > show_c0 <- get > let > vname = "v" ++ show_c0 > c0 = read show_c0 :: VarCount > c1 = succ c0 > fz :: Z a String -> Z b String > fz = Z . f . unZ > put (show c1) > s <- (fz . return) vname > return $ "(\\" ++ vname ++ " -> " ++ s ++ ")" Now with lam, I get this cryptic error message (under 6.8.2): Occurs check: cannot construct the infinite type: b = a -> b When trying to generalise the type inferred for `lam' Signature type: forall a1 b1. (Y String a1 -> Y String b1) -> Y String (a1 -> b1) Type to generalise: forall a1 b1. (Y String a1 -> Y String b1) -> Y String (a1 -> b1) In the instance declaration for `Symantics (Y String)' Both the two types in the error message are identical, which suggests no generalization is needed. I'm puzzled why ghc sees an infinite type. Any ideas on how to proceed? -- View this message in context: http://www.nabble.com/Flipping-*-%3E*-%3E*-kinds%2C-or-monadic-finally-tagless-madness-tp24314553p24314553.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From wren at freegeek.org Thu Jul 2 17:59:44 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Jul 2 17:42:15 2009 Subject: [Haskell-cafe] Network.CGI -- practical web programming example. In-Reply-To: <7E4F8437-C50A-43E5-82B0-A6DA848EBF49@ece.cmu.edu> References: <8f66da400906271707r64577db1mcc8193d478ea9928@mail.gmail.com> <7E4F8437-C50A-43E5-82B0-A6DA848EBF49@ece.cmu.edu> Message-ID: <4A4D2DD0.2000509@freegeek.org> Brandon S. Allbery KF8NH wrote: > Some Haskell > programmers use fmap (because most Monads are also Functors), others use > liftM. Both have the same effect: given a monadic computation "m a", > "liftM f" turns "f" into a function that operates on the enclosed "a" > instead of the entire "m a". That is, given the theory behind it all, every monad is a functor (note the lower case); from which it follows that liftM == fmap. For historical reasons the Monad typeclass does not require a Functor instance, however, and so it's not the case that every Monad is also a Functor (note the upper case). The function liftM can be defined generically given definitions for return and (>>=), so some prefer to use liftM to avoid the extra Functor dependency. The function fmap can be given specialized definitions due to overloading, so others prefer to use it for efficiency reasons. The (<$>) function is just a symbolic name for fmap. You'll also see the Applicative typeclass for "applicative functors". Applicative does require a Functor instance, which is good. (And actually, every monad is an applicative functor; though the Monad class doesn't require Applicative either.) The function liftA can be defined generically given definitions for pure and (<*>), and liftA == fmap as well. The only reason anyone should use liftA is for defining a Functor instance when they're too lazy to give a specialized implementation. -- Live well, ~wren From marco-oweber at gmx.de Thu Jul 2 18:01:33 2009 From: marco-oweber at gmx.de (Marc Weber) Date: Thu Jul 2 17:44:04 2009 Subject: [Haskell-cafe] ORM for haskell? In-Reply-To: <1246568501.4370.40.camel@supermule.opasia.dk> References: <20090630175208.GE6272@gmx.de> <1246398580.4349.10.camel@supermule.opasia.dk> <20090630221434.GA1780@gmx.de> <1246568501.4370.40.camel@supermule.opasia.dk> Message-ID: <20090702220133.GA18928@gmx.de> > And I realize that you are not trying to replace RDBs, just building a > nicer interface to them. I am just concerned that some of the nice > properties are lost in the process. I think my main concern comes from > seeing people create databases, by automatically generating tables from > OO-classes. They invariably ends up with something not nearly as nice, > as if they had constructed the database in a more traditional fashion. > > To summarize, what you propose is cool. Just do not throw the baby out > with the bathwater. Hi Mad. Maybe I want to replace a RDBMS. But this will cost. You can fire arbitrary SQL statements in no time at RDBMS. You can't do things like that that easy using a haskell (in memory) only solutions. So SQL wins here at the moment if you want to be productive. If you read the .pdf I posted you saw that SQLAlchemy is that coold that a) you can use the shortcut style and define objects and tables at the same time but you als can b) define both layers independent of each other. And: Most applications today don't have to scale to an extend forcing you to move all logic into a database system. If you can one request a sec on a web application .. That's already very much for most small shop system. (I'm not talking about Amazon or ebay or such!) I'm talking about customers who want some more customizations as you can do with oscommerce. My main purpose was to see wether someone else would be interested in spending more effort into such a solution. Anyway I have still have to do some other work before I can jump into such a project. And Mad, I think you already know that RDBMS are not the best solution because it's very hard to ask a RDBMS wether a query retuns a nullable value or not. And that makes a huge difference wether you have to use a unsafeFromNull like function all the time or not. Time will tell how much energy I can spend on such this topic in the future. cu all Marc Weber From ok at cs.otago.ac.nz Thu Jul 2 18:32:02 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Jul 2 18:14:36 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <57526e770907020936y56f3ab6bsda8f51de1f57a6eb@mail.gmail.com> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> <57526e770907020936y56f3ab6bsda8f51de1f57a6eb@mail.gmail.com> Message-ID: It is claimed that making ++ become another name for the Monoid mappend operation "will break some Haskell 98 code" such as append = (++) That example can easily be fixed by adding a type signature, no? append :: [a] -> [a] -> [a] append = (++) In ghci, at any rate, using mappend instead of (++), the first is rejected, but the sceond works perfectly. The nice thing about this is that the code _with_ the type signature is perfectly legal Haskell 98, so the fix leaves you with something that works with either reading of (++). Do we have any other uses of ++ that would be hard to fix by adding a type signature? From rendel at cs.au.dk Thu Jul 2 19:05:39 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Thu Jul 2 18:48:12 2009 Subject: [Haskell-cafe] A Strict GCL Interpreter in Haskell In-Reply-To: <1933439637-1246573275-cardhu_decombobulator_blackberry.rim.net-1042301844-@bxe1035.bisx.prod.on.blackberry> References: <1933439637-1246573275-cardhu_decombobulator_blackberry.rim.net-1042301844-@bxe1035.bisx.prod.on.blackberry> Message-ID: <4A4D3D43.5020202@cs.au.dk> Hi Hector, Hector Guilarte wrote: > I did that already, but it didn't work... Also, since this kind of error would be a run time error in my GCL Language, I don't want it to continue executing whenever an error is found, that's why I changed it back to just: > evalExpr:: Expr -> Tabla -> Int > > Instead of using the Either String Int... I think you misunderstand something. If you use (Expr -> Table -> Int), you are announcing: Whatever happens, I keep executing. If you use (Expr -> Table -> Either String Int), you are announcing: I may stop earlier because of some problem. Since may you want to stop earlier, you should use the second type. Let's look at a very small example, an interpreter for the following little language: data Expression = Literal Integer | Add Expression Expression | Divide Expression Expression Because of division by zero, an interpreter for this language may fail. So we have two kinds of return values: Sometimes we return a number, and sometimes we return an DivideByZero error. We can reflect that in a datatype: data Result = Number Integer | DivideByZeroError Now we can write our interpreter: eval :: Expression -> Result eval (Literal n) = Number n eval (Add a b) = case eval a of Number result_of_a -> case b of Number result_of_b -> Number (result_of_a + result_of_b) DivideByZeroError -> DivideByZeroError DivideByZeroError -> DivideByZeroError eval (Add a b) = case eval a of Number result_of_a -> case b of Number result_of_b -> if b == 0 then DivideByZeroError else Number (result_of_a + result_of_b) DivideByZeroError -> DivideByZeroError DivideByZeroError -> DivideByZeroError This interpreter will stop as soon as it encounters a division by zero, because we take care to return DivideByZeroError whenever we see a DivideByZeroError in one of the subterms. So you have to use an appropriate return type (like (Either String Int) or Result), and you have to pattern match on the result of "earlier" parts of your program, and propagate the error. Tillmann From wren at freegeek.org Thu Jul 2 19:38:18 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Jul 2 19:20:48 2009 Subject: [Haskell-cafe] ANN: TernaryTrees-0.1.1.1 - An efficient ternary tree implementation of Sets and Maps In-Reply-To: <6AC4BCCD-1F7E-48FC-B49C-85326510D532@gmail.com> References: <20090629161316.GB18404@brighton.ac.uk> <6AC4BCCD-1F7E-48FC-B49C-85326510D532@gmail.com> Message-ID: <4A4D44EA.6000408@freegeek.org> Alex Mason wrote: > TernaryTrees is a package that extends Data.Set ad Data.Map with some > ternary tree structures, based on the article > [http://www.pcplus.co.uk/node/3074/] . For the string (or rather ByteString) version: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-trie Which has a number of other significant performance improvements (e.g. node fusion, ByteString instead of String) and a highly expressive interface. Because it uses ByteStrings it can trie any type which can be serialized into a vector of bits[1], albeit indirectly. The real trick with tries is not in just having them[2], it's in having the right interface to make use of what they're good at. For example, if I have multiple tries, I'd like to merge them without doing it element by element[3]. Or if I know I'm going to be making a number of similar queries, it'd be nice if I could cache my position in the trie[4] to avoid repeating the work for the prefixes of all my queries[5]. Using tricks like these leads to significant improvements over using them like hashtables; tries aren't hashtables just like lists aren't arrays. [1] Where the ByteString encodings are equal iff the values are equal. Ideally, the encoding should ensure that for any given set of queries, the discriminative bits are closest to the front. You can also use lossless compression algorithms (e.g. Golomb codes) to shrink the size of the keys if you happen to know their distribution; and if your queries are already compressed, you don't need to decompress them to do lookup! [2] And they seem to be all the rage for people reinventing them these days... [3] Supported by Data.Trie.mergeBy for the general case, with unionL and unionR for common use cases. [4] Supported by Data.Trie.lookupBy [5] In the general case, this is trie intersection. You can hack this together with the bytestring-trie-0.1.4 interface, but an efficient version is on my todo list. A special case of intersection is provided by Data.Trie.submap. -- Live well, ~wren From dons at galois.com Thu Jul 2 19:45:47 2009 From: dons at galois.com (Don Stewart) Date: Thu Jul 2 19:30:35 2009 Subject: [Haskell-cafe] ANN: TernaryTrees-0.1.1.1 - An efficient ternary tree implementation of Sets and Maps In-Reply-To: <4A4D44EA.6000408@freegeek.org> References: <20090629161316.GB18404@brighton.ac.uk> <6AC4BCCD-1F7E-48FC-B49C-85326510D532@gmail.com> <4A4D44EA.6000408@freegeek.org> Message-ID: <20090702234547.GA29884@whirlpool.galois.com> wren: > Alex Mason wrote: >> TernaryTrees is a package that extends Data.Set ad Data.Map with some >> ternary tree structures, based on the article >> [http://www.pcplus.co.uk/node/3074/] . > > For the string (or rather ByteString) version: > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-trie > > Which has a number of other significant performance improvements (e.g. > node fusion, ByteString instead of String) and a highly expressive > interface. Because it uses ByteStrings it can trie any type which can be > serialized into a vector of bits[1], albeit indirectly. > > The real trick with tries is not in just having them[2], it's in having > the right interface to make use of what they're good at. For example, if > I have multiple tries, I'd like to merge them without doing it element > by element[3]. Or if I know I'm going to be making a number of similar > queries, it'd be nice if I could cache my position in the trie[4] to > avoid repeating the work for the prefixes of all my queries[5]. Using > tricks like these leads to significant improvements over using them like > hashtables; tries aren't hashtables just like lists aren't arrays. > > Do you have benchmarks? From allbery at ece.cmu.edu Thu Jul 2 19:50:11 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Jul 2 19:33:04 2009 Subject: [Haskell-cafe] Network.CGI -- practical web programming example. In-Reply-To: <4A4D2DD0.2000509@freegeek.org> References: <8f66da400906271707r64577db1mcc8193d478ea9928@mail.gmail.com> <7E4F8437-C50A-43E5-82B0-A6DA848EBF49@ece.cmu.edu> <4A4D2DD0.2000509@freegeek.org> Message-ID: <14B382FF-C944-469D-A508-DAA9216184A4@ece.cmu.edu> On Jul 2, 2009, at 17:59 , wren ng thornton wrote: > Brandon S. Allbery KF8NH wrote: >> Some Haskell programmers use fmap (because most Monads are also >> Functors), others use liftM. Both have the same effect: given a >> monadic computation "m a", "liftM f" turns "f" into a function that >> operates on the enclosed "a" instead of the entire "m a". > > That is, given the theory behind it all, every monad is a functor > (note the lower case); from Yeh, I decided to bypass the whole "all monads are functors, but for Hysterical Raisins not all Monads are Functors" morass. -- 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/20090702/3f633569/PGP.bin From kyagrd at gmail.com Thu Jul 2 20:02:18 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Thu Jul 2 19:45:17 2009 Subject: [Haskell-cafe] Re: Flipping *->*->* kinds, or monadic finally-tagless madness In-Reply-To: <24314553.post@talk.nabble.com> References: <24314553.post@talk.nabble.com> Message-ID: Kim-Ee Yeoh wrote: > > The add function illustrates the kind of do-sugaring we know and love > that I want to use for Symantics. > >> lam f = unZ $ do >> show_c0 <- get >> let >> vname = "v" ++ show_c0 >> c0 = read show_c0 :: VarCount >> c1 = succ c0 >> fz :: Z a String -> Z b String >> fz = Z . f . unZ >> put (show c1) >> s <- (fz . return) vname >> return $ "(\\" ++ vname ++ " -> " ++ s ++ ")" > > Now with lam, I get this cryptic error message (under 6.8.2): > > Occurs check: cannot construct the infinite type: b = a -> b > When trying to generalise the type inferred for `lam' > Signature type: forall a1 b1. > (Y String a1 -> Y String b1) -> Y String (a1 -> > b1) > Type to generalise: forall a1 b1. > (Y String a1 -> Y String b1) -> Y String (a1 -> > b1) > In the instance declaration for `Symantics (Y String)' > > Both the two types in the error message are identical, which suggests > no generalization is needed. I'm puzzled why ghc sees an infinite type. > > Any ideas on how to proceed? Not an answer, but just a different error message from GHC 6.10.3 when I tried loading up your code. kyagrd@kyavaio:~/tmp$ ghci EvalTaglessF.hs GHCi, version 6.10.3: 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 ( EvalTaglessF.hs, interpreted ) EvalTaglessF.hs:264:14: Couldn't match expected type `b1' against inferred type `b' `b1' is a rigid type variable bound by the type signature for `fz' at EvalTaglessF.hs:263:31 `b' is a rigid type variable bound by the type signature for `lam' at EvalTaglessF.hs:248:26 Expected type: Z b1 String Inferred type: Z b String In the expression: Z . f . unZ In the definition of `fz': fz = Z . f . unZ EvalTaglessF.hs:264:22: Couldn't match expected type `a1' against inferred type `a' `a1' is a rigid type variable bound by the type signature for `fz' at EvalTaglessF.hs:263:17 `a' is a rigid type variable bound by the type signature for `lam' at EvalTaglessF.hs:248:16 Expected type: Z a1 String Inferred type: Z a String In the second argument of `(.)', namely `unZ' In the second argument of `(.)', namely `f . unZ' Failed, modules loaded: none. I hope this gives you a hint, if any. I am not exactly sure about how to solve this but I might try using scoped type variables extension somehow if I were in your shoe. From ekmett at gmail.com Thu Jul 2 20:15:52 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Jul 2 19:58:20 2009 Subject: [Haskell-cafe] Re: Flipping *->*->* kinds, or monadic finally-tagless madness In-Reply-To: References: <24314553.post@talk.nabble.com> Message-ID: <7fb8f82f0907021715ua0495afk5d5e821c0d7f468b@mail.gmail.com> Actually the problem lies in your definition of fz, it has the wrong type to be used in lam. The Z you get out of fz as type Z b String, but you need it to have Z (a -> b) String so that when you strip off the Z you have a Y String (a -> b) matching the result type of lam. To get there replace your definition of fz with: > fz :: Z a String -> Z (a -> b) String > fz = Z . Y . unY . f . unZ In 6.10.2 I used {-# LANGUAGE FlexibleInstances, TypeSynonymInstances, MultiParamTypeClasses, ScopedTypeVariables #-} and that compiled just fine. On Thu, Jul 2, 2009 at 8:02 PM, Ahn, Ki Yung wrote: > Kim-Ee Yeoh wrote: > >> >> The add function illustrates the kind of do-sugaring we know and love >> that I want to use for Symantics. >> >> lam f = unZ $ do >>> show_c0 <- get >>> let >>> vname = "v" ++ show_c0 >>> c0 = read show_c0 :: VarCount >>> c1 = succ c0 >>> fz :: Z a String -> Z b String >>> fz = Z . f . unZ >>> put (show c1) >>> s <- (fz . return) vname >>> return $ "(\\" ++ vname ++ " -> " ++ s ++ ")" >>> >> >> Now with lam, I get this cryptic error message (under 6.8.2): >> >> Occurs check: cannot construct the infinite type: b = a -> b >> When trying to generalise the type inferred for `lam' >> Signature type: forall a1 b1. >> (Y String a1 -> Y String b1) -> Y String (a1 -> >> b1) >> Type to generalise: forall a1 b1. >> (Y String a1 -> Y String b1) -> Y String (a1 -> >> b1) >> In the instance declaration for `Symantics (Y String)' >> >> Both the two types in the error message are identical, which suggests >> no generalization is needed. I'm puzzled why ghc sees an infinite type. >> >> Any ideas on how to proceed? >> > > Not an answer, but just a different error message from GHC 6.10.3 when I > tried loading up your code. > > kyagrd@kyavaio:~/tmp$ ghci EvalTaglessF.hs > GHCi, version 6.10.3: 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 ( EvalTaglessF.hs, interpreted ) > > EvalTaglessF.hs:264:14: > Couldn't match expected type `b1' against inferred type `b' > `b1' is a rigid type variable bound by > the type signature for `fz' at EvalTaglessF.hs:263:31 > `b' is a rigid type variable bound by > the type signature for `lam' at EvalTaglessF.hs:248:26 > Expected type: Z b1 String > Inferred type: Z b String > In the expression: Z . f . unZ > In the definition of `fz': fz = Z . f . unZ > > EvalTaglessF.hs:264:22: > Couldn't match expected type `a1' against inferred type `a' > `a1' is a rigid type variable bound by > the type signature for `fz' at EvalTaglessF.hs:263:17 > `a' is a rigid type variable bound by > the type signature for `lam' at EvalTaglessF.hs:248:16 > Expected type: Z a1 String > Inferred type: Z a String > In the second argument of `(.)', namely `unZ' > In the second argument of `(.)', namely `f . unZ' > Failed, modules loaded: none. > > > > I hope this gives you a hint, if any. I am not exactly sure about how to > solve this but I might try using scoped type variables extension somehow if > I were in your shoe. > > > _______________________________________________ > 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/20090702/08e1cf0e/attachment.html From kyagrd at gmail.com Thu Jul 2 20:17:13 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Thu Jul 2 20:00:12 2009 Subject: [Haskell-cafe] here is how I made it type check In-Reply-To: References: <24314553.post@talk.nabble.com> Message-ID: I don't know if this is what you want but I was at least able to make it to type check basically changing (fz . return) into simply return. I think the error message about the occurs check was because of the fz function is used wrong (or you didn't give it a correct type). -------------- next part -------------- A non-text attachment was scrubbed... Name: EvalTaglessF.hs Type: text/x-haskell Size: 8647 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090702/bcd224a5/EvalTaglessF.bin From kyagrd at gmail.com Thu Jul 2 20:22:10 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Thu Jul 2 20:07:31 2009 Subject: [Haskell-cafe] Re: Flipping *->*->* kinds, or monadic finally-tagless madness In-Reply-To: <7fb8f82f0907021715ua0495afk5d5e821c0d7f468b@mail.gmail.com> References: <24314553.post@talk.nabble.com> <7fb8f82f0907021715ua0495afk5d5e821c0d7f468b@mail.gmail.com> Message-ID: Edward Kmett ? ?: > Actually the problem lies in your definition of fz, it has the wrong > type to be used in lam. > > The Z you get out of fz as type Z b String, but you need it to have Z (a > -> b) String so that when you strip off the Z you have a Y String (a -> > b) matching the result type of lam. > > To get there replace your definition of fz with: > > > fz :: Z a String -> Z (a -> b) String > > fz = Z . Y . unY . f . unZ I think this seems to be the Yeoh wanted. Mine was just blinded hack just to make it type check without looking at what program means. From wren at freegeek.org Thu Jul 2 20:43:00 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Jul 2 20:25:33 2009 Subject: [Haskell-cafe] [ghc] kind of the function arrow In-Reply-To: <4A4CE3B5.1020202@cl.cam.ac.uk> References: <4A4CE3B5.1020202@cl.cam.ac.uk> Message-ID: <4A4D5414.8020509@freegeek.org> Dominic Orchard wrote: > I was just playing around and noticed that the kind of the function > arrow in GHC is (?? -> ? -> *) when I (naively) expected it to be (* -> > * -> *). > After looking at > (http://hackage.haskell.org/packages/archive/ghc/6.10.2/doc/html/Type.html#5) > I see that the kind of (->) means that the parameter type cannot be an > unboxed tuple, whilst the result type can be anything. Why is this? > After reading this documentation I would expect the kind (? -> ? -> *). Unboxed tuples don't exist. That is, they are in evidence, but they don't actually have any physical representation. The elements of an unboxed tuple are stored in registers when returning from a function, so that the caller can access them immediately (rather than needing to indirect through a pointer to a tuple). ISTR that because of this strategy, there are restrictions on what types of tuples can be unboxed. Theoretically GHC could also allow passing certain arguments in registers when invoking a function, but this isn't supported as yet. -- Live well, ~wren From wren at freegeek.org Thu Jul 2 20:59:01 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Jul 2 20:41:31 2009 Subject: [Haskell-cafe] ANN: TernaryTrees-0.1.1.1 - An efficient ternary tree implementation of Sets and Maps In-Reply-To: <20090702234547.GA29884@whirlpool.galois.com> References: <20090629161316.GB18404@brighton.ac.uk> <6AC4BCCD-1F7E-48FC-B49C-85326510D532@gmail.com> <4A4D44EA.6000408@freegeek.org> <20090702234547.GA29884@whirlpool.galois.com> Message-ID: <4A4D57D5.4000905@freegeek.org> Don Stewart wrote: > wren: >> Alex Mason wrote: >>> TernaryTrees is a package that extends Data.Set ad Data.Map with some >>> ternary tree structures, based on the article >>> [http://www.pcplus.co.uk/node/3074/] . >> For the string (or rather ByteString) version: >> >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-trie >> >> Which has a number of other significant performance improvements (e.g. >> node fusion, ByteString instead of String) and a highly expressive >> interface. Because it uses ByteStrings it can trie any type which can be >> serialized into a vector of bits[1], albeit indirectly. >> >> The real trick with tries is not in just having them[2], it's in having >> the right interface to make use of what they're good at. For example, if >> I have multiple tries, I'd like to merge them without doing it element >> by element[3]. Or if I know I'm going to be making a number of similar >> queries, it'd be nice if I could cache my position in the trie[4] to >> avoid repeating the work for the prefixes of all my queries[5]. Using >> tricks like these leads to significant improvements over using them like >> hashtables; tries aren't hashtables just like lists aren't arrays. > > Do you have benchmarks? Somewhere in my email archive (care of Mark Wotton). I'll see if I can dig them up this weekend. The biggest issue here is finding nice datasets (and tasks) to give reasonable benchmarks for. Reading in all of /usr/dict (or the Brown corpus) and looking up all keys only gives one perspective (or two), and not necessarily the most helpful one for "real world" use. I haven't found any good dataset/task suites like there are for the Language Benchmarks Game, though I'd love to hear about one. The tries /= hashtables comment stems from discussions on various haskell blogs with people inventing their own (or wanting to benchmark Data.Map vs hashtables vs tries vs bloomfilters). As a drop-in replacement tries will perform adequately, but they're nothing overwhelming; the overwhelming comes from changing the usage algorithms to match the "stride" of the datastructure. I don't think I have links to these discussions anymore to pull up code examples. -- Live well, ~wren From ekmett at gmail.com Thu Jul 2 21:49:18 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Jul 2 21:31:46 2009 Subject: [Haskell-cafe] Flipping *->*->* kinds, or monadic finally-tagless madness In-Reply-To: <24314553.post@talk.nabble.com> References: <24314553.post@talk.nabble.com> Message-ID: <7fb8f82f0907021849m105018cy1651ac7799c2e137@mail.gmail.com> You might also look at doing it without all the State monad noise with something like: > class Symantics repr where > int :: Int -> repr Int > add :: repr Int -> repr Int -> repr Int > lam :: (repr a -> repr b) -> repr (a->b) > app :: repr (a -> b) -> repr a -> repr b > newtype Pretty a = Pretty { runPretty :: [String] -> String } > pretty :: Pretty a -> String > pretty (Pretty f) = f vars where > vars = [ [i] | i <- ['a'..'z']] ++ [i : show j | j <- [1..], i <- ['a'..'z'] ] > instance Symantics Pretty where > int = Pretty . const . show > add x y = Pretty $ \vars -> "(" ++ runPretty x vars ++ " + " ++ runPretty y vars ++ ")" > lam f = Pretty $ \ (v:vars) -> "(\\" ++ v ++ ". " ++ runPretty (f (var v)) vars ++ ")" where > var = Pretty . const > app f x = Pretty $ \vars -> "(" ++ runPretty f vars ++ " " ++ runPretty x vars ++ ")" -Edward Kmett On Thu, Jul 2, 2009 at 5:52 PM, Kim-Ee Yeoh wrote: > > I'm trying to write HOAS Show instances for the finally-tagless > type-classes using actual State monads. > > The original code: > http://okmij.org/ftp/Computation/FLOLAC/EvalTaglessF.hs > > Two type variables are needed: one to vary over the Symantics > class (but only as a phantom type) and another to vary over the > Monad class. Hence, the use of 2-variable type constructors. > > > type VarCount = int > > newtype Y b a = Y {unY :: VarCount -> (b, VarCount)} > > Not knowing of a type-level 'flip', I resort to newtype isomorphisms: > > > newtype Z a b = Z {unZ :: Y b a} > > instance Monad (Z a) where > > return x = Z $ Y $ \c -> (x,c) > > (Z (Y m)) >>= f = Z $ Y $ \c0 -> let (x,c1) = m c0 in (unY . unZ) (f > > x) c1 -- Pace, too-strict puritans > > instance MonadState String (Z a) where > > get = Z $ Y $ \c -> (show c, c) > > put x = Z $ Y $ \_ -> ((), read x) > > So far so good. Now for the Symantics instances (abridged). > > > class Symantics repr where > > int :: Int -> repr Int -- int literal > > add :: repr Int -> repr Int -> repr Int > > lam :: (repr a -> repr b) -> repr (a->b) > > > instance Symantics (Y String) where > > int = unZ . return . show > > add x y = unZ $ do > > sx <- Z x > > sy <- Z y > > return $ "(" ++ sx ++ " + " ++ sy ++ ")" > > The add function illustrates the kind of do-sugaring we know and love > that I want to use for Symantics. > > > lam f = unZ $ do > > show_c0 <- get > > let > > vname = "v" ++ show_c0 > > c0 = read show_c0 :: VarCount > > c1 = succ c0 > > fz :: Z a String -> Z b String > > fz = Z . f . unZ > > put (show c1) > > s <- (fz . return) vname > > return $ "(\\" ++ vname ++ " -> " ++ s ++ ")" > > Now with lam, I get this cryptic error message (under 6.8.2): > > Occurs check: cannot construct the infinite type: b = a -> b > When trying to generalise the type inferred for `lam' > Signature type: forall a1 b1. > (Y String a1 -> Y String b1) -> Y String (a1 -> > b1) > Type to generalise: forall a1 b1. > (Y String a1 -> Y String b1) -> Y String (a1 -> > b1) > In the instance declaration for `Symantics (Y String)' > > Both the two types in the error message are identical, which suggests > no generalization is needed. I'm puzzled why ghc sees an infinite type. > > Any ideas on how to proceed? > > -- > View this message in context: > http://www.nabble.com/Flipping-*-%3E*-%3E*-kinds%2C-or-monadic-finally-tagless-madness-tp24314553p24314553.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090702/0348a65a/attachment.html From fernanbolando at mailc.net Thu Jul 2 23:05:21 2009 From: fernanbolando at mailc.net (Fernan Bolando) Date: Thu Jul 2 22:47:51 2009 Subject: [Haskell-cafe] How to declare a Typeless Function Message-ID: <1d5d51400907022005g7f991cafoe17521a6d826d389@mail.gmail.com> Hi I have a function that swaps rows of an array of double swap :: Array (Int,Int) Double -> [Int] -> Array (Int,Int) Double I then create a function that swaps rows of arrays of Complex Double swap :: Array (Int, Int) (Complex Double) -> [Int] -> Array (Int, Int) (Complex Double) In reality the function swap does not care whether its working on a double or a complex number. how do I declare swap so that it will work whether it's a complex or a double array. I tried googling but I wasn't sure what to google. fernan -- http://www.fernski.com From alexander.dunlap at gmail.com Thu Jul 2 23:43:40 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Thu Jul 2 23:26:32 2009 Subject: [Haskell-cafe] How to declare a Typeless Function In-Reply-To: <1d5d51400907022005g7f991cafoe17521a6d826d389@mail.gmail.com> References: <1d5d51400907022005g7f991cafoe17521a6d826d389@mail.gmail.com> Message-ID: <57526e770907022043x268d57e3p70838357d1d4cd12@mail.gmail.com> swap :: Array (Int, Int) a -> [Int] -> Array (Int, Int) a The lowercase "a" means that that type variable is polymorphic, i.e. it can be any type. Alex On Thu, Jul 2, 2009 at 8:05 PM, Fernan Bolando wrote: > Hi > > I have a function that swaps rows of an array of double > > swap :: Array (Int,Int) Double -> [Int] -> Array (Int,Int) Double > > I then create a function that swaps rows of arrays of Complex Double > > swap :: Array (Int, Int) (Complex Double) -> [Int] -> Array (Int, Int) > (Complex Double) > > In reality the function swap does not care whether its working on a > double or a complex number. > how do I declare swap so that it will work whether it's a complex or a > double array. > > I tried googling but I wasn't sure what to google. > > fernan > -- > http://www.fernski.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From magicloud.magiclouds at gmail.com Fri Jul 3 00:00:05 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Jul 2 23:42:33 2009 Subject: [Haskell-cafe] How to present the commonness of some objects? Message-ID: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> Hi, I thought "class" was for this purpose. But it turns out not. Code as following could not compiled. 1 main = do 2 mapM_ (\(x, y, widget) -> do 3 a <- widgetRun widget 4 putStrLn $ show a 5 ) widgetList 6 7 widgetList :: (Widget w) => [(Integer, Integer, w)] 8 widgetList = [] 9 10 class Widget w where 11 widgetRun :: w -> IO () --- % ghc --make tmp/test.hs [1 of 1] Compiling Main ( tmp/test.hs, /tmp/Main.o ) tmp/test.hs:3:16: Ambiguous type variable `t' in the constraint: `Widget t' arising from a use of `widgetRun' at tmp/test.hs:3:16-31 Probable fix: add a type signature that fixes these type variable(s) -- ??????? ??????? From rmm-haskell at z.odi.ac Fri Jul 3 00:24:39 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Jul 3 00:07:22 2009 Subject: [Haskell-cafe] How to present the commonness of some objects? In-Reply-To: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> References: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> Message-ID: You have a couple problems here. The first is that GHC has no idea what particular type 'w' widgetList has, because the empty list is polymorphic. The second is that it looks like you probably want a heterogeneous list of widgets -- that is, possibly different types of widget as long as they all conform to Widget. To do this you'll need ExistentialQuantification (or GADTs I guess?). For example: {-# LANGUAGE ExistentialQuantification #-} class Widget w where widgetRun :: w -> IO () data SomeWidget = forall w. Widget w => SomeWidget w widgetList :: [(Integer, Integer, SomeWidget)] widgetList = [] main = mapM aux widgetList aux (x, y, sw) = case sw of SomeWidget w -> widgetRun w Note that the type variable for widgetList 'w' has disappeared. Before, with the type variable 'w', all elements of the widgetList had to be of the same type (lists being homogeneous). By wrapping up the type variable 'w' inside SomeWidget, you can now have whatever types of widgets in that SomeWidget, e.g. data Button = Button (IO ()) instance Widget Button where widgetRun = ... data Label = Label (String -> IO ()) instance Widget Label where widgetRun = ... widgetList:: [(Integer, Integer, SomeWidget)] widgetList = [ SomeWidget (Button $ putStrLn "ding!") , SomeWidget (Label $ putStrLn . ("entered: " ++)) ] Before, without existential quantification, you had to have all the same type of widget (e.g. all Button or all Label) Hope this makes it more clear. -Ross On Jul 3, 2009, at 12:00 AM, Magicloud Magiclouds wrote: > Hi, > I thought "class" was for this purpose. But it turns out not. > Code as following could not compiled. > > 1 main = do > 2 mapM_ (\(x, y, widget) -> do > 3 a <- widgetRun widget > 4 putStrLn $ show a > 5 ) widgetList > 6 > 7 widgetList :: (Widget w) => [(Integer, Integer, w)] > 8 widgetList = [] > 9 > 10 class Widget w where > 11 widgetRun :: w -> IO () > --- > % ghc --make tmp/test.hs > [1 of 1] Compiling Main ( tmp/test.hs, /tmp/Main.o ) > > tmp/test.hs:3:16: > Ambiguous type variable `t' in the constraint: > `Widget t' arising from a use of `widgetRun' at tmp/test.hs: > 3:16-31 > Probable fix: add a type signature that fixes these type > variable(s) > -- > ??????? > ??????? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From magicloud.magiclouds at gmail.com Fri Jul 3 00:32:37 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Jul 3 00:15:05 2009 Subject: [Haskell-cafe] How to present the commonness of some objects? In-Reply-To: References: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> Message-ID: <3bd412d40907022132o6eba9226v4c899161c0ccefd3@mail.gmail.com> Wow, this complex.... Thank you. I will try that. On Fri, Jul 3, 2009 at 12:24 PM, Ross Mellgren wrote: > You have a couple problems here. > > The first is that GHC has no idea what particular type 'w' widgetList has, > because the empty list is polymorphic. > > The second is that it looks like you probably want a heterogeneous list of > widgets -- that is, possibly different types of widget as long as they all > conform to Widget. To do this you'll need ExistentialQuantification (or > GADTs I guess?). > > For example: > > {-# LANGUAGE ExistentialQuantification #-} > > class Widget w where > ? ?widgetRun :: w -> IO () > > data SomeWidget = forall w. Widget w => SomeWidget w > > widgetList :: [(Integer, Integer, SomeWidget)] > widgetList = [] > > main = mapM aux widgetList > ? ?aux (x, y, sw) = > ? ? ? ?case sw of > ? ? ? ? ? ?SomeWidget w -> widgetRun w > > Note that the type variable for widgetList 'w' has disappeared. Before, with > the type variable 'w', all elements of the widgetList had to be of the same > type (lists being homogeneous). By wrapping up the type variable 'w' inside > SomeWidget, you can now have whatever types of widgets in that SomeWidget, > e.g. > > data Button = Button (IO ()) > instance Widget Button where widgetRun = ... > > data Label = Label (String -> IO ()) > instance Widget Label where widgetRun = ... > > widgetList:: [(Integer, Integer, SomeWidget)] > widgetList = > ? ?[ SomeWidget (Button $ putStrLn "ding!") > ? ?, SomeWidget (Label $ putStrLn . ("entered: " ++)) ] > > Before, without existential quantification, you had to have all the same > type of widget (e.g. all Button or all Label) > > Hope this makes it more clear. > > -Ross > > On Jul 3, 2009, at 12:00 AM, Magicloud Magiclouds wrote: > >> Hi, >> ?I thought "class" was for this purpose. But it turns out not. >> ?Code as following could not compiled. >> >> 1 main = do >> 2 ? mapM_ (\(x, y, widget) -> do >> 3 ? ? ? ? ? ?a <- widgetRun widget >> 4 ? ? ? ? ? ?putStrLn $ show a >> 5 ? ? ? ? ) widgetList >> 6 >> 7 widgetList :: (Widget w) => [(Integer, Integer, w)] >> 8 widgetList = [] >> 9 >> 10 class Widget w where >> 11 ? widgetRun :: w -> IO () >> --- >> % ghc --make tmp/test.hs >> [1 of 1] Compiling Main ? ? ? ? ? ? ( tmp/test.hs, /tmp/Main.o ) >> >> tmp/test.hs:3:16: >> ? Ambiguous type variable `t' in the constraint: >> ? ? `Widget t' arising from a use of `widgetRun' at tmp/test.hs:3:16-31 >> ? Probable fix: add a type signature that fixes these type variable(s) >> -- >> ??????? >> ??????? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- ??????? ??????? From lrpalmer at gmail.com Fri Jul 3 03:08:42 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Jul 3 02:51:14 2009 Subject: [Haskell-cafe] How to present the commonness of some objects? In-Reply-To: <3bd412d40907022132o6eba9226v4c899161c0ccefd3@mail.gmail.com> References: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> <3bd412d40907022132o6eba9226v4c899161c0ccefd3@mail.gmail.com> Message-ID: <7ca3f0160907030008p43aa6f63l228ddebdc4c399e7@mail.gmail.com> On Thu, Jul 2, 2009 at 8:32 PM, Magicloud Magiclouds < magicloud.magiclouds@gmail.com> wrote: > Wow, this complex.... Thank you. I will try that. No, don't! There is an easier way. Don't use a class, just use a record. I would translate your class as: data Widget = Widget { widgetRun :: IO () } If you need more capabilities, add them as fields in this record. There is no need for typeclasses here. Keep in mind that with this solution *and* with the ExistentialQuantification solution, there is no possibility of downcasting. I.e. if you were planning on making a GraphicalWidget subclass, and them somewhere seeing if a a Widget is actually a GraphicalWidget, you will be disappointed. The solution in this case is to redesign your software not to need downcasting. This is the point at which you are forced to move away from OO thinking. Luke > > On Fri, Jul 3, 2009 at 12:24 PM, Ross Mellgren > wrote: > > You have a couple problems here. > > > > The first is that GHC has no idea what particular type 'w' widgetList > has, > > because the empty list is polymorphic. > > > > The second is that it looks like you probably want a heterogeneous list > of > > widgets -- that is, possibly different types of widget as long as they > all > > conform to Widget. To do this you'll need ExistentialQuantification (or > > GADTs I guess?). > > > > For example: > > > > {-# LANGUAGE ExistentialQuantification #-} > > > > class Widget w where > > widgetRun :: w -> IO () > > > > data SomeWidget = forall w. Widget w => SomeWidget w > > > > widgetList :: [(Integer, Integer, SomeWidget)] > > widgetList = [] > > > > main = mapM aux widgetList > > aux (x, y, sw) = > > case sw of > > SomeWidget w -> widgetRun w > > > > Note that the type variable for widgetList 'w' has disappeared. Before, > with > > the type variable 'w', all elements of the widgetList had to be of the > same > > type (lists being homogeneous). By wrapping up the type variable 'w' > inside > > SomeWidget, you can now have whatever types of widgets in that > SomeWidget, > > e.g. > > > > data Button = Button (IO ()) > > instance Widget Button where widgetRun = ... > > > > data Label = Label (String -> IO ()) > > instance Widget Label where widgetRun = ... > > > > widgetList:: [(Integer, Integer, SomeWidget)] > > widgetList = > > [ SomeWidget (Button $ putStrLn "ding!") > > , SomeWidget (Label $ putStrLn . ("entered: " ++)) ] > > > > Before, without existential quantification, you had to have all the same > > type of widget (e.g. all Button or all Label) > > > > Hope this makes it more clear. > > > > -Ross > > > > On Jul 3, 2009, at 12:00 AM, Magicloud Magiclouds wrote: > > > >> Hi, > >> I thought "class" was for this purpose. But it turns out not. > >> Code as following could not compiled. > >> > >> 1 main = do > >> 2 mapM_ (\(x, y, widget) -> do > >> 3 a <- widgetRun widget > >> 4 putStrLn $ show a > >> 5 ) widgetList > >> 6 > >> 7 widgetList :: (Widget w) => [(Integer, Integer, w)] > >> 8 widgetList = [] > >> 9 > >> 10 class Widget w where > >> 11 widgetRun :: w -> IO () > >> --- > >> % ghc --make tmp/test.hs > >> [1 of 1] Compiling Main ( tmp/test.hs, /tmp/Main.o ) > >> > >> tmp/test.hs:3:16: > >> Ambiguous type variable `t' in the constraint: > >> `Widget t' arising from a use of `widgetRun' at tmp/test.hs:3:16-31 > >> Probable fix: add a type signature that fixes these type variable(s) > >> -- > >> ??????? > >> ??????? > >> _______________________________________________ > >> 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/20090703/4b6ebcdf/attachment.html From bulat.ziganshin at gmail.com Fri Jul 3 03:10:15 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Jul 3 02:53:53 2009 Subject: [Haskell-cafe] How to present the commonness of some objects? In-Reply-To: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> References: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> Message-ID: <976200668.20090703111015@gmail.com> Hello Magicloud, > I thought "class" was for this purpose. But it turns out not. http://haskell.org/haskellwiki/OOP_vs_type_classes -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From magnus at therning.org Fri Jul 3 03:54:29 2009 From: magnus at therning.org (Magnus Therning) Date: Fri Jul 3 03:36:59 2009 Subject: [Haskell-cafe] How to declare a Typeless Function In-Reply-To: <57526e770907022043x268d57e3p70838357d1d4cd12@mail.gmail.com> References: <1d5d51400907022005g7f991cafoe17521a6d826d389@mail.gmail.com> <57526e770907022043x268d57e3p70838357d1d4cd12@mail.gmail.com> Message-ID: On Fri, Jul 3, 2009 at 4:43 AM, Alexander Dunlap wrote: > swap :: Array (Int, Int) a -> [Int] -> Array (Int, Int) a > > The lowercase "a" means that that type variable is polymorphic, i.e. > it can be any type. Another option would be to simply not put in type of 'swap', load it in ghci and see what the compiler says the type is :-) /M > On Thu, Jul 2, 2009 at 8:05 PM, Fernan Bolando wrote: >> Hi >> >> I have a function that swaps rows of an array of double >> >> swap :: Array (Int,Int) Double -> [Int] -> Array (Int,Int) Double >> >> I then create a function that swaps rows of arrays of Complex Double >> >> swap :: Array (Int, Int) (Complex Double) -> [Int] -> Array (Int, Int) >> (Complex Double) >> >> In reality the function swap does not care whether its working on a >> double or a complex number. >> how do I declare swap so that it will work whether it's a complex or a >> double array. >> >> I tried googling but I wasn't sure what to google. >> >> fernan >> -- >> http://www.fernski.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 > -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From jvlask at hotmail.com Fri Jul 3 04:13:42 2009 From: jvlask at hotmail.com (John Lask) Date: Fri Jul 3 03:59:14 2009 Subject: [Haskell-cafe] hiding instance definitions in imported modules or redefining them, can it be done? Message-ID: Is there a way to hide instance definitions when importing a module for instance I want to import Data.Monoid but wish to redefine the instance of Monoid for ( a->b) I don't suppose this is possible? Specifically, I wish to define a specialised instance of Monoid for String->Int, but it seems overlapping instances will not give me what I want, as this option seems to need to be applied at the definition site (aka Data.Monoid module, looking for confirmation of this?). The easy fix is just to do newtype M a b = M (a->b) etc..., but I was hopping to avoid this. I've encountered this issue several times. Why can't we redefine instances? I can't of thought that there are any seriouse technical issues in doing so? If so what are they? jvl From apfelmus at quantentunnel.de Fri Jul 3 04:44:42 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Jul 3 04:27:12 2009 Subject: [Haskell-cafe] Re: A Strict GCL Interpreter in Haskell In-Reply-To: <4A4D3D43.5020202@cs.au.dk> References: <1933439637-1246573275-cardhu_decombobulator_blackberry.rim.net-1042301844-@bxe1035.bisx.prod.on.blackberry> <4A4D3D43.5020202@cs.au.dk> Message-ID: Tillmann Rendel wrote: > Now we can write our interpreter: > > eval :: Expression -> Result > eval (Literal n) > = Number n > > eval (Add a b) > = case eval a of > Number result_of_a > -> case b of > Number result_of_b > -> Number (result_of_a + result_of_b) > > DivideByZeroError > -> DivideByZeroError > > DivideByZeroError > -> DivideByZeroError > > > eval (Add a b) > = case eval a of > Number result_of_a > -> case b of > Number result_of_b > -> if b == 0 > then DivideByZeroError > else Number (result_of_a + result_of_b) > > DivideByZeroError > -> DivideByZeroError > > DivideByZeroError > -> DivideByZeroError > > > This interpreter will stop as soon as it encounters a division by zero, > because we take care to return DivideByZeroError whenever we see a > DivideByZeroError in one of the subterms. > > So you have to use an appropriate return type (like (Either String Int) > or Result), and you have to pattern match on the result of "earlier" > parts of your program, and propagate the error. And of course, these case expression are a case for the error monad. I think that Wadler's paper is a great introduction to writing an interpreter like the one at discussion here Monads for functional programming. Philip Wadler. http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf Regards, apfelmus -- http://apfelmus.nfshost.com From scook0 at gmail.com Fri Jul 3 05:15:53 2009 From: scook0 at gmail.com (Stuart Cook) Date: Fri Jul 3 04:58:21 2009 Subject: [Haskell-cafe] How to present the commonness of some objects? In-Reply-To: <7ca3f0160907030008p43aa6f63l228ddebdc4c399e7@mail.gmail.com> References: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> <3bd412d40907022132o6eba9226v4c899161c0ccefd3@mail.gmail.com> <7ca3f0160907030008p43aa6f63l228ddebdc4c399e7@mail.gmail.com> Message-ID: <49b351060907030215s2cac03a7pdef413be8f5339a3@mail.gmail.com> 2009/7/3 Luke Palmer : > Keep in mind that with this solution *and* with the > ExistentialQuantification solution, there is no possibility of downcasting. > ?I.e. if you were planning on making a GraphicalWidget subclass, and them > somewhere seeing if a a Widget is actually a GraphicalWidget, you will be > disappointed. ?The solution in this case is to redesign your software not to > need downcasting. ?This is the point at which you are forced to move away > from OO thinking. Heck, as far as I'm aware most OO communities frown on downcasting too. The "OO approach" is to call a virtual method and let the object decide to do, which (with enough hand-waving) is basically what you end up doing here anyway. Stuart From jochem at functor.nl Fri Jul 3 05:28:14 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Fri Jul 3 05:10:45 2009 Subject: [Haskell-cafe] ORM for haskell? In-Reply-To: <2DFE45C5-EC7E-4EC6-AD77-815C9236FE47@eidhof.nl> References: <20090630175208.GE6272@gmx.de> <2DFE45C5-EC7E-4EC6-AD77-815C9236FE47@eidhof.nl> Message-ID: <4A4DCF2E.8070100@functor.nl> Chris Eidhof wrote: > I've something working that sort of does this. You define your model in > the following way: > > data User = User {name :: String, password :: String, age :: Int, post > :: BelongsTo Post} > data Post = Post {title :: String, body :: String} > > Then there's some boilerplate code (that ultimately will be generated by > TH), and from that moment on you can do things like this: > > test = do > conn <- connectSqlite3 "example.sqlite3" > runDB conn $ do > user <- fromJust <$> find typeUser 1 > user' <- fillBelongsTo user relPost > return (post user') > By default, no relations will be fetched, but by doing the fillBelongsTo > the user will be updated. I currently have support for new, update and > find. All of this code is very alpha, and only works using HDBC and > Sqlite3, but still. So in this example, both user and user' are of type User, but if I ask for "post user", this is undefined? I have done something similar as you, except that I filled the related field with an unsafePerformIO fetching the related data from the database. Regards, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From jwlato at gmail.com Fri Jul 3 05:48:37 2009 From: jwlato at gmail.com (John Lato) Date: Fri Jul 3 05:31:05 2009 Subject: [Haskell-cafe] Re: Monad Input/Output and Monad Transformers Message-ID: <9979e72e0907030248y650a8d2aq10a2ef075df98660@mail.gmail.com> > From: Maciej Piechotka > > 1. Learning haskell I discovered that I/O should be avoided nearly 'at > all costs'. The problem is that the IO monad is the only one which have > more interactive work flow. There is Reader/Writer monad but in fact > AFAIU first one is about the environment and second one is about > logging. Implementation of Writer can be defined in terms of handles but > it is rather limited (either non-full implementation which may be > confusing or need of caching the result for pass etc.). > I'm not sure what you mean when you say that IO is the only monad with a "more interactive work flow". Do you mean that it allows interleaving of input and output? If so, I would ask what you're doing that makes this a concern. If it's for efficiency, don't worry about it. Haskell's laziness means that the language will take care of this for you. A good example is the bzlib[1] package; the "compress" function has type "ByteString -> ByteString" and automatically handles the chunking of data for you. If you need to partially process an input to determine how the rest of the input should be handled, there are many parser libraries (parsec[2], polyparse[3], etc.) that can either help with this directly or perhaps give ideas as to how you can handle it. You may also want to look at the iteratee[4] package. It sounds like it may accomplish what you're trying to do, although the interface is very different from what you specify. > > 2. I find writing monad transformers annoying. > Additionally if package defines transformer A and another transformer B > they need to be connected 'by hand'. > If this becomes onerous, I think the usual solution is to define custom lifting functions for the most commonly performed operations. However, my feeling is that you're probably trying to put together a monad stack to model what you're trying to do too soon, when you'd be better served trying to develop data structures and core functions that describe what you want to do. Of course, without more information this is just a guess. John Lato [1] http://hackage.haskell.org/package/bzlib [2] http://legacy.cs.uu.nl/daan/parsec.html, http://hackage.haskell.org/package/parsec [3] http://www.cs.york.ac.uk/fp/polyparse/, http://hackage.haskell.org/package/polyparse [4] http://okmij.org/ftp/Haskell/Iteratee/, http://hackage.haskell.org/package/iteratee From chris at eidhof.nl Fri Jul 3 06:51:20 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Fri Jul 3 06:34:50 2009 Subject: [Haskell-cafe] ORM for haskell? In-Reply-To: <4A4DCF2E.8070100@functor.nl> References: <20090630175208.GE6272@gmx.de> <2DFE45C5-EC7E-4EC6-AD77-815C9236FE47@eidhof.nl> <4A4DCF2E.8070100@functor.nl> Message-ID: On 3 jul 2009, at 11:28, Jochem Berndsen wrote: > Chris Eidhof wrote: >> I've something working that sort of does this. You define your >> model in >> the following way: >> >> data User = User {name :: String, password :: String, age :: Int, >> post >> :: BelongsTo Post} >> data Post = Post {title :: String, body :: String} >> >> Then there's some boilerplate code (that ultimately will be >> generated by >> TH), and from that moment on you can do things like this: >> >> test = do >> conn <- connectSqlite3 "example.sqlite3" >> runDB conn $ do >> user <- fromJust <$> find typeUser 1 >> user' <- fillBelongsTo user relPost >> return (post user') > > >> By default, no relations will be fetched, but by doing the >> fillBelongsTo >> the user will be updated. I currently have support for new, update >> and >> find. All of this code is very alpha, and only works using HDBC and >> Sqlite3, but still. > > So in this example, both user and user' are of type User, but if I ask > for "post user", this is undefined? > I have done something similar as you, except that I filled the related > field with an unsafePerformIO fetching the related data from the > database. No, it will never be undefined. The BelongsTo datatype is defined as following: data BelongsTo a = BTNotFetched | BTId Int | BTFetched (Int, a) So either there is no information available (BTNotFetched), we know the id (the foreign key, BTId) or we know the id and the value (BTFetched). It is currently just a proof of concept, but for me, an extend version of this will do. I think that almost every mapping from Haskell datatypes to a RDBMS will be slightly awkward, this is my way to find a balance ;) -chris From jfredett at gmail.com Fri Jul 3 08:31:08 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri Jul 3 08:13:39 2009 Subject: [Haskell-cafe] How to declare a Typeless Function In-Reply-To: References: <1d5d51400907022005g7f991cafoe17521a6d826d389@mail.gmail.com> <57526e770907022043x268d57e3p70838357d1d4cd12@mail.gmail.com> Message-ID: <4A4DFA0C.5070607@gmail.com> It's important to note that such a function is not "Typeless" but rather "Polymorphic" -- that is, it is a type which can be satisfied for many values of it's type variables. For instance, the function `(+) :: Num a => a -> a -> a` is polymorphic, since it's one type variable can be satisfied by any instance of the `Num` class. It's not that the `(+)` function is "Typeless" (implying that it has no type) precisely the opposite, it has _many_ types. Haskell is clever enough to figure out which one you mean as you use it (most of the time, anyway). /Joe Magnus Therning wrote: > On Fri, Jul 3, 2009 at 4:43 AM, Alexander > Dunlap wrote: > >> swap :: Array (Int, Int) a -> [Int] -> Array (Int, Int) a >> >> The lowercase "a" means that that type variable is polymorphic, i.e. >> it can be any type. >> > > Another option would be to simply not put in type of 'swap', load it > in ghci and see what the compiler says the type is :-) > > /M > > >> On Thu, Jul 2, 2009 at 8:05 PM, Fernan Bolando wrote: >> >>> Hi >>> >>> I have a function that swaps rows of an array of double >>> >>> swap :: Array (Int,Int) Double -> [Int] -> Array (Int,Int) Double >>> >>> I then create a function that swaps rows of arrays of Complex Double >>> >>> swap :: Array (Int, Int) (Complex Double) -> [Int] -> Array (Int, Int) >>> (Complex Double) >>> >>> In reality the function swap does not care whether its working on a >>> double or a complex number. >>> how do I declare swap so that it will work whether it's a complex or a >>> double array. >>> >>> I tried googling but I wasn't sure what to google. >>> >>> fernan >>> -- >>> http://www.fernski.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 >> >> > > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 307 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090703/89c365aa/jfredett.vcf From almeidaraf at gmail.com Fri Jul 3 09:55:12 2009 From: almeidaraf at gmail.com (Rafael Almeida) Date: Fri Jul 3 09:37:39 2009 Subject: [Haskell-cafe] On the parallel between java annotations and monads Message-ID: <6de6b1650907030655re55badt55420282e5918c0@mail.gmail.com> Hello, After an extensive search (5 minutes googling) I could not find any comparison between Java annotations (or Python annotations for that matter) and Monads. I think they are similar in various aspects and I want to discuss them here. I'm sure several of you have experience with Java programming and its annotation system. At first they seem like an extension to the typing system, by using annotations a single variable or method may have more than one type: the real type and all the annotations types. The way you declare them is not important for this discussion, but assume that you've created the annotations GreaterThanFive and LessThanTwenty, you could annotate a method like this (let's forget about all the class verbosity for a while): @GreaterThanFive @LessThanTwenty int doYourThing(); You could than use reflection to read those annotations and you could check if the returned integer is in the correct range. You could even make the compiler generate code that will do that checking automatically for you. Even though that was my first impression of them, that's not really how they are used in practice (at least the practice that I have experimented). People use them to implement Monad-like features to the language. Actually, you can forget monad and think of computation containers. On an EJB environment there's something called a container and it will do all sorts of computations when you call an annotated method or when you create a new annotated class. For instance, if, inside of an entity bean, you annotate a variable like this: @Column(name = "NAME") private String name; then, when you create a method like so: public String getName() { return name; } that name is actually something retrieved from the database, even though, it looks just like something in memory. As far as I know the interaction with monads for handling databases is not very different. There are other annotations which allows the container to "inject" some object on a variable, such as: @PersistenceContext private EntityManager entityManager; now you won't even create an EntityManager instance, but will use the object living inside the container. I compare that to getting a value from an State Monad. Like there, you'll do some computations using entityManager, but it will ultimately be returned to the container. While each computational container in Haskell is very rigid and well defined, in java there's nothing rigorous about the annotation. However, quite often the annotations in Java are used in a manner similar to the implementation of a Monad in Java. []'s Rafael From ekirpichov at gmail.com Fri Jul 3 10:40:06 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri Jul 3 10:22:33 2009 Subject: [Haskell-cafe] On the parallel between java annotations and monads In-Reply-To: <6de6b1650907030655re55badt55420282e5918c0@mail.gmail.com> References: <6de6b1650907030655re55badt55420282e5918c0@mail.gmail.com> Message-ID: <5e0214850907030740q5fa531bl3403558e410e0fe1@mail.gmail.com> Could you clarify on what is the precise relationship between the annotations and monads? Or at least an example, like, "The @Foo annotation corresponds to the Cont monad in the following way:..." I personally don't see any connection at all, although I'm rather familiar with both. 2009/7/3 Rafael Almeida : > Hello, > > After an extensive search (5 minutes googling) I could not find any comparison > between Java annotations (or Python annotations for that matter) and Monads. I > think they are similar in various aspects and I want to discuss them here. > > I'm sure several of you have experience with Java programming and its annotation > system. At first they seem like an extension to the typing system, by using > annotations a single variable or method may have more than one type: the real > type and all the annotations types. The way you declare them is not important > for this discussion, but assume that you've created the annotations > GreaterThanFive and LessThanTwenty, you could annotate a method like > this (let's > forget about all the class verbosity for a while): > > ? ? ? ?@GreaterThanFive @LessThanTwenty int doYourThing(); > > You could than use reflection to read those annotations and you could check if > the returned integer is in the correct range. You could even make the compiler > generate code that will do that checking automatically for you. > > Even though that was my first impression of them, that's not really > how they are > used in practice (at least the practice that I have experimented). People use > them to implement Monad-like features to the language. Actually, you can forget > monad and think of computation containers. > > On an EJB environment there's something called a container and it will do all > sorts of computations when you call an annotated method or when you > create a new > annotated class. For instance, if, inside of an entity bean, you annotate a > variable like this: > > ? ? ? ?@Column(name = "NAME") private String name; > > then, when you create a method like so: > > ? ? ? ?public String getName() > ? ? ? ?{ > ? ? ? ? ? ? ? ?return name; > ? ? ? ?} > > that name is actually something retrieved from the database, even though, it > looks just like something in memory. As far as I know the interaction with > monads for handling databases is not very different. There are other annotations > which allows the container to "inject" some object on a variable, such as: > > ? ? ? ?@PersistenceContext private EntityManager entityManager; > > now you won't even create an EntityManager instance, but will use the object > living inside the container. I compare that to getting a value from an State > Monad. Like there, you'll do some computations using entityManager, but it will > ultimately be returned to the container. > > While each computational container in Haskell is very rigid and well > defined, in > java there's nothing rigorous about the annotation. However, quite often the > annotations in Java are used in a manner similar to the implementation of a > Monad in Java. > > []'s > Rafael > _______________________________________________ > 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 r.kelsall at millstream.com Fri Jul 3 11:12:30 2009 From: r.kelsall at millstream.com (Richard Kelsall) Date: Fri Jul 3 10:55:07 2009 Subject: [Haskell-cafe] Monad Input/Output and Monad Transformers In-Reply-To: References: <1246534319.28235.197.camel@notebook.piechotka.com.pl> <7ca3f0160907021318o4313addfv69beea9f04f47e9d@mail.gmail.com> <1246568705.28235.242.camel@notebook.piechotka.com.pl> Message-ID: <4A4E1FDE.2070409@millstream.com> Gwern Branwen wrote: ... > " Ultimately, the problem with Haskell and ML for our purposes is that > the brightest and most aggressive programmers in those languages, > using the most aggressive optimization techniques known to the > research community, remain unable to write systems codes that compete > reasonably with C or C++. The most successful attempt to date is > probably the FoxNet TCP/IP protocol stack, which incurred a 10x > increase in system load and a 40x penalty in accessing external memory > relative to a conventional (and less aggressively optimized) C > implemenation. [ 4 ,6 ]" > > http://www.bitc-lang.org/docs/bitc/bitc-origins.html Interesting paper. Putting these remarks in context, in case anyone takes them as a current critique of Haskell, they are apparently about ten years out-of-date and apply to this SML program http://www.cs.cmu.edu/~fox/foxnet.html I wonder what would happen if the program was ported and benchmarked in a recent version of GHC. Richard. From briqueabraque at yahoo.com Fri Jul 3 11:13:28 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Fri Jul 3 10:56:17 2009 Subject: [Haskell-cafe] Re: hiding instance definitions in imported modules or redefining them, can it be done? In-Reply-To: References: Message-ID: > Is there a way to hide instance definitions when importing a module for > instance No, there isn't. See item 5.4: http://haskell.org/onlinereport/modules.html Best, Maur?cio From briqueabraque at yahoo.com Fri Jul 3 11:39:46 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Fri Jul 3 11:22:32 2009 Subject: [Haskell-cafe] Re: How to present the commonness of some objects? In-Reply-To: <7ca3f0160907030008p43aa6f63l228ddebdc4c399e7@mail.gmail.com> References: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> <3bd412d40907022132o6eba9226v4c899161c0ccefd3@mail.gmail.com> <7ca3f0160907030008p43aa6f63l228ddebdc4c399e7@mail.gmail.com> Message-ID: >> Wow, this complex.... Thank you. I will try that. > No, don't! There is an easier way. > > (...) This is the point at > which you are forced to move away from OO thinking. This seems to be worth clearing a little bit. I usually read people saying that this kind of misundestanding is a confusion with object oriented background, when actually I believe it is not. Magicloud's assumption are all correct, in the Haskell way of thinking. Classes do behave the way he thinks it does. The problem was only that you can't (without existential quantification) build lists of elements with diferent types for each element -- as you also can't do in languages like C++. The way to achieve that in C++ is to use a list of pointers, while in Haskell you can use existential quantification. (Confusion with OO is less of a problem than people use to think it is. I've already been told that something I wanted was OO specific, and I later realized what I needed is available in Haskell and is called associated type, as in type families.) Best, Maur?cio From rmm-haskell at z.odi.ac Fri Jul 3 12:38:51 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Jul 3 12:21:20 2009 Subject: [Haskell-cafe] How to present the commonness of some objects? In-Reply-To: <7ca3f0160907030008p43aa6f63l228ddebdc4c399e7@mail.gmail.com> References: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> <3bd412d40907022132o6eba9226v4c899161c0ccefd3@mail.gmail.com> <7ca3f0160907030008p43aa6f63l228ddebdc4c399e7@mail.gmail.com> Message-ID: <8B8E76B2-F1E8-4F9C-AA7B-BBA0FEE43389@z.odi.ac> Wordy (and yet technically accurate) names aside, isn't this basically the same thing, except that you must pass the dictionary around by hand? What is the advantage of doing the dictionary passing manually, other than being able to avoid the scoping issue (that requires case) and the slightly odd syntax? I'm not saying you're wrong or anything, I'm just curious on your opinion. To expand your example, would you suggest something like: data Widget = Widget { widgetRun :: IO () } data Label = Label (String -> IO ()) data Button = Button (IO ()) labelToWidget = Widget runLabel buttonToWidget = Widget runButton widgetList :: [(Integer, Integer, Widget)] widgetList = [labelToWidget myLabel, buttonToWidget myButton] ? Regarding downcasting, you'd have to use Data.Dynamic or Data.Typeable right? -Ross On Jul 3, 2009, at 3:08 AM, Luke Palmer wrote: > On Thu, Jul 2, 2009 at 8:32 PM, Magicloud Magiclouds > wrote: > Wow, this complex.... Thank you. I will try that. > > No, don't! There is an easier way. > > Don't use a class, just use a record. > > I would translate your class as: > > data Widget = Widget { > widgetRun :: IO () > } > > If you need more capabilities, add them as fields in this record. > There is no need for typeclasses here. > > Keep in mind that with this solution *and* with the > ExistentialQuantification solution, there is no possibility of > downcasting. I.e. if you were planning on making a GraphicalWidget > subclass, and them somewhere seeing if a a Widget is actually a > GraphicalWidget, you will be disappointed. The solution in this > case is to redesign your software not to need downcasting. This is > the point at which you are forced to move away from OO thinking. > > Luke > > > > On Fri, Jul 3, 2009 at 12:24 PM, Ross Mellgren > wrote: > > You have a couple problems here. > > > > The first is that GHC has no idea what particular type 'w' > widgetList has, > > because the empty list is polymorphic. > > > > The second is that it looks like you probably want a heterogeneous > list of > > widgets -- that is, possibly different types of widget as long as > they all > > conform to Widget. To do this you'll need > ExistentialQuantification (or > > GADTs I guess?). > > > > For example: > > > > {-# LANGUAGE ExistentialQuantification #-} > > > > class Widget w where > > widgetRun :: w -> IO () > > > > data SomeWidget = forall w. Widget w => SomeWidget w > > > > widgetList :: [(Integer, Integer, SomeWidget)] > > widgetList = [] > > > > main = mapM aux widgetList > > aux (x, y, sw) = > > case sw of > > SomeWidget w -> widgetRun w > > > > Note that the type variable for widgetList 'w' has disappeared. > Before, with > > the type variable 'w', all elements of the widgetList had to be of > the same > > type (lists being homogeneous). By wrapping up the type variable > 'w' inside > > SomeWidget, you can now have whatever types of widgets in that > SomeWidget, > > e.g. > > > > data Button = Button (IO ()) > > instance Widget Button where widgetRun = ... > > > > data Label = Label (String -> IO ()) > > instance Widget Label where widgetRun = ... > > > > widgetList:: [(Integer, Integer, SomeWidget)] > > widgetList = > > [ SomeWidget (Button $ putStrLn "ding!") > > , SomeWidget (Label $ putStrLn . ("entered: " ++)) ] > > > > Before, without existential quantification, you had to have all > the same > > type of widget (e.g. all Button or all Label) > > > > Hope this makes it more clear. > > > > -Ross > > > > On Jul 3, 2009, at 12:00 AM, Magicloud Magiclouds wrote: > > > >> Hi, > >> I thought "class" was for this purpose. But it turns out not. > >> Code as following could not compiled. > >> > >> 1 main = do > >> 2 mapM_ (\(x, y, widget) -> do > >> 3 a <- widgetRun widget > >> 4 putStrLn $ show a > >> 5 ) widgetList > >> 6 > >> 7 widgetList :: (Widget w) => [(Integer, Integer, w)] > >> 8 widgetList = [] > >> 9 > >> 10 class Widget w where > >> 11 widgetRun :: w -> IO () > >> --- > >> % ghc --make tmp/test.hs > >> [1 of 1] Compiling Main ( tmp/test.hs, /tmp/Main.o ) > >> > >> tmp/test.hs:3:16: > >> Ambiguous type variable `t' in the constraint: > >> `Widget t' arising from a use of `widgetRun' at tmp/test.hs: > 3:16-31 > >> Probable fix: add a type signature that fixes these type > variable(s) > >> -- > >> ??????? > >> ??????? > >> _______________________________________________ > >> 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/20090703/f2be3653/attachment.html From a.biurvOir4 at asuhan.com Fri Jul 3 12:58:57 2009 From: a.biurvOir4 at asuhan.com (Kim-Ee Yeoh) Date: Fri Jul 3 12:41:27 2009 Subject: [Haskell-cafe] Flipping *->*->* kinds, or monadic finally-tagless madness In-Reply-To: <7fb8f82f0907021849m105018cy1651ac7799c2e137@mail.gmail.com> References: <24314553.post@talk.nabble.com> <7fb8f82f0907021849m105018cy1651ac7799c2e137@mail.gmail.com> Message-ID: <24326046.post@talk.nabble.com> Hi Edward, Your runPretty version fits the bill nicely, thank you. I might still retain the state monad version because it allows generalizations beyond pretty-printing. As for fixing the original bug, I've found that the real magic lies in the incantation (Y . unY) inserted at the appropriate places. Indeed, I've removed type signatures because try as I might, I couldn't write something the type-checker would accept. This is for 6.8.2. FWIW, the final version: instance Symantics (Y String) where int = unZ . return . show bool = unZ . return . show lam f = unZ $ do show_c0 <- get let vname = "v" ++ show_c0 c0 = read show_c0 :: VarCount c1 = succ c0 put (show c1) bodyf <- (Z . Y . unY . f . unZ . return) vname return $ "(\\" ++ vname ++ " -> " ++ bodyf ++ ")" fix f = pr3 [MkZa $ lam f] ["(fix ", ")"] app e1 e2 = pr3 [MkZa e1,MkZa e2] ["("," " ,")"] add e1 e2 = pr3 [MkZa e1,MkZa e2] ["("," + " ,")"] mul e1 e2 = pr3 [MkZa e1,MkZa e2] ["("," * " ,")"] leq e1 e2 = pr3 [MkZa e1,MkZa e2] ["("," <= ",")"] if_ be et ee = pr3 [MkZa be,MkZa et,MkZa ee] ["(if "," then "," else ",")"] -- Suppress the Symantics phantom type by casting to an existential data Za where MkZa :: Y String a -> Za pr3 a b = unZ $ pr2 a b pr2 :: forall a. [Za] -> [String] -> Z a String pr2 _ [] = return "" pr2 [] ts = (return . concat) ts pr2 ((MkZa e):es) (t:ts) = do s1 <- (Z . Y . unY) e -- that (Y . unY) magical incantation again! s2 <- pr2 es ts return $ t ++ s1 ++ s2 Edward Kmett wrote: > > You might also look at doing it without all the State monad noise with > something like: >> class Symantics repr where >> int :: Int -> repr Int >> add :: repr Int -> repr Int -> repr Int >> lam :: (repr a -> repr b) -> repr (a->b) >> app :: repr (a -> b) -> repr a -> repr b > >> newtype Pretty a = Pretty { runPretty :: [String] -> String } > >> pretty :: Pretty a -> String >> pretty (Pretty f) = f vars where >> vars = [ [i] | i <- ['a'..'z']] ++ [i : show j | j <- [1..], i <- > ['a'..'z'] ] > >> instance Symantics Pretty where >> int = Pretty . const . show >> add x y = Pretty $ \vars -> "(" ++ runPretty x vars ++ " + " ++ > runPretty y vars ++ ")" >> lam f = Pretty $ \ (v:vars) -> "(\\" ++ v ++ ". " ++ runPretty (f (var > v)) vars ++ ")" where >> var = Pretty . const >> app f x = Pretty $ \vars -> "(" ++ runPretty f vars ++ " " ++ >> runPretty > x vars ++ ")" > -- View this message in context: http://www.nabble.com/Flipping-*-%3E*-%3E*-kinds%2C-or-monadic-finally-tagless-madness-tp24314553p24326046.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From nfjinjing at gmail.com Fri Jul 3 13:23:33 2009 From: nfjinjing at gmail.com (Jinjing Wang) Date: Fri Jul 3 13:06:04 2009 Subject: [Haskell-cafe] Help needed to pick a better name then "hack" Message-ID: <81ea7d400907031023k3226b2f2xca76649ffd87278c@mail.gmail.com> Hack is such an inconvenient name for a package, may I get some inspiration from renaming it? Also, is there an idiom to use when upgrading package name on hackage? Best, -- jinjing From keithshep at gmail.com Fri Jul 3 13:27:41 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Fri Jul 3 13:10:07 2009 Subject: [Haskell-cafe] On the parallel between java annotations and monads In-Reply-To: <6de6b1650907030655re55badt55420282e5918c0@mail.gmail.com> References: <6de6b1650907030655re55badt55420282e5918c0@mail.gmail.com> Message-ID: <92e42b740907031027n2741fc33m164e455d3eca7e76@mail.gmail.com> I see some parallels between Inversion of Control/Dependency Injection frameworks and monads. I would say annotations are tools that are sometimes used for those frameworks, but they are also used for other unrelated things (warning suppression, overriding functions ...) so it may be more clear to focus on IoC and DI instead of annotations. -Keith 2009/7/3 Rafael Almeida : > Hello, > > After an extensive search (5 minutes googling) I could not find any comparison > between Java annotations (or Python annotations for that matter) and Monads. I > think they are similar in various aspects and I want to discuss them here. > > I'm sure several of you have experience with Java programming and its annotation > system. At first they seem like an extension to the typing system, by using > annotations a single variable or method may have more than one type: the real > type and all the annotations types. The way you declare them is not important > for this discussion, but assume that you've created the annotations > GreaterThanFive and LessThanTwenty, you could annotate a method like > this (let's > forget about all the class verbosity for a while): > > ? ? ? ?@GreaterThanFive @LessThanTwenty int doYourThing(); > > You could than use reflection to read those annotations and you could check if > the returned integer is in the correct range. You could even make the compiler > generate code that will do that checking automatically for you. > > Even though that was my first impression of them, that's not really > how they are > used in practice (at least the practice that I have experimented). People use > them to implement Monad-like features to the language. Actually, you can forget > monad and think of computation containers. > > On an EJB environment there's something called a container and it will do all > sorts of computations when you call an annotated method or when you > create a new > annotated class. For instance, if, inside of an entity bean, you annotate a > variable like this: > > ? ? ? ?@Column(name = "NAME") private String name; > > then, when you create a method like so: > > ? ? ? ?public String getName() > ? ? ? ?{ > ? ? ? ? ? ? ? ?return name; > ? ? ? ?} > > that name is actually something retrieved from the database, even though, it > looks just like something in memory. As far as I know the interaction with > monads for handling databases is not very different. There are other annotations > which allows the container to "inject" some object on a variable, such as: > > ? ? ? ?@PersistenceContext private EntityManager entityManager; > > now you won't even create an EntityManager instance, but will use the object > living inside the container. I compare that to getting a value from an State > Monad. Like there, you'll do some computations using entityManager, but it will > ultimately be returned to the container. > > While each computational container in Haskell is very rigid and well > defined, in > java there's nothing rigorous about the annotation. However, quite often the > annotations in Java are used in a manner similar to the implementation of a > Monad in Java. > > []'s > Rafael > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- keithsheppard.name From deniz.a.m.dogan at gmail.com Fri Jul 3 13:54:58 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Fri Jul 3 13:37:24 2009 Subject: [Haskell-cafe] Help needed to pick a better name then "hack" In-Reply-To: <81ea7d400907031023k3226b2f2xca76649ffd87278c@mail.gmail.com> References: <81ea7d400907031023k3226b2f2xca76649ffd87278c@mail.gmail.com> Message-ID: <7b501d5c0907031054jea818dfg1cc3b466c6f63a61@mail.gmail.com> 2009/7/3 Jinjing Wang : > Hack is such an inconvenient name for a package, may I get some > inspiration from renaming it? > > Also, is there an idiom to use when upgrading package name on hackage? > > Best, > > -- > jinjing Crack? Har har... -- Deniz Dogan From simon at joyful.com Fri Jul 3 15:12:04 2009 From: simon at joyful.com (Simon Michael) Date: Fri Jul 3 14:54:42 2009 Subject: [Haskell-cafe] Re: Help needed to pick a better name then "hack" In-Reply-To: <81ea7d400907031023k3226b2f2xca76649ffd87278c@mail.gmail.com> References: <81ea7d400907031023k3226b2f2xca76649ffd87278c@mail.gmail.com> Message-ID: We've had the Common Gateway Interface.. and the Web Server Gateway Interface.. now I think it's high time for the Haskell And General Gateway Interface for Servers. From lrpalmer at gmail.com Fri Jul 3 15:29:35 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Jul 3 15:17:35 2009 Subject: [Haskell-cafe] How to present the commonness of some objects? In-Reply-To: <8B8E76B2-F1E8-4F9C-AA7B-BBA0FEE43389@z.odi.ac> References: <3bd412d40907022100o2d9972ecw5b090a720b4f348b@mail.gmail.com> <3bd412d40907022132o6eba9226v4c899161c0ccefd3@mail.gmail.com> <7ca3f0160907030008p43aa6f63l228ddebdc4c399e7@mail.gmail.com> <8B8E76B2-F1E8-4F9C-AA7B-BBA0FEE43389@z.odi.ac> Message-ID: <7ca3f0160907031229k7543ef1pd38d267b90e2f70@mail.gmail.com> 2009/7/3 Ross Mellgren > Wordy (and yet technically accurate) names aside, isn't this basically the > same thing, except that you must pass the dictionary around by hand? > A SomeWidget is defined as "any object which has a Widget dictionary". It's still an object; the link from it to its dictionary is implicit. But since you have no other qualifiers on that object, nothing can be determined from it but its dictionary. Why not just junk the indirection and make the object equal to its dictionary. This is a different story if you a class like: class Split a where split :: a -> (a,a) join :: a -> a -> a data SomeSplit = forall a. Split a => SomeSplit a Here a SomeSplit can be split into two SomeSplits, but two SomeSplits can't be joined into one. Two join two of these things, you must have split them off a common ancestor. > What is the advantage of doing the dictionary passing manually, other than > being able to avoid the scoping issue (that requires case) and the slightly > odd syntax? > The fact that it's exactly the same, except for the scoping issue and the slightly odd syntax. You're not saving any parameter passing. > > To expand your example, would you suggest something like: > > data Widget = Widget { widgetRun :: IO () } > > data Label = Label (String -> IO ()) > data Button = Button (IO ()) > > labelToWidget = Widget runLabel > buttonToWidget = Widget runButton > > widgetList :: [(Integer, Integer, Widget)] > widgetList = [labelToWidget myLabel, buttonToWidget myButton] > Yeah sure, something like that. Except, concretely, I don't see how a Label is a String -> IO (). Is that a setter function for its text? How is a Widget going to use that. I guess unless a "label widget" passed *you* a label when you create it. I'd say the other option in this paradigm is a MVar. But I digress... Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090703/64c8176f/attachment.html From patai_gergely at fastmail.fm Fri Jul 3 16:22:04 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Fri Jul 3 16:04:32 2009 Subject: [Haskell-cafe] ANN: bloxorz clone Message-ID: <1246652524.9181.1323418579@webmail.messagingengine.com> Hello all, This post is not about my own creation, it's just a little fun program written by a student of mine. You can install the bloxorz package to try it out, and read more about its background on my blog: http://just-bottom.blogspot.com/2009/07/playing-and-learning.html Gergely -- http://www.fastmail.fm - Access all of your messages and folders wherever you are From gue.schmidt at web.de Fri Jul 3 19:11:23 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Fri Jul 3 18:54:07 2009 Subject: [Haskell-cafe] Cont, ContT and IO() Message-ID: Hi, I've got an IO action, some file system IO, traversing one level only and iterating over files found. I wish to build in an "early" exit, ie. if an IO action in the loop encounters a particular value I want it to abort the loop. Now so far, pls don't shoot, I have done this by throwing IO Exceptions and catching them. I'm trying to rewrite this using Continuatios / callCC but can't figure out where to place what. I certainly don't have the intuition yet and funny enough not even in RWH I could find some Cont/ContT examples. Would someone please draw me an example? G?nther From inforichland at gmail.com Fri Jul 3 19:36:27 2009 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Fri Jul 3 19:18:53 2009 Subject: [Haskell-cafe] Cont, ContT and IO() In-Reply-To: References: Message-ID: <4335a3260907031636x6b66d6ccy1f52af426874bc@mail.gmail.com> Well, continuations come from Scheme, and by and large, they are usually used in languages like Scheme (i.e. PLT web server), or Smalltalk (Seaside web server), but they can be very useful in e.g. cases like yours for making a convenient way to make a local exit. I did this in one toy game program of mine. The code looks (somewhat) like this: run :: GameState () run = (`runContT` id) $ do throwaway <- callCC $ \exit -> forever $ do -- retrieve the current state -- get user input, etc... case input of ... "quit" -> exit $ return () in this case, when the user enters "quit" the captured continuation is restored and the value '()' is returned from callCC and assigned to 'throwAway' in this case. Of course, this is only one use case of continuations, a very powerful abstraction mechanism :) Cheers. 2009/7/3 G?nther Schmidt > > Hi, > > I've got an IO action, some file system IO, traversing one level only and > iterating over files found. I wish to build in an "early" exit, ie. if an IO > action in the loop encounters a particular value I want it to abort the > loop. > > Now so far, pls don't shoot, I have done this by throwing IO Exceptions and > catching them. I'm trying to rewrite this using Continuatios / callCC but > can't figure out where to place what. > > I certainly don't have the intuition yet and funny enough not even in RWH I > could find some Cont/ContT examples. > > Would someone please draw me an example? > > 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/20090703/2f56ab63/attachment.html From nominolo at googlemail.com Fri Jul 3 21:33:48 2009 From: nominolo at googlemail.com (Thomas Schilling) Date: Fri Jul 3 21:16:14 2009 Subject: [Haskell-cafe] Cont, ContT and IO() In-Reply-To: References: Message-ID: <916b84820907031833v2dea1f23ldf6af480e2226131@mail.gmail.com> Here's some code I wrote the other day: hasCycle :: (Applicative m, MonadIO m) => Node -> m Bool hasCycle n0 = runContT (*callCC* go) return where go *abort* = do visit [] IM.empty n0 return False where visit preds h n = do nid <- nodeId n h' <- foldM (\h' n' -> do n'id <- nodeId n' case IM.lookup n'id h' of Just True -> *abort* True Just False -> return h' Nothing -> visit (n:preds) h n') (IM.insert nid True h) =<< nodeChildren n return (IM.insert nid False h') This function returns True if the graph starting at n0 has cycles. You can ignore the details; take a look at the use of "abort". The type of "abort" is Bool -> m (IM.IntMap Bool) but the result type is actually irrelevant since this function will never return. The effect of calling "abort" is to: jump back to the place where we called callCC and replace the call with the value we passed to "abort". You can think of callCC of creating a snapshot of the program's current execution state. This snapshot (called the "current continuation") is passed to the function that was the argument to "callCC" ("go" in the above). This snapshot is represented as a function and you can call it. If you call the continuation, two things happen: 1. The currently executed code is aborted. 2. The execution jumps back to the state in which callCC was called and the call to callCC gets replaced by the value you passed to the continuation. Naturally, we cannot undo IO effects, so not all of the state is reset. Also, since callCC is only available in the monad, it only saves the snapshot up to the closest "runContT". Another, more mind-bending feature of continuations is that you can store them and invoke them *multiple times*. But that is a story for another day. HTH 2009/7/4 G?nther Schmidt : > > Hi, > > I've got an IO action, some file system IO, traversing one level only and > iterating over files found. I wish to build in an "early" exit, ie. if an IO > action in the loop encounters a particular value I want it to abort the > loop. > > Now so far, pls don't shoot, I have done this by throwing IO Exceptions and > catching them. I'm trying to rewrite this using Continuatios / callCC but > can't figure out where to place what. > > I certainly don't have the intuition yet and funny enough not even in RWH I > could find some Cont/ContT examples. > > Would someone please draw me an example? > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Push the envelope. Watch it bend. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090703/f3ddacda/attachment.html From newhoggy at gmail.com Fri Jul 3 21:45:47 2009 From: newhoggy at gmail.com (John Ky) Date: Fri Jul 3 21:28:12 2009 Subject: [Haskell-cafe] How to pretty print code efficiently Message-ID: Hi, Currently I'm pretty printing code by building arrays of strings and calling indent. For example: instance JavaPrintableNamed AST.EnumeratedType where javaLinesNamed parentName (AST.EnumeratedType memberDefinitions) = [ "public enum " ++ asJavaId(parentName) , "{" ] ++ memberCodeLines ++ [ "}" , "" ] where memberCodeLines = indent $ javaLines memberDefinitions The indent function takes a list of strings and adds an indent to the beginning of every line. I can imagine this to be very inefficient as it builds many strings and concatenates them. In Ruby, I might do the same thing like this: class EnumeratedType < JavaPrintableNamed def writeTo(writer) writer.print "public enum " writer.puts self.asJavaId writer.puts "{" writer.indent do self.memberDefinitions.writeTo(writer) writer.puts end where above, the writer.indent takes care of the indent, and everything is appended to a stream, which doesn't seem so bad in terms of efficiency. I'm looking for a way to do something similar in Haskell. Anyone can give me a hand? Thanks -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090703/493a94e9/attachment.html From mutjida at gmail.com Fri Jul 3 21:58:46 2009 From: mutjida at gmail.com (jeff p) Date: Fri Jul 3 21:41:11 2009 Subject: [Haskell-cafe] Cont, ContT and IO() In-Reply-To: <4335a3260907031636x6b66d6ccy1f52af426874bc@mail.gmail.com> References: <4335a3260907031636x6b66d6ccy1f52af426874bc@mail.gmail.com> Message-ID: Couldn't resist taking the bait... > Well, continuations come from Scheme, and by and large, they are usually > used in languages like Scheme (i.e. PLT web server), or Smalltalk (Seaside > web server), > For a fuller history of continuatios, please see "The Discoveries of Continuations" by John Reynolds (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.40.237) -Jeff From barsoap at web.de Fri Jul 3 22:56:48 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Jul 3 22:39:38 2009 Subject: [Haskell-cafe] Re: How to pretty print code efficiently References: Message-ID: <20090704045648.215532e3@solaris> John Ky wrote: > Hi, > > Currently I'm pretty printing code by building arrays of strings and > calling indent. For example: > > instance JavaPrintableNamed AST.EnumeratedType where > javaLinesNamed parentName (AST.EnumeratedType memberDefinitions) = > [ "public enum " ++ asJavaId(parentName) > , "{" > ] ++ memberCodeLines ++ > [ "}" > , "" > ] > where > memberCodeLines = indent $ javaLines memberDefinitions > > The indent function takes a list of strings and adds an indent to the > beginning of every line. > > I can imagine this to be very inefficient as it builds many strings > and concatenates them. > Yes and no. When concatenating two lists, only the first one is rebuild, the second one is reused, due to sharing. So if you concatenate short strings to the front of a long string you're quite fine. But then, that isn't the answer you hoped for. > In Ruby, I might do the same thing like this: > > class EnumeratedType < JavaPrintableNamed > def writeTo(writer) > writer.print "public enum " > writer.puts self.asJavaId > writer.puts "{" > writer.indent do > self.memberDefinitions.writeTo(writer) > writer.puts > end > > where above, the writer.indent takes care of the indent, and > everything is appended to a stream, which doesn't seem so bad in > terms of efficiency. > > I'm looking for a way to do something similar in Haskell. > > Anyone can give me a hand? > As data structure use Data.ByteString.Lazy: concatenating two lazy bytestrings doesn't involve rebuilding the first string byte-by-byte, but constructs a superstructure denoting the concatenation. As for how to express it in code: I'd recommend a combination of a State monad to track the indentation, and the underused[1] Applicative interpretation of lists to concatenate stuff. >>= would function as concatenation of lines, getting the state, while the indent function would first set it to the new level, then execute the passed sub-action, and finally reset it to the old level. You're going to need a way to concatenate two strings without doing a line-break, too, of course. All in all, it's a splendid exercise in how to write custom monads. [1] Lists as ordered collections, not possibilities, that is, see e.g. the typeclassopedia ( http://www.haskell.org/sitewiki/images/8/85/TMR-Issue13.pdf ) -- (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 alexander.dunlap at gmail.com Fri Jul 3 23:13:56 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Fri Jul 3 22:56:42 2009 Subject: [Haskell-cafe] How to pretty print code efficiently In-Reply-To: References: Message-ID: <57526e770907032013v3eed0a9cl626624bd6abf026f@mail.gmail.com> On Fri, Jul 3, 2009 at 6:45 PM, John Ky wrote: > Hi, > > Currently I'm pretty printing code by building arrays of strings and calling > indent.? For example: > > instance JavaPrintableNamed AST.EnumeratedType where > ?? javaLinesNamed parentName (AST.EnumeratedType memberDefinitions) = > ????? [ "public enum " ++ asJavaId(parentName) > ????? , "{" > ????? ] ++ memberCodeLines ++ > ????? [ "}" > ????? , "" > ????? ] > ????? where > ???????? memberCodeLines = indent $ javaLines memberDefinitions > > The indent function takes a list of strings and adds an indent to the > beginning of every line. > > I can imagine this to be very inefficient as it builds many strings and > concatenates them. > > In Ruby, I might do the same thing like this: > > class EnumeratedType < JavaPrintableNamed > ?? def writeTo(writer) > ????? writer.print "public enum " > ? ? ? writer.puts self.asJavaId > ????? writer.puts "{" > ????? writer.indent do > ? ? ? ?? self.memberDefinitions.writeTo(writer) > ???????? writer.puts > ????? end > > where above, the writer.indent takes care of the indent, and everything is > appended to a stream, which doesn't seem so bad in terms of efficiency. > > I'm looking for a way to do something similar in Haskell. > > Anyone can give me a hand? > > Thanks > > -John > > > _______________________________________________ You may want to investigate the standard module Text.PrettyPrint.HughesPJ, which contains a number of (I assume fairly efficient) combinators for pretty printing. Alex From barsoap at web.de Fri Jul 3 23:17:15 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Jul 3 23:00:05 2009 Subject: [Haskell-cafe] Re: How to pretty print code efficiently References: <20090704045648.215532e3@solaris> Message-ID: <20090704051715.72e1daf8@solaris> Achim Schneider wrote: > As for how to express it in code: I'd recommend a combination of a > State monad to track the indentation, and the underused[1] Applicative > interpretation of lists to concatenate stuff. >>= would function as > concatenation of lines, getting the state, while the indent function > would first set it to the new level, then execute the passed > sub-action, and finally reset it to the old level. You're going to > need a way to concatenate two strings without doing a line-break, > too, of course. > Make that "Reader Monad" and "execute the passed sub-action with the new level inside a new monad" -- (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 wren at freegeek.org Sat Jul 4 00:33:14 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 4 00:15:41 2009 Subject: [Haskell-cafe] Flipping *->*->* kinds, or monadic finally-tagless madness In-Reply-To: <24326046.post@talk.nabble.com> References: <24314553.post@talk.nabble.com> <7fb8f82f0907021849m105018cy1651ac7799c2e137@mail.gmail.com> <24326046.post@talk.nabble.com> Message-ID: <4A4EDB8A.6050102@freegeek.org> Kim-Ee Yeoh wrote: > > type VarCount = int > > newtype Y b a = Y {unY :: VarCount -> (b, VarCount)} > > Hi Edward, > > Your runPretty version fits the bill nicely, thank you. I might still retain > the state monad version because it allows generalizations beyond > pretty-printing. > > As for fixing the original bug, I've found that the real magic lies > in the incantation (Y . unY) inserted at the appropriate places. Aka unsafeCoerce, changing the phantom type |a|. The need to do it is caused by wanting to erase the existential introduced by Za/MkZa. Depending on what the phantom type is supposed to represent, this may or may not give the semantics/safety you're after. -- Live well, ~wren From porges at porg.es Sat Jul 4 01:08:15 2009 From: porges at porg.es (George Pollard) Date: Sat Jul 4 00:50:41 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> <57526e770907020936y56f3ab6bsda8f51de1f57a6eb@mail.gmail.com> Message-ID: <6d942a4a0907032208h49ba529bmdd0e1133ac078465@mail.gmail.com> This discussion points to a wider issue: at some stage we should look at pulling all the nice "new" stuff into Haskell prelude. I'm looking at you, Data.Foldable,Traversable. Also, throw out `map`. ;) From wren at freegeek.org Sat Jul 4 01:17:07 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 4 00:59:33 2009 Subject: [Haskell-cafe] Cont, ContT and IO() In-Reply-To: References: Message-ID: <4A4EE5D3.4080203@freegeek.org> G?nther Schmidt wrote: > > Hi, > > I've got an IO action, some file system IO, traversing one level only > and iterating over files found. I wish to build in an "early" exit, ie. > if an IO action in the loop encounters a particular value I want it to > abort the loop. > > Now so far, pls don't shoot, I have done this by throwing IO Exceptions > and catching them. I'm trying to rewrite this using Continuatios / > callCC but can't figure out where to place what. > > I certainly don't have the intuition yet and funny enough not even in > RWH I could find some Cont/ContT examples. > > Would someone please draw me an example? The quick and dirty explanation is, given an expression like: f . g . h $ callCC (\k -> body) we might wonder what the meaning of "callCC (\k -> body)" is. If k is unused in body, then it means the same thing as "body" which is to say that body returns with some value x::A. The alternative is that we use k in the body (e.g. by passing it some y::A), in which case the value of "callCC (\k -> body)" is whatever value is passed to k (namely y::A). Note that the input type of k and the output type of body must be the same, and the output type of k is irrelevant because it never returns. Once we get a value for "callCC (\k -> body)", whatever value that is gets passed on to h, then g, then f, in the usual manner. For imperative code, this is just like calling return before the end of the function, e.g: if_PA_then_return5_else_DoSomethingAndReturnB = \ p a b -> callCC $ \exit -> do isP <- if p a then exit (return 5) -- return 5 *immediately* to our caller else return True -- if we ever get here, isP must equal True because -- exit never returns. doSomething -- if we wanted doSomething to be able to override our -- "return b" result, we could pass it exit and then -- doSomething will either return control to us (and we -- return b) or it will return directly to our caller with -- some other answer. return b That isn't the whole story, but it's enough to figure out how to do early exits. In the more compleat explanation, the k which callCC causes to be passed to its functional argument is the "f . g . h" which will be invoked after callCC returns. That is, it's not the composition of functions, but rather it's that exact application of those functions. I.e. the fabricated k is a goto statement accepting a value and returning control to just outside of the invocation of callCC. Because of this behavior you can do interesting things like returning k from the body, or passing k to itself, which allows someone else to jump back into the expression and rerun it by passing a new value through the "f . g . h" Another paper to check out if you're a fan of theory is: Andrzej Filinski Declarative continuations: An investigation of duality in programming language semantics http://www.springerlink.com/content/m2105282ru426654/ which does quite a good job of investigating how to reason about continuations. (Though you need to be somewhat familiar with some Category Theory, and intimately familiar with lambda calculus, to enjoy it.) -- Live well, ~wren From jason.dusek at gmail.com Sat Jul 4 01:17:31 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sat Jul 4 00:59:58 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <6d942a4a0907032208h49ba529bmdd0e1133ac078465@mail.gmail.com> References: <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> <57526e770907020936y56f3ab6bsda8f51de1f57a6eb@mail.gmail.com> <6d942a4a0907032208h49ba529bmdd0e1133ac078465@mail.gmail.com> Message-ID: <42784f260907032217q6eb049b8w97c5868251ed9f5c@mail.gmail.com> 2009/07/03 George Pollard : > This discussion points to a wider issue: at some stage we > should look at pulling all the nice "new" stuff into Haskell > prelude. I'm looking at you, Data.Foldable,Traversable. > > Also, throw out `map`. ;) What is the proper name for the operation on functions of a functor, anyway? The name `fmap` seems to driven by an analogy with `map`. -- Jason Dusek From alexander.dunlap at gmail.com Sat Jul 4 01:22:43 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sat Jul 4 01:05:29 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <42784f260907032217q6eb049b8w97c5868251ed9f5c@mail.gmail.com> References: <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> <57526e770907020936y56f3ab6bsda8f51de1f57a6eb@mail.gmail.com> <6d942a4a0907032208h49ba529bmdd0e1133ac078465@mail.gmail.com> <42784f260907032217q6eb049b8w97c5868251ed9f5c@mail.gmail.com> Message-ID: <57526e770907032222n3bc94975w6bc3f22363bf3904@mail.gmail.com> On Fri, Jul 3, 2009 at 10:17 PM, Jason Dusek wrote: > 2009/07/03 George Pollard : >> This discussion points to a wider issue: at some stage we >> should look at pulling all the nice "new" stuff into Haskell >> prelude. I'm looking at you, Data.Foldable,Traversable. >> >> Also, throw out `map`. ;) > > ?What is the proper name for the operation on functions of a > ?functor, anyway? The name `fmap` seems to driven by an analogy > ?with `map`. > > -- > Jason Dusek > _______________________________________________ I think map would be the right name. IMO, what would be really nice would be to rename "fmap" to "map" (and then fmap would become a deprecated synonym for map), etc., and get rid of many of the special cases for lists in the Prelude. The only backward compatibility problem that has been brought up is monomorphism restriction stuff, though. Alex From porges at porg.es Sat Jul 4 01:26:09 2009 From: porges at porg.es (George Pollard) Date: Sat Jul 4 01:08:33 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <42784f260907032217q6eb049b8w97c5868251ed9f5c@mail.gmail.com> References: <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> <57526e770907020936y56f3ab6bsda8f51de1f57a6eb@mail.gmail.com> <6d942a4a0907032208h49ba529bmdd0e1133ac078465@mail.gmail.com> <42784f260907032217q6eb049b8w97c5868251ed9f5c@mail.gmail.com> Message-ID: <6d942a4a0907032226q2d03a216x29b922faef37cdf9@mail.gmail.com> 2009/7/4 Jason Dusek : > 2009/07/03 George Pollard : >> Also, throw out `map`. ;) > > ?What is the proper name for the operation on functions of a > ?functor, anyway? The name `fmap` seems to driven by an analogy > ?with `map`. This is getting a little off topic, but I don't believe it has a name. In category theory the name of the functor is used as an operation on the function, so that given the functor "F", instead of writing `fmap f` you'd write `F(f)`. I think this is one area where Haskell wins notationally :) From uhollerbach at gmail.com Sat Jul 4 01:37:08 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sat Jul 4 01:19:35 2009 Subject: [Haskell-cafe] space leak hints? Message-ID: <65d7a7e0907032237y6a8d70acs7910373327fb1910@mail.gmail.com> Good evening, all, I wonder if I could tap your collective wisdom regarding space leaks? I've been messing about with haskeem, my little scheme interpreter, and I decided to see if I could make it run reasonably space-efficiently. So far... no. Here's what I tried: I wrote a tiny scheme program to compute Collatz sequences for successive numbers, starting from 1 and incrementing forever (well, in principle). Because real scheme implementations are fully tail-call-optimized, this'll run in constant memory; I checked that with mzscheme, and it does indeed work. With my little interpreter, that's not the case: memory usage grows continually, although apparently less-than-linearly. I've built the interpreter with the profiling stuff described on the wiki and in RWH Ch 25 turned on and have made a few runs with that; I stuck the postscript plot that's the result of one of those runs onto my web site at http://www.korgwal.com/haskeem/run2.ps. The full source to the interpreter is a little large to paste into this message; it's available on my web site, and also on hackage. But according to the plot, there appear to be three main memory allocation issues, and they seem to all be related, if I'm reading stuff correctly. The core of the interpreter is a function, evalLisp, which evaluates scheme forms. There are of course a fair number of different forms, but the largest generic usage is "evaluate each of a list of forms, returning the value of the last of them as the overall result". In order to express that in a couple of different places, and to accomodate the possibility of an empty list, I have a really tiny function lastOrNil which just calls "last" on a (haskell) list, checking for the possibility of an empty list, and returning a haskeem LispVal object: > lastOrNil = liftM lON > where lON [] = List [] > lON l = last l (sorry, proportional fonting may be throwing this off). It's this function which is directly implicated in two of the top three memory pigs, and nearly directly in the third one as well. If I could eliminate the memory growth in these three cost centers, I would already capture over 90% of the growth in this benchmark, which would make me very happy indeed. But I don't really understand what is going on here. It seems entirely plausible, indeed likely, that the list which I'm traversing there is not fully evaluated. So I've tried adding 'seq' to this function. Uhhh... from memory, I dumped it after it didn't work, I had > lastOrNil = liftM lON > where lON [] = List [] > lON (l:[]) = l > lON (l:ls) = seq l (lON ls) (again, proportional fonting might mess me up here.) As I said, I dumped this after it made no difference whatsoever. I also tried bang-patterns in a couple of places, strictness annotation of my basic LispVal types... nothing. It all made exactly no difference, as far as I could tell. I've tried a couple of google searches, but haven't come up with anything better than what I've already described. So I'm a stumped chump! I'd be grateful for any suggestions... thanks in advance! Uwe From bulat.ziganshin at gmail.com Sat Jul 4 02:42:02 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jul 4 02:25:03 2009 Subject: [Haskell-cafe] Cont, ContT and IO() In-Reply-To: References: Message-ID: <4210037819.20090704104202@gmail.com> Hello G?nther, Saturday, July 4, 2009, 3:11:23 AM, you wrote: > I've got an IO action, some file system IO, traversing one level only and > iterating over files found. I wish to build in an "early" exit, ie. if an > IO action in the loop encounters a particular value I want it to abort the > loop. just make an explicit loop: process [] = return () process (file:files) = do x <- doit file if x>0 then process files else return () -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From uhollerbach at gmail.com Sat Jul 4 03:39:35 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sat Jul 4 03:21:59 2009 Subject: [Haskell-cafe] following up on space leak Message-ID: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> Good evening, all, following up on my question regarding space leaks, I seem to have stumbled across something very promising. I said I was using this tiny function "lastOrNil" to get the last value in a list, or the empty (scheme) list if the haskell list was empty. The uses of it were all of the form lastOrNil (mapM ) so I wrote a different function mapML to do this directly: > mapML fn lst = mapMLA (List []) fn lst > where mapMLA r _ [] = return r > mapMLA ro fn (x:xs) = > do rn <- fn x > mapMLA rn fn xs This isn't an accumulator, it's a replacer (or, if you like, the "accumulation" is "drop the old one on the floor"), it starts out with the scheme empty list that I want as the default, and it never even builds the list which it'll just dump an instant later. Shazam! Memory usage dropped by roughly an order of magnitude in my little Collatz benchmark, and incidentally runtime improved by 25% or so as well. The horror! :-) Having tasted blood, I will of course be continuing to benchmark... but not tonight. Uwe From andrewcoppin at btinternet.com Sat Jul 4 04:24:08 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 04:06:32 2009 Subject: [Haskell-cafe] Cabal fun [Half-integer] In-Reply-To: <694519c50906291111y50872ad4s3ec35add223656fe@mail.gmail.com> References: <4A476F0E.5060305@btinternet.com> <4A47C0E2.5060101@btinternet.com> <694519c50906281227k198fb126k787da6680fe3fc50@mail.gmail.com> <4A47C4A8.5030009@btinternet.com> <4A47CDB2.6020602@btinternet.com> <4A47D5AA.2070706@btinternet.com> <694519c50906281411i6016cd8dgb1c9c3390a390c9@mail.gmail.com> <61f84eff0906281839n60d73f42v3891b8c8e9c59949@mail.gmail.com> <4A4901E7.2080503@btinternet.com> <694519c50906291111y50872ad4s3ec35add223656fe@mail.gmail.com> Message-ID: <4A4F11A8.6020004@btinternet.com> Antoine Latter wrote: > Personally, I've never used "runhaskell Setup sdist" and I've only > ever used "cabal sdist". But I'm not sure where I learned that. > > I think cabal-install is a pretty standard util for people to have, > and it ships with the Haskell platform now. So the big hurdle is > documentation. > > Andrew - where does it state that "Setup sdist" is the recommended way > of doing this? If it's a wiki you could go and edit it yourself. > Start from the Hackage homepage: http://hackage.haskell.org/packages/hackage.html Click on "how to create a Haskell package", takes you to http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program Section 2.10.1.1 shows you how to create a tarball - using setup sdist rather than cabal sdist. Indeed, I don't think cabal-install is mentioned anywhere. If people seriously want this to become the preferred way to do things, it needs to be much more prominently documented. From marcin.kosiba at gmail.com Sat Jul 4 04:36:37 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Sat Jul 4 04:19:16 2009 Subject: [Haskell-cafe] following up on space leak In-Reply-To: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> References: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> Message-ID: <200907041036.42915.marcin.kosiba@gmail.com> On Saturday 04 July 2009, Uwe Hollerbach wrote: > Good evening, all, following up on my question regarding space leaks, > I seem to have stumbled across something very promising. I said I was > using this tiny function "lastOrNil" to get the last value in a list, > or the empty (scheme) list if the haskell list was empty. The uses of > it were all of the form > > lastOrNil (mapM ) > > so I wrote a different function mapML to do this directly: > > mapML fn lst = mapMLA (List []) fn lst > > where mapMLA r _ [] = return r > > mapMLA ro fn (x:xs) = > > do rn <- fn x > > mapMLA rn fn xs > > This isn't an accumulator, it's a replacer (or, if you like, the > "accumulation" is "drop the old one on the floor"), it starts out with > the scheme empty list that I want as the default, and it never even > builds the list which it'll just dump an instant later. Shazam! Memory > usage dropped by roughly an order of magnitude in my little Collatz > benchmark, and incidentally runtime improved by 25% or so as well. The > horror! :-) Hi, IMHO expressing mapML using StateT would be a bit cleaner ;) mapML :: (Monad m) => (a -> m List) -> [a] -> m List mapML fn lst = execStateT mapMLAs (List []) where mapMLAs = sequence_ $ map mapMLA lst mapMLA x = (lift $ fn x) >>= put -- 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/20090704/0fc36bb6/attachment.bin From agocorona at gmail.com Sat Jul 4 06:21:06 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Sat Jul 4 06:03:31 2009 Subject: [Haskell-cafe] ORM for haskell? In-Reply-To: References: <20090630175208.GE6272@gmx.de> <2DFE45C5-EC7E-4EC6-AD77-815C9236FE47@eidhof.nl> <4A4DCF2E.8070100@functor.nl> Message-ID: And I realize that you are not trying to replace RDBs, just building a > nicer interface to them. I am just concerned that some of the nice > properties are lost in the process. I think my main concern comes from > seeing people create databases, by automatically generating tables from > OO-classes. They invariably ends up with something not nearly as nice, > as if they had constructed the database in a more traditional fashion. > for web applications in the Internet, due to security reasons, 99% of the databases are handled exlusively by te web application. This increases the arguments in favor of spending less time in database design. Moreover, since there are no concurrent updates from different applications, (communication with other applications are done trough the middle tier of the web application rather than trough the database), the database just provides transaction coherence (for the single application) and storage. Then it is much faster to perform transactions in the application trough STM and leave the database for storage purposes. At this time the database can be substituted with advantage by files. All of this gives credit to ORM solutions and HappStack or SQLalchemy, Database design and maintenance don't worth the pain in this scenario. My package TCache http://hackage.haskell.org/package/TCache is made also around this philosophy. If the ORM has an interface such is SQLalchemy, it would be nice to have two "drivers" one for pure SQL databases, where all the primitives would be executed in the database, and other pure Haskell where the primitives are executed in memory. For example, the transactions would be executed trough STM. This driver would have configurable persistence (either in files, manualy designed databases or whatever) . Perhaps mixed drivers can be added later. This would unite the best of both worlds. It would be flexible enough to permit the change of scenario without breaking the code. This would be nice for prototyping for example. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090704/487d4586/attachment.html From andrewcoppin at btinternet.com Sat Jul 4 07:37:21 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 07:19:42 2009 Subject: [Haskell-cafe] ANN: HalfInteger-1.1.1 In-Reply-To: <4A476F0E.5060305@btinternet.com> References: <4A476F0E.5060305@btinternet.com> Message-ID: <4A4F3EF1.904@btinternet.com> Andrew Coppin wrote: > I just wrote a small module for dealing with half-integers. (That is, > any number I/2 where I is an integer. Note that the set of integers is > a subset of this; Wikipedia seems to reserve "half-integer" for such > numbers that are *not* integers.) > > Now, the question is... Is this useful enough to be worth putting on > Hackage? It's on Hackage: http://hackage.haskell.org/package/AC-HalfInteger-1.1.1 It'll be interesting to see if I uploaded it right... o_O From felipe.lessa at gmail.com Sat Jul 4 08:24:29 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Jul 4 08:06:57 2009 Subject: [Haskell-cafe] ANN: HalfInteger-1.1.1 In-Reply-To: <4A4F3EF1.904@btinternet.com> References: <4A476F0E.5060305@btinternet.com> <4A4F3EF1.904@btinternet.com> Message-ID: <20090704122429.GA15052@kira.casa> On Sat, Jul 04, 2009 at 12:37:21PM +0100, Andrew Coppin wrote: > It's on Hackage: > > http://hackage.haskell.org/package/AC-HalfInteger-1.1.1 > > It'll be interesting to see if I uploaded it right... o_O I guess you did, congrats! :) ...on the Haddock comments of halve and double, it should be "halve . double" and not "half . double", right? You'll see that after the first upload it is easy to do another one (hopefully). -- Felipe. From andrewcoppin at btinternet.com Sat Jul 4 08:37:26 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 08:20:06 2009 Subject: [Haskell-cafe] ANN: HalfInteger-1.1.1 In-Reply-To: <20090704122429.GA15052@kira.casa> References: <4A476F0E.5060305@btinternet.com> <4A4F3EF1.904@btinternet.com> <20090704122429.GA15052@kira.casa> Message-ID: <4A4F4D06.8060805@btinternet.com> Felipe Lessa wrote: > On Sat, Jul 04, 2009 at 12:37:21PM +0100, Andrew Coppin wrote: > >> It's on Hackage: >> >> http://hackage.haskell.org/package/AC-HalfInteger-1.1.1 >> >> It'll be interesting to see if I uploaded it right... o_O >> > > I guess you did, congrats! :) > > ...on the Haddock comments of halve and double, it should be > "halve . double" and not "half . double", right? You'll see that > after the first upload it is easy to do another one (hopefully). > Well that's a good start. Already somebody has found a bug to be fixed. And in such a trivial package... o_O Still, at least it's an easy fix. ;-) I don't think I'll bother making another upload just for this; the fix is applied to my local copy, but I'll wait until I have something more substantial to upload for the next version. "Thanks for the report." From allbery at ece.cmu.edu Sat Jul 4 09:57:48 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Jul 4 09:40:32 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <42784f260907032217q6eb049b8w97c5868251ed9f5c@mail.gmail.com> References: <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <1246444728.28197.1655.camel@localhost> <20090701182651.GA9344@soi.city.ac.uk> <57526e770907020936y56f3ab6bsda8f51de1f57a6eb@mail.gmail.com> <6d942a4a0907032208h49ba529bmdd0e1133ac078465@mail.gmail.com> <42784f260907032217q6eb049b8w97c5868251ed9f5c@mail.gmail.com> Message-ID: On Jul 4, 2009, at 01:17 , Jason Dusek wrote: > What is the proper name for the operation on functions of a > functor, anyway? The name `fmap` seems to driven by an analogy > with `map`. (.) -- 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/20090704/5a04d102/PGP.bin From andrewcoppin at btinternet.com Sat Jul 4 10:22:09 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 10:04:30 2009 Subject: [Haskell-cafe] Small Haddock question Message-ID: <4A4F6591.2050508@btinternet.com> This is irritating me now... Suppose I have something like the following: zero = 0 :: Int one = 1 :: Int two = 2 :: Int three = 3 :: Int How do I add Haddock comments to the end of each line? For some reason, Haddock doesn't like either of zero = 0 :: Int -- | Zero zero = 0 :: Int -- ^ Zero Either way it whinges about parse errors. How do I make it shut up and stop being so dense at me? :-} It's damned obvious what I want it to do... From matthias.goergens at googlemail.com Sat Jul 4 10:39:30 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Jul 4 10:21:54 2009 Subject: [Haskell-cafe] Cont, ContT and IO() In-Reply-To: <4210037819.20090704104202@gmail.com> References: <4210037819.20090704104202@gmail.com> Message-ID: > process [] = return () > process (file:files) = do x <- doit file > ? ? ? ? ? ? ? ? ? ? ? ? ?if x>0 then process files > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? else return () Or use a fold: > process' = foldl op True files > op True file = doit file > op False _ = False From matthias.goergens at googlemail.com Sat Jul 4 10:44:42 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Jul 4 10:27:06 2009 Subject: [Haskell-cafe] Cont, ContT and IO() In-Reply-To: References: <4210037819.20090704104202@gmail.com> Message-ID: >> process' = foldl op True files >> op True file = doit file >> op False _ = False Please pardon me. 'doit' should surely be able to do some IO: > import Data.Foldable > import System.IO > process' = foldlM op True files > op True file = doit file > op False _ = return False were DoIt has the type FilePath -> IO Bool From bulat.ziganshin at gmail.com Sat Jul 4 10:42:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jul 4 10:34:09 2009 Subject: [Haskell-cafe] Cont, ContT and IO() In-Reply-To: References: <4210037819.20090704104202@gmail.com> Message-ID: <1996435535.20090704184247@gmail.com> Hello Matthias, Saturday, July 4, 2009, 6:39:30 PM, you wrote: > Or use a fold: >> process' = foldl op True files >> op True file = doit file >> op False _ = False foldM, probably, otherwise you will need to execute all actions before running fold -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From gue.schmidt at web.de Sat Jul 4 10:54:13 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sat Jul 4 10:36:52 2009 Subject: [Haskell-cafe] Re: Cont, ContT and IO() - Code on hpaste References: Message-ID: Hi, I've put the code that I wish to transform from using exceptions to using continuations on hpaste: ?http://hpaste.org/fastcgi/hpaste.fcgi/view?id=6515#a6515 thanks G?nther Am 04.07.2009, 01:11 Uhr, schrieb G?nther Schmidt : > > Hi, > > I've got an IO action, some file system IO, traversing one level only > and iterating over files found. I wish to build in an "early" exit, ie. > if an IO action in the loop encounters a particular value I want it to > abort the loop. > > Now so far, pls don't shoot, I have done this by throwing IO Exceptions > and catching them. I'm trying to rewrite this using Continuatios / > callCC but can't figure out where to place what. > > I certainly don't have the intuition yet and funny enough not even in > RWH I could find some Cont/ContT examples. > > Would someone please draw me an example? > > G?nther -- Erstellt mit Operas revolution?rem E-Mail-Modul: http://www.opera.com/mail/ From matthias.goergens at googlemail.com Sat Jul 4 11:43:22 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Jul 4 11:25:46 2009 Subject: [Haskell-cafe] Re: Cont, ContT and IO() - Code on hpaste In-Reply-To: References: Message-ID: Hi G?nther, here is a solution with the Maybe Monad: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=6515#a6515 Matthias. From matthias.goergens at googlemail.com Sat Jul 4 11:43:54 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Jul 4 11:26:18 2009 Subject: [Haskell-cafe] Re: Cont, ContT and IO() - Code on hpaste In-Reply-To: References: Message-ID: P.S. See http://en.wikibooks.org/wiki/Haskell/Monad_transformers for some documentation. From matthias.goergens at googlemail.com Sat Jul 4 11:45:44 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Jul 4 11:28:08 2009 Subject: [Haskell-cafe] Re: Cont, ContT and IO() - Code on hpaste In-Reply-To: References: Message-ID: P.P.S. Strange it does not seem to work with the paste. So here comes the solution by mail: module Consolidator.BusinessLogic.ConflictsResolved (consolidateDuplicates) where import System.FilePath import System.Directory import Control.Monad (filterM) import Control.Exception (throwIO) import System.Environment import Data.Maybe import Control.Monad import Control.Monad.Trans newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) } instance (Monad m) => Monad (MaybeT m) where (>>=) tmb_v f = MaybeT (runMaybeT tmb_v >>= \b_v -> case b_v of Nothing -> return Nothing Just v -> runMaybeT $ f v ) return = MaybeT . return . return instance MonadTrans MaybeT where lift mon = MaybeT (mon >>= return . Just) abort :: String -> MaybeT IO a abort reason = do lift . putStrLn $ reason MaybeT (return Nothing) {- The traversal is one directory deep only. I try to find out if every immediate subdirectory contains exactly one "*.gdr" file, and collect the path names in a list, sgls. Afterwards I append the contents of each such file to another file. I want to abort the whole process as soon as I encounter a directory that does not include exactly one *.gdr file. Currently I'm throwing exceptions but I'd prefer to rewrite this code to use continuations. -} consolidateDuplicates :: FilePath -> MaybeT IO () consolidateDuplicates fp = do dirs <- lift (getDirectoryContents fp) recs <- lift (filterM doesDirectoryExist $ map (fp ) $ filter (not . flip elem [".", ".."]) dirs) sgls <- mapM checkForSingle recs let cpy = fp "Korrigiert.gdr" lift (copyFile (fp "Konsolidiert.gdr") cpy) lift (mapM_ (\sgl -> do str <- readFile sgl appendFile cpy str) sgls) checkForSingle :: FilePath -> MaybeT IO FilePath checkForSingle fp = do cnt <- lift (getDirectoryContents fp) let fltr = filter ((== ".gdr") . takeExtension) case fltr cnt of [] -> abort ("The directory " ++ fp ++ " is empty") [f] -> return (fp f) _ -> abort ("There is more than one file in the directory " ++ fp) From byorgey at seas.upenn.edu Sat Jul 4 11:52:40 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Jul 4 11:35:04 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 124 - July 4, 2009 Message-ID: <20090704155240.GA2382@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090704 Issue 124 - July 04, 2009 --------------------------------------------------------------------------- Welcome to issue 124 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements HLint 1.6. Neil Mitchell [2]announced the release of [3]HLint 1.6, a tool for automatically suggesting improvements to Haskell code. Haskell Implementers Workshop: accepted talks. Simon Marlow [4]announced that the list of talks at the [5]Haskell Implementers Workshop 2009 has now been posted. bloxorz clone. Patai Gergely [6]announced a [7]Haskell clone of the game "bloxorz", written by Viktor Devecseri. Fun with type functions. Simon Peyton-Jones [8]announced that he, Ken Shan, and Oleg have finished Version 2 of their [9]paper "Fun with Type Functions", which gives a programmer's tour of what type functions are and how they are useful. If you have a moment to look at, and wanted to help them improve it, leave comments on the linked wiki page. package Boolean: Generalized booleans. Conal Elliott [10]announced [11]Boolean, a new package for generalized booleans, which provides type classes with generalizations of Boolean values and operations, if-then-else, Eq and Ord. TernaryTrees-0.1.1.1 - An efficient ternary tree implementation of Sets and Maps. Alex Mason [12]announced the release of [13]TernaryTrees, a package that extends Data.Set ad Data.Map with some ternary tree structures, one of the more efficient ways of storing strings in a set. 6.12.1 planning. Simon Marlow [14]announced plans for a release of GHC 6.12.1, sometime around September. If you have the time and inclination to help with any of the listed features, please get involved! regular-0.1. Jos? Pedro Magalh?es [15]announced the release of the [16]regular library. Many generic programs require information about the recursive positions of a data type, such as generic fold, generic rewriting, and the Zipper data structure. Regular provides a fixed point view on data which allows these definitions for regular data types. It also serves as the basis for a [17]generic rewriting library. Google Summer of Code Progress updates from participants in the 2008 [18]Google Summer of Code. Haddock improvements. Isaac Dupree has made it easier to generate Haddock documentation [19]for non-exported functions, posted an [20]overview of the issues involved in getting proper cross-package documentation working, and his current [21]plan. EclipseFP. Thomas Ten Cate has done a lot of work on EclipseFP, including some [22]cosmetic updates and getting [23]error reporting to work better. space profiling. Gergely Patai is [24]working on a network protocol for his profiling grapher tool, so that other tools can monitor the profiling information. haskell-src-exts. Niklas Broberg has [25]released [26]haskell-src-exts version 1.0.0! fast darcs. Petr Rockai has completed [27]quite a bit of work on darcs, including a [28]beta release of darcs 2.3. Discussion Monoid wants a (++) equivalent. Bryan O'Sullivan [29]suggested adding a more concise operator to the Monoid class for 'mappend', leading to a long, bike-shed-ish (but hopefully still useful) discussion. Reflections on the ICFP 2009 programming contest. Justin Bailey began a [30]discussion on results and experiences from the ICFP 2009 programming contest. Blog noise [31]Haskell news from the [32]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Gergely Patai: [33]Playing and learning. * Ketil Malde: [34]A set of tools for working with 454 sequences. * Sebastian Fischer: [35]FP Overview. * Magnus Therning: [36]Making a choice from a list in Haskell, Vty (part 1). * David Amos: [37]Conjugacy classes, part 1. * Well-Typed.Com: [38]GHC and Windows DLLs. * Manuel M T Chakravarty: [39]Converting typed term representations: from HOAS to de Bruijn.. * >>> Ivan Uemlianin: [40]Haskell: sort and sortBy. * Gregory Collins: [41]Building a website with Haskell, part 3. * Michael Snoyman: [42]Hack sample- chat server. * Luke Palmer: [43]On the By functions. * Magnus Therning: [44]Dataenc finally making it into Debian. * Thomas ten Cate: [45]New build instructions. * Erik de Castro Lopo: [46]Three More for the Debian New Queue. * >>> Yuval Kogman: [47]What Haskell did to my brain. * Greg Bacon: [48]FFI: calling into kernel32.dll. * Greg Bacon: [49]Setting up a simple test with Cabal. * Ketil Malde: [50]Dephd updates. * Bryan O'Sullivan: [51]What's in a text API?. * Brent Yorgey: [52]2009 ICFP programming contest reflections. * Galois, Inc: [53]Galois, Inc. Wins Two Small Business Research Awards from Federal Agencies. * Greg Bacon: [54]Cleaning up your Haskell imports. * Douglas M. Auclair (geophf): [55]Realized Constants are Comonadic. Quotes of the Week * KF8NH: all monads are functors, but for Hysterical Raisins not all Monads are Functors. * lilac: lambda actually is just the greek letter l. it stands for lilac. * lilac: before mauke we all implemented map with a fold every time we needed it. * luqui: I'll just stick to my religion: I have a personal relationship with our lord and savior, the untyped lambda calculus. * copumpkin: I think I was implemented in haskell. I mean, my parents never used seq, ever. * Benjamin Russell: Haskell. "Avoid success at all costs." Made with dinosaur technology. 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://article.gmane.org/gmane.comp.lang.haskell.general/17332 3. http://community.haskell.org/~ndm/hlint/ 4. http://article.gmane.org/gmane.comp.lang.haskell.general/17331 5. http://haskell.org/haskellwiki/HaskellImplementorsWorkshop 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/60907 7. http://just-bottom.blogspot.com/2009/07/playing-and-learning.html 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/60846 9. http://haskell.org/haskellwiki/Simonpj/Talk:FunWithTypeFuns 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/60716 11. http://hackage.haskell.org/package/Boolean 12. http://www.haskell.org//pipermail/haskell-cafe/2009-June/063625.html 13. http://hackage.haskell.org/package/TernaryTrees 14. http://www.haskell.org//pipermail/haskell-cafe/2009-June/063681.html 15. http://www.haskell.org//pipermail/haskell/2009-July/021468.html 16. http://www.cs.uu.nl/wiki/bin/view/GenericProgramming/Regular 17. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rewriting 18. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 19. http://haddock2009.wordpress.com/2009/06/23/how-to-navigate-your-code/ 20. http://haddock2009.wordpress.com/2009/06/24/cross-package-documentation-part-1/ 21. http://haddock2009.wordpress.com/2009/06/25/cross-package-plan-a/ 22. http://eclipsefp.wordpress.com/2009/06/20/cosmetics/ 23. http://eclipsefp.wordpress.com/2009/06/30/compiling-and-error-reporting/ 24. http://just-bottom.blogspot.com/2009/06/short-term-hp2any-plans.html 25. http://nibrofun.blogspot.com/2009/06/gsoc-status-report-week-4.html 26. http://hackage.haskell.org/package/haskell%2Dsrc%2Dexts 27. http://web.mornfall.net/blog/soc_progress_5.html 28. http://web.mornfall.net/blog/darcs_2.3_beta_1.html 29. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/60754 30. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/60690 31. http://planet.haskell.org/ 32. http://haskell.org/haskellwiki/Blog_articles 33. http://just-bottom.blogspot.com/2009/07/playing-and-learning.html 34. http://blog.malde.org/index.php/2009/07/03/a-set-of-tools-for-working-with-454-sequences/ 35. http://www-ps.informatik.uni-kiel.de/~sebf/haskell/fp-overview.html 36. http://therning.org/magnus/archives/685 37. http://haskellformaths.blogspot.com/2009/06/conjugacy-classes-part-1.html 38. http://blog.well-typed.com/2009/07/ghcdlls/ 39. http://justtesting.org/post/134566537 40. http://llaisdy.wordpress.com/2009/07/03/haskell-sort-and-sortby/ 41. http://gregorycollins.net/posts/2009/07/02/building-a-website-part-3 42. http://blog.snoyman.com/2009/07/01/hack-sample-chat-server/ 43. http://lukepalmer.wordpress.com/2009/07/01/on-the-by-functions/ 44. http://therning.org/magnus/archives/672 45. http://eclipsefp.wordpress.com/2009/07/01/new-build-instructions/ 46. http://www.mega-nerd.com/erikd/Blog/CodeHacking/Debian/polyparse_dataenc_json.html 47. http://nothingmuch.woobling.org/talks/takahashi.xul?data=yapc_na_2009/haskell_brain.txt#page1 48. http://feedproxy.google.com/~r/gbacon/~3/o-lAJeIoUbk/ffi-calling-into-kernel32dll.html 49. http://feedproxy.google.com/~r/gbacon/~3/7rlf4Dd1JKU/setting-up-simple-test-with-cabal.html 50. http://blog.malde.org/index.php/2009/06/16/dephd-updates/ 51. http://www.serpentine.com/blog/2009/06/30/python-and-haskell-text-apis-compare/ 52. http://byorgey.wordpress.com/2009/06/29/2009-icfp-programming-contest-reflections/ 53. http://www.galois.com/blog/2009/06/29/galois-awarded-two-federal-sbirs/ 54. http://feedproxy.google.com/~r/gbacon/~3/AGNKaCB2-GI/cleaning-up-your-haskell-imports.html 55. http://logicaltypes.blogspot.com/2009/06/realized-constants-are-comonadic.html 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 dbueno at gmail.com Sat Jul 4 13:23:39 2009 From: dbueno at gmail.com (Denis Bueno) Date: Sat Jul 4 13:06:02 2009 Subject: [Haskell-cafe] Small Haddock question In-Reply-To: <4A4F6591.2050508@btinternet.com> References: <4A4F6591.2050508@btinternet.com> Message-ID: <6dbd4d000907041023h24ccc288x495be6f2b6cc8ba3@mail.gmail.com> On Sat, Jul 4, 2009 at 08:22, Andrew Coppin wrote: > This is irritating me now... Suppose I have something like the following: > > zero = 0 :: Int > one = 1 :: Int > two = 2 :: Int > three = 3 :: Int > > How do I add Haddock comments to the end of each line? For some reason, > Haddock doesn't like either of > > zero = 0 :: Int -- | Zero > zero = 0 :: Int -- ^ Zero > > Either way it whinges about parse errors. How do I make it shut up and stop > being so dense at me? :-} It's damned obvious what I want it to do... I think top-level definitions can only be commented in one way: -- | Emptiness and void, as an Int. zero = 0 :: Int Denis From cetin.sert at gmail.com Sat Jul 4 13:32:40 2009 From: cetin.sert at gmail.com (Cetin Sert) Date: Sat Jul 4 13:15:23 2009 Subject: [Haskell-cafe] Flow Graphs for Language-independent Code Representation Message-ID: <1ff5dedc0907041032g66c604ah8c52285be0d65447@mail.gmail.com> Hi *^o^*, I'm working on a source code transformation project for numerical automatic differentiation for Fortran and C. I would love to know the best Haskell way/package available today to represent procedural (non-OO) code in a language-independent manner. Any tips or resource, paper references are most welcome! Regards, Cetin Sert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090704/cf82f9c8/attachment.html From andrewcoppin at btinternet.com Sat Jul 4 13:47:36 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 13:29:56 2009 Subject: [Haskell-cafe] ANN: HalfInteger-1.1.1 In-Reply-To: <57526e770907040948g64592d6evfe749cccba27701f@mail.gmail.com> References: <4A476F0E.5060305@btinternet.com> <4A4F3EF1.904@btinternet.com> <57526e770907040948g64592d6evfe749cccba27701f@mail.gmail.com> Message-ID: <4A4F95B8.3060706@btinternet.com> Alexander Dunlap wrote: > Couple of suggestions: > > - You should put an (Integer i) => constraint on the halve function so > that it becomes impossible to create invalid HalfIntegers. > Right. Currently you can *make* such a HalfInteger. You just won't be able to *do* anything with it afterwards. It would probably be more sensible to just add a constraint there. > - The documentation for toHalfInteger is truncated. Also, why can't > you make the rounding more predictable? > ...wow. OK, I'm looking at the source, and it seems I must have got distracted at that moment or something, because I just 100% didn't actually finish writing the documentation! o_O That's pretty special. ;-) As I *should* have written, the rounding for something like toHalfInteger 0.25 is kind of unpredictable; but if you do toHalfInteger 0.5, the result is *guaranteed* to be exact. All the functions are carefully tuned to work correctly on things which really are half integers, and to give plausible results otherwise. Just don't let your life depend on 0.25 being mapped to exactly a half or to exactly zero... > Nice work! > Heh, thanks. From andrewcoppin at btinternet.com Sat Jul 4 13:56:44 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 13:39:05 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK Message-ID: <4A4F97DC.3090707@btinternet.com> OK, so having released AC-HalfInteger, I got slightly carried away and released three other small packages. These are packages that many programs I write all end up using. I'm forever copying these files, so I made them into actual bonafide packages. http://hackage.haskell.org/package/AC-Vector-1.1.1 This provides two types, Vector2 and Vector3, which are unboxed vectors of Doubles, with arithmetic, dot product and cross product, and a few other useful items. http://hackage.haskell.org/package/AC-Colour-1.1.1 This provides two types, Colour and Colour8. Both implement simple RGB colour types with arithmetic. Colour has unboxed Double fields, and Colour8 has unboxed Word8 fields. My usual workflow is to do all the image generation with Colour, and to convert to Colour8 just before the data hits the I/O channels. You can, however, do arithmetic directly on Colour8. (I haven't extensively tested that it works properly though...) http://hackage.haskell.org/package/AC-EasyRaster-GTK-1.1.1 This is a layer over Gtk2hs. As you all probably know, Gtk2hs provides a Cairo binding that makes vector graphics wonderfully easy. However, *bitmapped* graphics is darned tricky. I basically had to sit in the #haskell channel with Duncan for a few hours trying to figure out how the hell to do it. This knowledge is now codified in the above package. Load it up and you don't need to know a thing about GTK; you can just create an ImageBuffer, write some pixels to it (efficiently!), save it to disk or display it on screen. (But you *can* access the underlying GTK+ resources if you wish...) In other news, it appears that the batch job to generate the documentation just ran, so you can view it all online. :-D Comments, suggestions, random flames, etc... [I'm particularly curios to know what Duncan will make of the GTK thing...] From felipe.lessa at gmail.com Sat Jul 4 14:13:53 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Jul 4 13:56:22 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <4A4F97DC.3090707@btinternet.com> References: <4A4F97DC.3090707@btinternet.com> Message-ID: <20090704181353.GB3861@kira.casa> On Sat, Jul 04, 2009 at 06:56:44PM +0100, Andrew Coppin wrote: > http://hackage.haskell.org/package/AC-Colour-1.1.1 Why don't you use colour[1]? [1] http://hackage.haskell.org/package/colour -- Felipe. From andrewcoppin at btinternet.com Sat Jul 4 14:38:47 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 14:21:12 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <20090704181353.GB3861@kira.casa> References: <4A4F97DC.3090707@btinternet.com> <20090704181353.GB3861@kira.casa> Message-ID: <4A4FA1B7.8040407@btinternet.com> Felipe Lessa wrote: > On Sat, Jul 04, 2009 at 06:56:44PM +0100, Andrew Coppin wrote: > >> http://hackage.haskell.org/package/AC-Colour-1.1.1 >> > > Why don't you use colour[1]? > > [1] http://hackage.haskell.org/package/colour > A few reasons: 1. I never knew it existed. ;-) 2. It's mind-blowingly complex. 3. It doesn't appear to provide arithmetic over colours. 4. It's parameterised over the component type; my library is hard-coded to specific types for speed. From max.rabkin at gmail.com Sat Jul 4 15:01:53 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sat Jul 4 14:44:37 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <4A4FA1B7.8040407@btinternet.com> References: <4A4F97DC.3090707@btinternet.com> <20090704181353.GB3861@kira.casa> <4A4FA1B7.8040407@btinternet.com> Message-ID: On Sat, Jul 4, 2009 at 8:38 PM, Andrew Coppin wrote: > A few reasons: > > 1. I never knew it existed. ;-) A good reason. However, it's good to do a quick search over Hackage before uploading (or before writing) so you know what's out there. Also, if you hadn't used an "AC-" prefix, you'd have had a name collision. Is there a particular reason why you want your name in the package name rather than just the author field? > 2. It's mind-blowingly complex. Colour *is* complex. Which is why I'm so glad Russell O'Connor did all the hard work for me :) > 3. It doesn't appear to provide arithmetic over colours. It provides darken, blend and addition (though addition is called mappend rather than (+)). signum, abs and fromInteger don't make a huge amount of sense for colours. > 4. It's parameterised over the component type; my library is hard-coded to > specific types for speed. My feeling would be to trust the specializer until it lets me down. Has it let you down in the past? BTW, the EasyRaster package looks useful. --Max From andrewcoppin at btinternet.com Sat Jul 4 15:18:53 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 15:01:14 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: References: <4A4F97DC.3090707@btinternet.com> <20090704181353.GB3861@kira.casa> <4A4FA1B7.8040407@btinternet.com> Message-ID: <4A4FAB1D.8030808@btinternet.com> Max Rabkin wrote: > On Sat, Jul 4, 2009 at 8:38 PM, Andrew > Coppin wrote: > >> A few reasons: >> >> 1. I never knew it existed. ;-) >> > > A good reason. However, it's good to do a quick search over Hackage > before uploading (or before writing) so you know what's out there. > Fair enough. ;-) > Also, if you hadn't used an "AC-" prefix, you'd have had a name > collision. Is there a particular reason why you want your name in the > package name rather than just the author field? > Well, for example, there's seemingly half a dozen unrelated packages all called "binary", which is just confusing. I wanted to make sure my packages had unique names. (I mean, so do the existing binary packages, just not very useful ones...) >> 2. It's mind-blowingly complex. >> > > Colour *is* complex. Which is why I'm so glad Russell O'Connor did all > the hard work for me :) > Well, no, because now I'm going to have to spend a few hours trying to find out what CIE is before I can even use that library. I think really it's just aimed at a different problem. It looks like it's trying to specify actual real-world colours. [It's news to me that this isn't fundamentally impossible...] I'm only trying to specify colours on a computer screen. And as we all know, computer screens aren't calibrated in any way, and the same RGB value looks different on each display. But then, I'm only trying to write a fractal generator, so CIE specifications are somewhat overkill here. ;-) >> 3. It doesn't appear to provide arithmetic over colours. >> > > It provides darken, blend and addition (though addition is called > mappend rather than (+)). signum, abs and fromInteger don't make a > huge amount of sense for colours. > Yeah, I implemented signum and so forth for colours and vectors, but they're not particularly meaningful... [Insert remark here about Haskell's numeric class hierachy.] So mappend gives you colour addition [with the perplexing comments about "gamut", presumably some kind of small mammal?], but there's no subtraction? No multiplication? No linear blending? >> 4. It's parameterised over the component type; my library is hard-coded to >> specific types for speed. >> > > My feeling would be to trust the specializer until it lets me down. > Has it let you down in the past? > Heh, my colour library includes a custom floor implementation that talks to the GHC primops directly because calling floor is too slow... [In case that sounds like idle talk, I had a program go from 10 seconds to less than 1 second just by using this function. There's a few tickets about it on the GHC Trac.] > BTW, the EasyRaster package looks useful. > Well, I'd like to think so... It doesn't do anything you couldn't do yourself if you spend a day or two trying to grok the GTK complexity. But it's much easier to just import some code somebody else has already written. ;-) Certainly when I'm in the middle of trying to build a complicated bit of software, figuring out how to just write a few pixels onto the screen is a low priority. From uhollerbach at gmail.com Sat Jul 4 15:35:41 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sat Jul 4 15:18:04 2009 Subject: [Haskell-cafe] following up on space leak In-Reply-To: <200907041036.42915.marcin.kosiba@gmail.com> References: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> <200907041036.42915.marcin.kosiba@gmail.com> Message-ID: <65d7a7e0907041235x582c76b5vb182fe2304ee4304@mail.gmail.com> On 7/4/09, Marcin Kosiba wrote: > On Saturday 04 July 2009, Uwe Hollerbach wrote: >> Good evening, all, following up on my question regarding space leaks, >> I seem to have stumbled across something very promising. I said I was >> using this tiny function "lastOrNil" to get the last value in a list, >> or the empty (scheme) list if the haskell list was empty. The uses of >> it were all of the form >> >> lastOrNil (mapM ) >> >> so I wrote a different function mapML to do this directly: >> > mapML fn lst = mapMLA (List []) fn lst >> > where mapMLA r _ [] = return r >> > mapMLA ro fn (x:xs) = >> > do rn <- fn x >> > mapMLA rn fn xs >> >> This isn't an accumulator, it's a replacer (or, if you like, the >> "accumulation" is "drop the old one on the floor"), it starts out with >> the scheme empty list that I want as the default, and it never even >> builds the list which it'll just dump an instant later. Shazam! Memory >> usage dropped by roughly an order of magnitude in my little Collatz >> benchmark, and incidentally runtime improved by 25% or so as well. The >> horror! :-) > > Hi, > IMHO expressing mapML using StateT would be a bit cleaner ;) > > mapML :: (Monad m) => (a -> m List) -> [a] -> m List > mapML fn lst = execStateT mapMLAs (List []) > where > mapMLAs = sequence_ $ map mapMLA lst > mapMLA x = (lift $ fn x) >>= put > > -- > Marcin Kosiba Yeah, I'm sure there are more-elegant ways to write this, I'm still very much a beginner in haskell. I'm just very thrilled by the reduction in memory usage! Uwe From max.rabkin at gmail.com Sat Jul 4 15:35:52 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sat Jul 4 15:18:34 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <4A4FAB1D.8030808@btinternet.com> References: <4A4F97DC.3090707@btinternet.com> <20090704181353.GB3861@kira.casa> <4A4FA1B7.8040407@btinternet.com> <4A4FAB1D.8030808@btinternet.com> Message-ID: On Sat, Jul 4, 2009 at 9:18 PM, Andrew Coppin wrote: >>> 2. It's mind-blowingly complex. >>> >> >> Colour *is* complex. Which is why I'm so glad Russell O'Connor did all >> the hard work for me :) >> > > Well, no, because now I'm going to have to spend a few hours trying to find > out what CIE is before I can even use that library. The sRGB function makes a Colour from RGB (actually sRGB, which is a "standardised" RGB -- basically RGB where the exact frequency and power of each channel is specified -- but you can pretend your monitor's RGB is sRGB. > So mappend gives you colour addition [with the perplexing comments about > "gamut", presumably some kind of small mammal?] The gamut of a device is the range of representable colours (a monitor's gamut looks something like a parabola with a flat base in XYZ space, whereas a printer's is much more complex and variable). This makes sense. If you double a monitor's brightest white, you don't get a colour twice as bright: you get the same colour. > but there's no subtraction? > No multiplication? No linear blending? affineCombo can do subtraction, again with the gamut warning. darken does scalar multiplication; it probably doesn't do componentwise multiplication, which doesn't make much sense if you're trying to work in a coordinate-independent setting, though I admit RGB-multiplication can be handy. > Heh, my colour library includes a custom floor implementation that talks to > the GHC primops directly because calling floor is too slow... > > [In case that sounds like idle talk, I had a program go from 10 seconds to > less than 1 second just by using this function. There's a few tickets about > it on the GHC Trac.] Fair enough. Can your implementation not be turned into a patch? BTW, I'm also working on Haskell fractals. You might be interested in looking at my fractal package (though it's currently undocumented, and has no GUI). --Max From andrewcoppin at btinternet.com Sat Jul 4 15:54:36 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 4 15:36:57 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <4A4FAFA6.4030802@cogito.org.uk> References: <4A4F97DC.3090707@btinternet.com> <20090704181353.GB3861@kira.casa> <4A4FA1B7.8040407@btinternet.com> <4A4FAB1D.8030808@btinternet.com> <4A4FAFA6.4030802@cogito.org.uk> Message-ID: <4A4FB37C.6040808@btinternet.com> Paul Johnson wrote: > Andrew Coppin wrote: >> Well, no, because now I'm going to have to spend a few hours trying >> to find out what CIE is before I can even use that library. >> >> I think really it's just aimed at a different problem. It looks like >> it's trying to specify actual real-world colours. [It's news to me >> that this isn't fundamentally impossible...] I'm only trying to >> specify colours on a computer screen. And as we all know, computer >> screens aren't calibrated in any way, and the same RGB value looks >> different on each display. But then, I'm only trying to write a >> fractal generator, so CIE specifications are somewhat overkill here. ;-) > Your display may not be calibrated, but those used for graphic design > certainly are. Indeed. And if you're in any kind of position where you *care* about such things, you should be using color, not AC-Colour. If, however, you just want to throw together pretty pictures, AC-Colour is simpler and easier. Different libraries for slightly different tasks. ;-) > On the package naming front: I appreciate your wish to avoid just > having another "colour" library. But "AC_Colour" doesn't help much. > "Simple_colour" might be better. Mmm, yeah. Naming everything with "AC" precludes name clashes and doesn't require too much thinking. Coming up with a better name requires thinking about what actually makes your package unique. And, of course, if another package comes along, that analysis may change. (E.g., I seem to recall there's a "newbinary" package which has actually been long since superceeded - so not so "new" any more!) If I name my package simple-colour, and then somebody else makes an even simpler one... the name becomes kind of meaningless. (Admitedly there's not too much danger of this happening...) I just like the idea of having definitely unique, distinctive package names. Otherwise I'd have to come up with stuff like geovector and trivicolour and so on... Arguably EasyRaster-GTK should have been a sufficiently unique name by itself though. From matthias.goergens at googlemail.com Sat Jul 4 17:09:24 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Jul 4 16:51:47 2009 Subject: [Haskell-cafe] Optimizing Compiler for the ICFP 09 contest's VM Message-ID: The byte code for the virtual machine of this years ICFP specified a language with single assignment per simulation step. Interestingly most memory locations get overwritten each simulation step before they are read. That means, those locations don't have to be remember between steps. Also locations that never get overwritten (e.g. location associated with Noops), are constant. Thus the variables state of the simulation is orders of magnitude smaller than the naive 2^16 * 32 bit + 1 bit. I wrote a small program that analyses the dataflow of a byte code program (and initial memory setup) for the VM. After analyzing my program emits Haskell code to run the given byte code. If anyboby is interested, I can document my program and put it online somewhere. I also made pretty graphs of the dataflow with graphviz. From noteed at gmail.com Sat Jul 4 17:12:30 2009 From: noteed at gmail.com (minh thu) Date: Sat Jul 4 16:55:13 2009 Subject: [Haskell-cafe] Optimizing Compiler for the ICFP 09 contest's VM In-Reply-To: References: Message-ID: <40a414c20907041412s7d5575bere74fa7cc1304a926@mail.gmail.com> 2009/7/4 Matthias G?rgens : > The byte code for the virtual machine of this years ICFP specified a > language with single assignment per simulation step. Interestingly > most memory locations get overwritten each simulation step before they > are read. That means, those locations don't have to be remember > between steps. Also locations that never get overwritten (e.g. > location associated with Noops), are constant. Thus the variables > state of the simulation is orders of magnitude smaller than the naive > 2^16 * 32 bit + 1 bit. > > I wrote a small program that analyses the dataflow of a byte code > program (and initial memory setup) for the VM. After analyzing my > program emits Haskell code to run the given byte code. > > If anyboby is interested, I can document my program and put it online > somewhere. I also made pretty graphs of the dataflow with graphviz. Hi Matthias, it would be nice to blog a little post about what you found and the pretty graphs :) Thu From allbery at ece.cmu.edu Sat Jul 4 18:10:24 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Jul 4 17:53:05 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: References: <4A4F97DC.3090707@btinternet.com> <20090704181353.GB3861@kira.casa> <4A4FA1B7.8040407@btinternet.com> Message-ID: On Jul 4, 2009, at 15:01 , Max Rabkin wrote: > On Sat, Jul 4, 2009 at 8:38 PM, Andrew > Coppin wrote: >> 3. It doesn't appear to provide arithmetic over colours. > > It provides darken, blend and addition (though addition is called > mappend rather than (+)). signum, abs and fromInteger don't make a > huge amount of sense for colours. I don't see a good meaning for signum offhand, but fromInteger could take an X11-encoded RGB value and abs could produce grayscale brightness. -- 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/20090704/b1cb54fb/PGP.bin From chris at eidhof.nl Sun Jul 5 13:49:30 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Sun Jul 5 13:31:54 2009 Subject: [Haskell-cafe] How to pretty print code efficiently In-Reply-To: <57526e770907032013v3eed0a9cl626624bd6abf026f@mail.gmail.com> References: <57526e770907032013v3eed0a9cl626624bd6abf026f@mail.gmail.com> Message-ID: On 4 jul 2009, at 05:13, Alexander Dunlap wrote: > On Fri, Jul 3, 2009 at 6:45 PM, John Ky wrote: >> Hi, >> >> Currently I'm pretty printing code by building arrays of strings >> and calling >> indent. For example: >> >> instance JavaPrintableNamed AST.EnumeratedType where >> javaLinesNamed parentName (AST.EnumeratedType memberDefinitions) = >> [ "public enum " ++ asJavaId(parentName) >> , "{" >> ] ++ memberCodeLines ++ >> [ "}" >> , "" >> ] >> where >> memberCodeLines = indent $ javaLines memberDefinitions >> >> The indent function takes a list of strings and adds an indent to the >> beginning of every line. >> >> I can imagine this to be very inefficient as it builds many strings >> and >> concatenates them. >> >> In Ruby, I might do the same thing like this: >> >> class EnumeratedType < JavaPrintableNamed >> def writeTo(writer) >> writer.print "public enum " >> writer.puts self.asJavaId >> writer.puts "{" >> writer.indent do >> self.memberDefinitions.writeTo(writer) >> writer.puts >> end >> >> where above, the writer.indent takes care of the indent, and >> everything is >> appended to a stream, which doesn't seem so bad in terms of >> efficiency. >> >> I'm looking for a way to do something similar in Haskell. >> >> Anyone can give me a hand? >> >> Thanks >> >> -John >> >> >> _______________________________________________ > > You may want to investigate the standard module > Text.PrettyPrint.HughesPJ, which contains a number of (I assume fairly > efficient) combinators for pretty printing. I second that. Also, there is uulib which has a pretty printing module that's quite similar: http://hackage.haskell.org/packages/archive/uulib/0.9.10/doc/html/UU-PPrint.html I think both packages are based on the paper "The Design of a Pretty- printing Library" which can be found at http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps Not only do they provide abstractions for things like indentation, concatenation in different forms, etc., but they also are more efficient than a naive implementation using lists. -chris -chris From conal at conal.net Sun Jul 5 13:58:22 2009 From: conal at conal.net (Conal Elliott) Date: Sun Jul 5 13:41:02 2009 Subject: [Haskell-cafe] Read & Show instance generation for GADTs? Message-ID: Are there any tools for generating Show & Read instances for GADTs? - Conal -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090705/62ee5f6f/attachment.html From lemming at henning-thielemann.de Sun Jul 5 16:30:29 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Jul 5 16:12:38 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <4ec472cb0907010811v434ac162x41748edd7d3a084@mail.gmail.com> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> <4ec472cb0907010811v434ac162x41748edd7d3a084@mail.gmail.com> Message-ID: <4A510D65.3030106@henning-thielemann.de> Robert Greayer schrieb: > I'm sure there's some important historical reason... but why isn't '&' > used in something more prominent than the fgl package? I understand > why it's not used for bitwise AND in Data.Bits (I assume because the > corresponding bitwise '|' operator isn't available), but all the other > single-character operators** (in the ASCII range) are used in some > core library (if not the Prelude itself). But not '&'. Why? It > makes sense (to me) as a Monoid 'append'. (?) is also undefined in Prelude. From lemming at henning-thielemann.de Sun Jul 5 16:41:16 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Jul 5 16:23:36 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: Message-ID: On Tue, 30 Jun 2009, Bryan O'Sullivan wrote: > I've thought for a while that it would be very nice indeed if the Monoid class had a more > concise operator for infix appending than "a `mappend` b". I wonder if other people are of a > similar opinion, and if so, whether this is worth submitting a libraries@ proposal over. We have the package version policy which relies on explicit or qualified imports, such that adding a function like (++) to Data.Monoid cannot harm any package that follow that policy. Thus I vote for not introducing a new operator, in order to keep the set of infix operators to memorize small, but use (++) for the generalized (List.++) aka mappend. The user would however need to hide (++) from Prelude. From dons at galois.com Sun Jul 5 17:27:12 2009 From: dons at galois.com (Don Stewart) Date: Sun Jul 5 17:11:32 2009 Subject: [Haskell-cafe] ANN: bloxorz clone In-Reply-To: <1246652524.9181.1323418579@webmail.messagingengine.com> References: <1246652524.9181.1323418579@webmail.messagingengine.com> Message-ID: <20090705212712.GB10538@whirlpool.galois.com> patai_gergely: > Hello all, > > This post is not about my own creation, it's just a little fun program > written by a student of mine. You can install the bloxorz package to try > it out, and read more about its background on my blog: > > http://just-bottom.blogspot.com/2009/07/playing-and-learning.html Here's a video of bloxorz at work, very cool! http://archhaskell.wordpress.com/2009/07/04/bloxorz-an-opengl-logic-game-written-in-haskell/ From ekmett at gmail.com Sun Jul 5 20:06:59 2009 From: ekmett at gmail.com (Edward Kmett) Date: Sun Jul 5 19:49:18 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: References: Message-ID: <7fb8f82f0907051706h4dd8ba1ar246abe4f4c7cdd9f@mail.gmail.com> While I like the idea of (++) as mappend to some extent, two objections immediately come to mind: 1.) While I like the appeal to the PVP to export a version of (++) from Data.Monoid and I think this has worked out well for new modules like Control.Category, I'm not sure that with a module that has been around for so long as Data.Monoid can be so flippant about breaking any code that imports it unqualified that also happens to use a list. Lists are everywhere in Haskell, and unqualified imports do exist. 2.) There is also a pretty big caveat in that the choice of which operator should be naturally selected for (++) _is_ ambiguous. Should it be mappend or mplus? Recall that in Haskell 1.4 (++) worked on MonadPlus and it was changed in the great monomorphism revolution of '98. -Edward Kmett On Sun, Jul 5, 2009 at 4:41 PM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > > On Tue, 30 Jun 2009, Bryan O'Sullivan wrote: > > I've thought for a while that it would be very nice indeed if the Monoid >> class had a more >> concise operator for infix appending than "a `mappend` b". I wonder if >> other people are of a >> similar opinion, and if so, whether this is worth submitting a libraries@proposal over. >> > > We have the package version policy which relies on explicit or qualified > imports, such that adding a function like (++) to Data.Monoid cannot harm > any package that follow that policy. Thus I vote for not introducing a new > operator, in order to keep the set of infix operators to memorize small, but > use (++) for the generalized (List.++) aka mappend. The user would however > need to hide (++) from Prelude. > > _______________________________________________ > 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/20090705/c80e55bd/attachment.html From ninegua at gmail.com Sun Jul 5 22:06:28 2009 From: ninegua at gmail.com (Paul L) Date: Sun Jul 5 21:48:46 2009 Subject: [Haskell-cafe] following up on space leak In-Reply-To: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> References: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> Message-ID: <856033f20907051906j59b0e4a5k7a62679ecaeb3f82@mail.gmail.com> Previously you had lastOrNil taking m [a] as input, presumably generated by mapM. So mapM is actually building an entire list before it returns the argument for you to call lastOrNil. This is where you had unexpected memory behavior. Now you are "fusing" lastOrNil and mapM together, and instead of building a list, you traverse it and perform monadic action along the way. This can happen in a constant memory if the original pure list is generated lazily. I think the real problem you had was a mis-understanding of mapM, and there was nothing wrong with your previous lastOrNil function. mapM will only return a list after all monadic actions are performed, and in doing so, it inevitably has to build the entire list along the way. -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale On 7/4/09, Uwe Hollerbach wrote: > Good evening, all, following up on my question regarding space leaks, > I seem to have stumbled across something very promising. I said I was > using this tiny function "lastOrNil" to get the last value in a list, > or the empty (scheme) list if the haskell list was empty. The uses of > it were all of the form > > lastOrNil (mapM ) > > so I wrote a different function mapML to do this directly: > >> mapML fn lst = mapMLA (List []) fn lst >> where mapMLA r _ [] = return r >> mapMLA ro fn (x:xs) = >> do rn <- fn x >> mapMLA rn fn xs > > This isn't an accumulator, it's a replacer (or, if you like, the > "accumulation" is "drop the old one on the floor"), it starts out with > the scheme empty list that I want as the default, and it never even > builds the list which it'll just dump an instant later. Shazam! Memory > usage dropped by roughly an order of magnitude in my little Collatz > benchmark, and incidentally runtime improved by 25% or so as well. The > horror! :-) > > Having tasted blood, I will of course be continuing to benchmark... > but not tonight. > > Uwe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From uhollerbach at gmail.com Sun Jul 5 22:46:25 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sun Jul 5 22:28:44 2009 Subject: [Haskell-cafe] following up on space leak In-Reply-To: <856033f20907051906j59b0e4a5k7a62679ecaeb3f82@mail.gmail.com> References: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> <856033f20907051906j59b0e4a5k7a62679ecaeb3f82@mail.gmail.com> Message-ID: <65d7a7e0907051946g5e51156at9529dcc8480f45c5@mail.gmail.com> On 7/5/09, Paul L wrote: > Previously you had lastOrNil taking m [a] as input, presumably > generated by mapM. So mapM is actually building an entire list before > it returns the argument for you to call lastOrNil. This is where you > had unexpected memory behavior. > > Now you are "fusing" lastOrNil and mapM together, and instead of > building a list, you traverse it and perform monadic action along the > way. This can happen in a constant memory if the original pure list is > generated lazily. > > I think the real problem you had was a mis-understanding of mapM, and > there was nothing wrong with your previous lastOrNil function. mapM > will only return a list after all monadic actions are performed, and > in doing so, it inevitably has to build the entire list along the way. > > -- > Regards, > Paul Liu > > Yale Haskell Group > http://www.haskell.org/yale Hi, Paul, thanks for the comments. You're quite right that I am fusing the two functions together, but I think I wasn't mis-understanding mapM... I knew I was generating the entire list, and aside from the slight inefficiency of generating it only to tear it down an instant later, that would have been no problem. But I was expecting all of the memory associated with the list to be reclaimed after I had processed it, and that was what was not happening as far as I could tell. (This isn't one monolithic list, by the way; it's the small bodies of a couple of small scheme functions that get evaluated over and over. So the setup and teardown happens a lot.) I don't have very good intuition yet about what should get garbage-collected and what should get kept in such situations, and in fact I'm kind of in the same boat again: the test case now runs much better, but it still leaks memory, and I am again stumped as to why. Could I see something useful by examining ghc core? I haven't looked at that yet, no idea what to look for... Uwe From alexander.dunlap at gmail.com Sun Jul 5 22:52:55 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Jul 5 22:35:34 2009 Subject: [Haskell-cafe] following up on space leak In-Reply-To: <65d7a7e0907051946g5e51156at9529dcc8480f45c5@mail.gmail.com> References: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> <856033f20907051906j59b0e4a5k7a62679ecaeb3f82@mail.gmail.com> <65d7a7e0907051946g5e51156at9529dcc8480f45c5@mail.gmail.com> Message-ID: <57526e770907051952u80ba639of5fe921e64b2039c@mail.gmail.com> On Sun, Jul 5, 2009 at 7:46 PM, Uwe Hollerbach wrote: > On 7/5/09, Paul L wrote: >> Previously you had lastOrNil taking m [a] as input, presumably >> generated by mapM. So mapM is actually building an entire list before >> it returns the argument for you to call lastOrNil. This is where you >> had unexpected memory behavior. >> >> Now you are "fusing" lastOrNil and mapM together, and instead of >> building a list, you traverse it and perform monadic action along the >> way. This can happen in a constant memory if the original pure list is >> generated lazily. >> >> I think the real problem you had was a mis-understanding of mapM, and >> there was nothing wrong with your previous lastOrNil function. mapM >> will only return a list after all monadic actions are performed, and >> in doing so, it inevitably has to build the entire list along the way. >> >> -- >> Regards, >> Paul Liu >> >> Yale Haskell Group >> http://www.haskell.org/yale > > Hi, Paul, thanks for the comments. You're quite right that I am fusing > the two functions together, but I think I wasn't mis-understanding > mapM... I knew I was generating the entire list, and aside from the > slight inefficiency of generating it only to tear it down an instant > later, that would have been no problem. But I was expecting all of the > memory associated with the list to be reclaimed after I had processed > it, and that was what was not happening as far as I could tell. (This > isn't one monolithic list, by the way; it's the small bodies of a > couple of small scheme functions that get evaluated over and over. So > the setup and teardown happens a lot.) I don't have very good > intuition yet about what should get garbage-collected and what should > get kept in such situations, and in fact I'm kind of in the same boat > again: the test case now runs much better, but it still leaks memory, > and I am again stumped as to why. Could I see something useful by > examining ghc core? I haven't looked at that yet, no idea what to look > for... > > Uwe > _______________________________________________ mapM_ might be useful to you. I know there are cases where mapM leaks memory but mapM_ doesn't, basically because mapM_ throws away all of the intermediate results immediately. You might want to condition on nullness of the list and then mapM_ your function over the init of the list and then just return the function on the last element of the list. Alex From uhollerbach at gmail.com Sun Jul 5 23:27:29 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sun Jul 5 23:09:55 2009 Subject: [Haskell-cafe] following up on space leak In-Reply-To: <57526e770907051952u80ba639of5fe921e64b2039c@mail.gmail.com> References: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> <856033f20907051906j59b0e4a5k7a62679ecaeb3f82@mail.gmail.com> <65d7a7e0907051946g5e51156at9529dcc8480f45c5@mail.gmail.com> <57526e770907051952u80ba639of5fe921e64b2039c@mail.gmail.com> Message-ID: <65d7a7e0907052027q7a16f595w9fa53fcacb8cdaab@mail.gmail.com> On 7/5/09, Alexander Dunlap wrote: > On Sun, Jul 5, 2009 at 7:46 PM, Uwe Hollerbach > wrote: >> On 7/5/09, Paul L wrote: >>> Previously you had lastOrNil taking m [a] as input, presumably >>> generated by mapM. So mapM is actually building an entire list before >>> it returns the argument for you to call lastOrNil. This is where you >>> had unexpected memory behavior. >>> >>> Now you are "fusing" lastOrNil and mapM together, and instead of >>> building a list, you traverse it and perform monadic action along the >>> way. This can happen in a constant memory if the original pure list is >>> generated lazily. >>> >>> I think the real problem you had was a mis-understanding of mapM, and >>> there was nothing wrong with your previous lastOrNil function. mapM >>> will only return a list after all monadic actions are performed, and >>> in doing so, it inevitably has to build the entire list along the way. >>> >>> -- >>> Regards, >>> Paul Liu >>> >>> Yale Haskell Group >>> http://www.haskell.org/yale >> >> Hi, Paul, thanks for the comments. You're quite right that I am fusing >> the two functions together, but I think I wasn't mis-understanding >> mapM... I knew I was generating the entire list, and aside from the >> slight inefficiency of generating it only to tear it down an instant >> later, that would have been no problem. But I was expecting all of the >> memory associated with the list to be reclaimed after I had processed >> it, and that was what was not happening as far as I could tell. (This >> isn't one monolithic list, by the way; it's the small bodies of a >> couple of small scheme functions that get evaluated over and over. So >> the setup and teardown happens a lot.) I don't have very good >> intuition yet about what should get garbage-collected and what should >> get kept in such situations, and in fact I'm kind of in the same boat >> again: the test case now runs much better, but it still leaks memory, >> and I am again stumped as to why. Could I see something useful by >> examining ghc core? I haven't looked at that yet, no idea what to look >> for... >> >> Uwe >> _______________________________________________ > > mapM_ might be useful to you. I know there are cases where mapM leaks > memory but mapM_ doesn't, basically because mapM_ throws away all of > the intermediate results immediately. You might want to condition on > nullness of the list and then mapM_ your function over the init of the > list and then just return the function on the last element of the > list. > > Alex Oh, sorry, I was not clear in my original note in this thread: the lastOrNil issue seems to be solved. That part of the code is, as far as I can tell, not leaking memory at all anymore. I think I can claim that because now the constant memory allocation is showing up visibly in the profiling output; before, it was lost in the noise. So, if there is a leak there, it's tiny compared with the constant stuff at least for this benchmark. There are still two or perhaps three leaks, and these show up as large but not huge compared to the constant stuff. I've got a plot of this up on the haskeem website: http://www.korgwal.com/haskeem/run_new.png. The bits where I am stumped now are two-fold: one is (I think) analogous to the lastOrNil issue, except that instead of feeding the result to lastOrNil, I am doing a more general fold. So there I do need all the results. I tried the same fusion as with lastOrNil/mapML, and as far as I can tell I'm not building any lists; but this time it didn't change the behavior at all, other than causing the names of some profiling cost centers to change. This is the #2 entry on the plot above. The other issue seems to have something to do with IORefs, I'm dynamically building environments for my scheme functions, and somehow there seems to be something going wrong with reclaiming that memory after it's done. This is the #1 and I think #3 entry on the plot. I don't know enough details there yet to be able to say any more. Uwe From newhoggy at gmail.com Sun Jul 5 23:35:44 2009 From: newhoggy at gmail.com (John Ky) Date: Sun Jul 5 23:18:03 2009 Subject: [Haskell-cafe] How to pretty print code efficiently In-Reply-To: References: <57526e770907032013v3eed0a9cl626624bd6abf026f@mail.gmail.com> Message-ID: Hi all, Thanks everyone for the help. The HughesPJ module works well for me. Cheers, -John On Mon, Jul 6, 2009 at 3:49 AM, Chris Eidhof wrote: > On 4 jul 2009, at 05:13, Alexander Dunlap wrote: > > On Fri, Jul 3, 2009 at 6:45 PM, John Ky wrote: >> >>> Hi, >>> >>> Currently I'm pretty printing code by building arrays of strings and >>> calling >>> indent. For example: >>> >>> instance JavaPrintableNamed AST.EnumeratedType where >>> javaLinesNamed parentName (AST.EnumeratedType memberDefinitions) = >>> [ "public enum " ++ asJavaId(parentName) >>> , "{" >>> ] ++ memberCodeLines ++ >>> [ "}" >>> , "" >>> ] >>> where >>> memberCodeLines = indent $ javaLines memberDefinitions >>> >>> The indent function takes a list of strings and adds an indent to the >>> beginning of every line. >>> >>> I can imagine this to be very inefficient as it builds many strings and >>> concatenates them. >>> >>> In Ruby, I might do the same thing like this: >>> >>> class EnumeratedType < JavaPrintableNamed >>> def writeTo(writer) >>> writer.print "public enum " >>> writer.puts self.asJavaId >>> writer.puts "{" >>> writer.indent do >>> self.memberDefinitions.writeTo(writer) >>> writer.puts >>> end >>> >>> where above, the writer.indent takes care of the indent, and everything >>> is >>> appended to a stream, which doesn't seem so bad in terms of efficiency. >>> >>> I'm looking for a way to do something similar in Haskell. >>> >>> Anyone can give me a hand? >>> >>> Thanks >>> >>> -John >>> >>> >>> _______________________________________________ >>> >> >> You may want to investigate the standard module >> Text.PrettyPrint.HughesPJ, which contains a number of (I assume fairly >> efficient) combinators for pretty printing. >> > > I second that. Also, there is uulib which has a pretty printing module > that's quite similar: > > > http://hackage.haskell.org/packages/archive/uulib/0.9.10/doc/html/UU-PPrint.html > > I think both packages are based on the paper "The Design of a > Pretty-printing Library" which can be found at > http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps > > Not only do they provide abstractions for things like indentation, > concatenation in different forms, etc., but they also are more efficient > than a naive implementation using lists. > > -chris > > -chris > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090705/a395386a/attachment.html From ml at isaac.cedarswampstudios.org Sun Jul 5 23:45:31 2009 From: ml at isaac.cedarswampstudios.org (Isaac Dupree) Date: Sun Jul 5 23:27:55 2009 Subject: [Haskell-cafe] Documentation design Message-ID: <4A51735B.8040901@isaac.cedarswampstudios.org> (for reference, here's the blog-post I wrote that inspired me to ask this list for advice. I'll explain everything in this email anyway though. http://haddock2009.wordpress.com/2009/06/23/how-to-navigate-your-code/ ) My challenge: getting to know an existing code-base quickly and easily, so that I can hack on it. Haddock and HsColour are already pretty helpful at this, but they could be more helpful. (haddock with --ignore-all-exports, i.e. cabal haddock --internal, especially) My dream situation: both haddock-pages and hscolour-pages would be super-hyperlinked and super-readable. For example, haddock would list all a module's definitions, not just its exports. In HsColoured source, every identifier would link to its definition or the haddockumentation of its definition. and so forth. It would be so much easier to generate and browse this in HTML, than to get an IDE working, and it would be so much more readable than a mere text-editor (even with syntax hilighting) and quicker clicking on hyperlinks than grepping for everything. Actually I don't have the resources to worry about designing any HsColour stuff right now (its current design is mainly just a lexeme highlighter). But, with your advices, I can design an improvement on Haddock's ignore-exports mode, which currently has a few shortcomings: 1. you can't tell which identifiers in a module are exported 2. it doesn't document a module's re-exports at all 3. it still obeys {-# OPTIONS_HADDOCK hide #-} et al, even when they're not appropriate for reading documentation of internals 4. 2+3 means that some things may be found nowhere in the documentation at all! Not quite satisfying for something invoked by `cabal haddock --internal`. (Here's a haddock-generated page you can look at so you can figure out the formatting-details I'll be describing: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html and its source code http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/Data-List.html ) The ideal haddockumentation-formatting for this purpose isn't quite obvious though. For example, sometimes you want to think about a module in terms of its abstract interface, but sometimes you want to figure out how it's implemented (without reverting completely to text based code browsing). Maybe a compromise of some sort would be good. so... Here's a proposal, for a new mode (`haddock --all-internal`?, to be invoked by `cabal haddock --internal` rather than --internal's current effect of ignore-all-exports) : Files with no explicit export list can be treated as-is anyway. For all files that have an explicit export list, generate the synopsis-of-exports near the top, as usual. But have the index link, generally, to where functions are originally defined (modulo being from a non-internally-documented separate package, where it should link to the appropriate place), and have the fuller documentation below be a compilation of the identifiers *defined* in this module. Actually that would need some revision because the sections and subsections -- *, -- **, etc. defined in the export-list in the .hs, actually are displayed 1. above the table of contents, linking to places in 2. the full list of definitions. Which might be defined in the module in a different order than they're listed in the export list. Why not add the sections into the synopsis? In this case, instead of adding them to the main doc section. But hmm... in ordinary non-internal documentation, would it be nice to *additionally* have the sections marked in the synopsis (in addition to in the Contents and in the main docs section)? Maybe this mode should also abstain from "hiding" any module, because that would cause missing docs. Etc. Questions? Comments? Opinions? Does anyone want this feature, and/or not think it's particularly useful? -Isaac From felipe.lessa at gmail.com Mon Jul 6 00:10:32 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Jul 5 23:52:56 2009 Subject: [Haskell-cafe] Documentation design In-Reply-To: <4A51735B.8040901@isaac.cedarswampstudios.org> References: <4A51735B.8040901@isaac.cedarswampstudios.org> Message-ID: <20090706041032.GA26246@kira.casa> I would also like some sort of "combo" mode for Hackage where the docs are shown the same way that they are now but with a link to "Internals" showing the view that you propose, perhaps showing only internals or highlighting them. Then we would be able to have the internal documentation on Hackage without polluting the most used exported docs. If you anybody doesn't like having to go on "Internals" they may 'cabal fetch' at will. -- Felipe. From patai_gergely at fastmail.fm Mon Jul 6 02:30:03 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Mon Jul 6 02:12:23 2009 Subject: [Haskell-cafe] ANN: bloxorz clone In-Reply-To: <20090705212712.GB10538@whirlpool.galois.com> References: <1246652524.9181.1323418579@webmail.messagingengine.com> <20090705212712.GB10538@whirlpool.galois.com> Message-ID: <1246861803.9664.1323645631@webmail.messagingengine.com> > Here's a video of bloxorz at work, very cool! > > http://archhaskell.wordpress.com/2009/07/04/bloxorz-an-opengl-logic-game-written-in-haskell/ I see it wasn't rehearsed in advance. ;) Gergely -- http://www.fastmail.fm - The professional email service From bugfact at gmail.com Mon Jul 6 06:40:31 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Jul 6 06:22:50 2009 Subject: [Haskell-cafe] Haskell Platform 2009.2.0.1 and GLUT32.DLL on Windows: which version? Message-ID: I know GLUT32.DLL is not bundled with the Haskell Platform installer, but which GLUT32.DLL should I use? Every DLL I tried (even building FreeGLUT myself) gives the error: *"The procedure entry point glutAddMenuEntry could not be located in the dynamic library glut32.dll"* Any hints as to which glut32 version to use would be highly appreciated. Thanks, Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090706/03c6cc66/attachment.html From phercek at gmail.com Mon Jul 6 07:28:59 2009 From: phercek at gmail.com (Peter Hercek) Date: Mon Jul 6 07:11:32 2009 Subject: [Haskell-cafe] Re: Documentation design References: <4A51735B.8040901@isaac.cedarswampstudios.org> Message-ID: I like your proposal. Few notes below. On Sun, 05 Jul 2009 23:45:31 -0400, Isaac Dupree wrote: > My dream situation: both haddock-pages and hscolour-pages would be > super-hyperlinked and super-readable. For example, haddock would list > all a module's definitions, not just its exports. In HsColoured source, > every identifier would link to its definition or the haddockumentation > of its definition. and so forth. It would be so much easier to generate > and browse this in HTML, than to get an IDE working, and it would be so > much more readable than a mere text-editor (even with syntax hilighting) > and quicker clicking on hyperlinks than grepping for everything. You do not need to resort to grep for navigation of your source code from your text editor. At least not with vim. It has tags and stack of tags. Generate tags for your source code and use Ctrl-] to navigate to the definition (or Ctrl-W} to open the definition in preview window). Any jump to definition done with Ctrl-] is stored in the stack of tags. You can return to the previous position in the stack with Ctrl-T or return to the last next position with :tag. You can check how the tag stack looks like with :tags. This way you can navigate the stack of tags comfortably and the stack of tags can correspond to the lexical (creation) stack as it would exist during execution. The only problem with this is that it works so nicely only for me currently since I have a patch applied to ghci which makes ghci to include also the non-exported symbols to the tags file. I would like to add the patch to ghci but so far there is only small support for it. If you (or anybody else) would like it drop me a note or comment on the glasgow haskell users list: http://www.haskell.org/pipermail/glasgow-haskell-users/2009- June/017399.html The :ctags improvement patch gives you a substitute for intellisense in vim. I have ":inoremap ^] ^[^W}a" in .vimrc so when I start to type a function name I can finish it with some completion, and (while still being in the insert mode) I can get help for it to the preview window with Ctrl-]. > The ideal haddockumentation-formatting for this purpose isn't quite > obvious though. For example, sometimes you want to think about a module > in terms of its abstract interface, but sometimes you want to figure out > how it's implemented (without reverting completely to text based code > browsing). Maybe a compromise of some sort would be good. so... > > Here's a proposal, for a new mode (`haddock --all-internal`?, to be > invoked by `cabal haddock --internal` rather than --internal's current > effect of ignore-all-exports) : > > Files with no explicit export list can be treated as-is anyway. > > For all files that have an explicit export list, generate the > synopsis-of-exports near the top, as usual. But have the index link, > generally, to where functions are originally defined (modulo being from > a non-internally-documented separate package, where it should link to > the appropriate place), and have the fuller documentation below be a > compilation of the identifiers *defined* in this module. I like it but some notes to the new synopsis part: You mean the index link for a symbol should go to the haddock help page not to the HsColour source page. Right? I would like some annotations aligned to the right which would indicate whether the symbol is defined locally or it is reexported. There should be also an annotation or different font to indicate whether the symbol in synopsis is exported or not (in addition to nonexported symbols being is a separate section). This is so that one can easily see what part of the help is shown. > Actually that would need some revision because the sections and > subsections -- *, -- **, etc. defined in the export-list in the .hs, > actually are displayed > 1. above the table of contents, linking to places in 2. the full list of > definitions. Which might be defined in the module in a different order > than they're listed in the export list. Why not add the sections into > the synopsis? In this case, instead of adding them to the main doc > section. But hmm... in ordinary non-internal documentation, would it be > nice to *additionally* have the sections marked in the synopsis (in > addition to in the Contents and in the main docs section)? Not sure I understand this part well. I assume by main document part you mean the part with detailed description and source code links. I want the contents preserved with the added last section with name "Nonexported symbols", or something named like that. Adding the section names to synopsis seems like good idea to me. In such a case it could be removed from the main doc part but I would rather keep it there. But I do not really mind either way. I assume the main doc part would contain only the symbols defined in the given module (not the re-exported ones). But the synopsis part would contain the names of re-exported symbols with links to the appropriate location in the main doc part of the module where the symbol is really defined. Also the main doc part would contain one more section "Nonexported symbols" with help for the symbols defined in the module but not exported. I would also like "back-links": clicking on the bold symbol name (which currently does not have any hyperlink) in the main doc part would open a pop up list box with all the symbols using/calling it within the project. Selecting an item from the pop up list box would navigate to the main doc part where the caller symbol is described. Peter. From moonlite at dtek.chalmers.se Mon Jul 6 08:37:24 2009 From: moonlite at dtek.chalmers.se (Mattias Bengtsson) Date: Mon Jul 6 08:19:43 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <4A510D65.3030106@henning-thielemann.de> References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> <4ec472cb0907010811v434ac162x41748edd7d3a084@mail.gmail.com> <4A510D65.3030106@henning-thielemann.de> Message-ID: <1246883844.5850.10.camel@moonlite> On Sun, 2009-07-05 at 22:30 +0200, Henning Thielemann wrote: > > (?) is also undefined in Prelude. Which i think is a good thing. I think it's quite nice to use (?) as an operator in higher order functions. Eg. foldr _ z [] = z foldr (?) z (x:xs) = x ? foldr (?) z xs From ketil at malde.org Mon Jul 6 08:59:48 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Jul 6 08:41:59 2009 Subject: [Haskell-cafe] Monoid wants a (++) equivalent In-Reply-To: <1246883844.5850.10.camel@moonlite> (Mattias Bengtsson's message of "Mon\, 06 Jul 2009 14\:37\:24 +0200") References: <20090630185438.GA17768@seas.upenn.edu> <20090630223938.GI22067@sliver.repetae.net> <20090701013126.GK22067@sliver.repetae.net> <20090701000050.onv8vijwo40o4c04-nwo@webmail.spamcop.net> <20090701125626.GA8372@seas.upenn.edu> <7fb8f82f0907010746n31ba3518u67995742638cb9d4@mail.gmail.com> <4ec472cb0907010811v434ac162x41748edd7d3a084@mail.gmail.com> <4A510D65.3030106@henning-thielemann.de> <1246883844.5850.10.camel@moonlite> Message-ID: <878wj20xx7.fsf@malde.org> Mattias Bengtsson writes: >> (?) is also undefined in Prelude. > Which i think is a good thing. > I think it's quite nice to use (?) as an operator in higher order > functions. Also, it clashes with the implicit parameters extension, and combining the extension with a user-defined (?) operator resulted in (?) having a whitespace-dependent meaning, IIRC. This is perhaps not so crucial anymore, in the time since I stumbled into this -fglasgow-exts has largely been replaced by more fine-grained mechanisms, and implicit parameters has become less fashionable. -k -- If I haven't seen further, it is by standing in the footprints of giants From the.dead.shall.rise at gmail.com Mon Jul 6 11:11:50 2009 From: the.dead.shall.rise at gmail.com (Mikhail Glushenkov) Date: Mon Jul 6 10:54:30 2009 Subject: [Haskell-cafe] Re: Haskell Platform 2009.2.0.1 and GLUT32.DLL on Windows: which version? References: Message-ID: Hi Peter, Peter Verswyvelen gmail.com> writes: > I know GLUT32.DLL is not bundled with the Haskell Platform > installer, but which GLUT32.DLL should I use? I compiled a basic example [1] successfully using the DLL downloaded from [2]. But since that's the first hit in Google, you've probably already tried it. Did you put the DLL where GHC can find it? Use $WINDIR\System32 or $WINDIR\SysWOW64 if you're on 64 bit. [1] http://netsuperbrain.com/blog/wp-content/uploads/2008/11/teapots.hs [2] http://www.xmission.com/~nate/glut.html From dvde at gmx.net Mon Jul 6 11:51:34 2009 From: dvde at gmx.net (Daniel van den Eijkel) Date: Mon Jul 6 11:33:55 2009 Subject: [Haskell-cafe] ANN: bloxorz clone In-Reply-To: <1246652524.9181.1323418579@webmail.messagingengine.com> References: <1246652524.9181.1323418579@webmail.messagingengine.com> Message-ID: <4A521D86.4040504@gmx.net> Very nice! Just to give feedback: It installs and works perfectly on windows. kind regards, daniel Patai Gergely schrieb: > Hello all, > > This post is not about my own creation, it's just a little fun program > written by a student of mine. You can install the bloxorz package to try > it out, and read more about its background on my blog: > > http://just-bottom.blogspot.com/2009/07/playing-and-learning.html > > Gergely > > From tphyahoo at gmail.com Mon Jul 6 12:54:54 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Jul 6 12:37:12 2009 Subject: [Haskell-cafe] simple state monad exercises? (besides labeling trees) Message-ID: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> Can someone give some simple common scenarios where the state monad is useful, besides labeling trees? References to puzzles like those in project Euler or similar would be nice. Thanks! From dons at galois.com Mon Jul 6 13:07:24 2009 From: dons at galois.com (Don Stewart) Date: Mon Jul 6 12:51:45 2009 Subject: [Haskell-cafe] ANN: bloxorz clone In-Reply-To: <1246861803.9664.1323645631@webmail.messagingengine.com> References: <1246652524.9181.1323418579@webmail.messagingengine.com> <20090705212712.GB10538@whirlpool.galois.com> <1246861803.9664.1323645631@webmail.messagingengine.com> Message-ID: <20090706170724.GC14155@whirlpool.galois.com> patai_gergely: > > Here's a video of bloxorz at work, very cool! > > > > http://archhaskell.wordpress.com/2009/07/04/bloxorz-an-opengl-logic-game-written-in-haskell/ > I see it wasn't rehearsed in advance. ;) Will the darcs (or.. ) repository for the code be made public? I'm sure there are people in the community who'd like to contribute new levels, etc. -- Don From bugfact at gmail.com Mon Jul 6 13:13:08 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Jul 6 12:55:29 2009 Subject: [Haskell-cafe] Re: Haskell Platform 2009.2.0.1 and GLUT32.DLL on Windows: which version? In-Reply-To: References: Message-ID: Okay, thanks for this feedback. I tried [2] but that failed. Since it works on your system I'll double check again tomorrow, it must be picking an incorrect GLUT32.dll I guess On Mon, Jul 6, 2009 at 5:11 PM, Mikhail Glushenkov < the.dead.shall.rise@gmail.com> wrote: > Hi Peter, > > Peter Verswyvelen gmail.com> writes: > > > I know GLUT32.DLL is not bundled with the Haskell Platform > > installer, but which GLUT32.DLL should I use? > > I compiled a basic example [1] successfully using the DLL > downloaded from [2]. But since that's the first hit in Google, > you've probably already tried it. > > Did you put the DLL where GHC can find it? Use $WINDIR\System32 > or $WINDIR\SysWOW64 if you're on 64 bit. > > [1] http://netsuperbrain.com/blog/wp-content/uploads/2008/11/teapots.hs > [2] http://www.xmission.com/~nate/glut.html > > _______________________________________________ > 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/20090706/a3e90849/attachment.html From ttencate at gmail.com Mon Jul 6 13:17:28 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Mon Jul 6 12:59:46 2009 Subject: [Haskell-cafe] simple state monad exercises? (besides labeling trees) In-Reply-To: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> References: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> Message-ID: I used the State monad to implement a Brainfuck [1] interpreter a few months ago. It stored the program counter, pointer and the memory of the machine. There might have been a different (better?) way, but as I was trying to learn more about monads, it was an obvious choice. Thomas [1] http://www.muppetlabs.com/~breadbox/bf/ On Mon, Jul 6, 2009 at 18:54, Thomas Hartman wrote: > Can someone give some simple common scenarios where the state monad is > useful, besides labeling trees? > > References to puzzles like those in project Euler or similar would be nice. > > Thanks! > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From patai_gergely at fastmail.fm Mon Jul 6 14:06:19 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Mon Jul 6 13:48:35 2009 Subject: [Haskell-cafe] ANN: bloxorz clone In-Reply-To: <20090706170724.GC14155@whirlpool.galois.com> References: <1246652524.9181.1323418579@webmail.messagingengine.com> <20090705212712.GB10538@whirlpool.galois.com> <1246861803.9664.1323645631@webmail.messagingengine.com> <20090706170724.GC14155@whirlpool.galois.com> Message-ID: <1246903579.2110.1323743741@webmail.messagingengine.com> > Will the darcs (or.. ) repository for the code be made public? > I'm sure there are people in the community who'd like to contribute new > levels, etc. I don't think there is a repository at all, and I'm not even sure if Viktor wants to maintain it. I'll ask and direct him to the list. Gergely -- http://www.fastmail.fm - Or how I learned to stop worrying and love email again From matthias.goergens at googlemail.com Mon Jul 6 14:31:52 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 6 14:14:14 2009 Subject: [Haskell-cafe] simple state monad exercises? (besides labeling trees) In-Reply-To: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> References: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> Message-ID: > Can someone give some simple common scenarios where the state monad is > useful, besides labeling trees? Emulating the VM given in this years ICFP programming contest was also a good application of the state monad. Of course you interprate much simpler language imperative languages, too. (However that might feel a bit forced as an exercise.) From deb at pudlak.name Mon Jul 6 15:26:38 2009 From: deb at pudlak.name (Petr Pudlak) Date: Mon Jul 6 15:08:56 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm Message-ID: <20090706192637.GA19982@pudlak.name> Hi all, about a month ago, we were discussing sorting in Haskell with a friend. We realized a nice property of lazy merge-sort (which is AFAIK the implementation of Data.List.sort): Getting the first element of the sorted list actually requires O(n) time, not O(n * log n) as in imperative languages. And immediately we asked: Would it be possible to create a lazy selection/sorting algorithm so that getting any element of the sorted list/array by its index would require just O(n) time, and getting all the elements would still be in O(n * log n)? More precisely: The result of sorting an n-element list or array should be a structure that allows to ask i-th element of the result (for example, a lazy array). Asking k arbitrary elements should take no more than O(min(n * log n, k * n)) I believe that this could be done, but so far I wasn't able to implement and show it myself. I think the solution would be somewhat modified lazy quicksort (or "Median of Medians algorithm" if we want to be sure that we get good pivots). Perhaps somebody else would also like to give it a try? Or perhaps explain me why it's not possible? Best regards, Petr From matthias.goergens at googlemail.com Mon Jul 6 16:17:10 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 6 15:59:29 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: <20090706192637.GA19982@pudlak.name> References: <20090706192637.GA19982@pudlak.name> Message-ID: Interesting problem. I have been toying with the same problem for some time. To solve the problem in theory, I'd concentrate on getting the number of comparisons into the required O(n) resp. O(n log n) ranges. Afterwards we can think about building the infrastructure to keep the number of all operations (book keeping..) in those bounds, too. Anyway, I'll give a solution to the problem using a randomized quicksort, soon. Later we can replace the randomized pivote-picking with a deteministic linear-median algorithm. From RafaelGCPP.Linux at gmail.com Mon Jul 6 16:34:40 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Mon Jul 6 16:16:57 2009 Subject: [Haskell-cafe] Haskell Platform on Ubuntu Message-ID: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> Is there anyone working on a Haskell Platform package for Ubuntu? GHC in Ubuntu is a pain! Regards Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090706/65c99b90/attachment.html From andrewhhunter at gmail.com Mon Jul 6 16:42:02 2009 From: andrewhhunter at gmail.com (Andrew Hunter) Date: Mon Jul 6 16:24:20 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: <20090706192637.GA19982@pudlak.name> References: <20090706192637.GA19982@pudlak.name> Message-ID: <2a774a0c0907061342j312b33b5o26f7c95897a1bbd1@mail.gmail.com> On Mon, Jul 6, 2009 at 12:26 PM, Petr Pudlak wrote: > More precisely: The result of sorting an n-element list or array should be a > structure that allows to ask i-th element of the result (for example, a lazy > array). Asking k arbitrary elements should take no more than > ?O(min(n * log n, k * n)) > I'd argue this is not really a true use of "laziness" and more just amortized cost. That said, yes, it can be done! I'm going to use an imperative data structure because I hate you all and it makes the analysis/presentation slightly easier. To wit, we have a sorted array of unsorted bags of inputs. For example, (suppose we start with an array of numbers 1..10, scrambled), we might start with: (10,{1,5,6,8,3,4,2,7,9,10}) And after some operations, it might look like: (3,{1,3,2});(4,{6,7,5,4});(3:{8,9,10}) And we're trying to (eventually) hit the state: (1,{1});(2,{2});...etc. (It's not hard to see how to in constant time maintain an array of pointers into these bags to allow finding elements.) Now, using a linear-time selection algorithm like median-of-medians or Chazelle's, it's easy to see how to find the k-th largest element in such a data structure: find the bag containing the k-th element, apply the selection algorithm. Furthermore, still in linear time, we can (while we're working) split the bag around that element we found. So, given the data state: (10,{1,5,6,8,3,4,2,7,9,10}) if we're asked for the 4th largest element, we'll update to: (3,{1,3,2});(1,{4});(6,{5,6,8,7,9,10}) So far so good, right? Now we just apply one more change: after each lookup, we walk across the list of bags, and split each in half (as if we were asked for the median element of each bag.) In my running example, we'd go to: (1,{1});{1,{2});(1,{3});(1,{4});(2,{5,6});(1,{7});(3,{8,9,10}) This is still linear time--we run a linear-time algorithm on disjoint subsets of the input. Now, note: after k lookups to this structure, the largest bag is at most n/2^k elements long! Couple with a slight optimization that overwrites the lookup table into the bags with just the correct results once the bags are small enough, and this matches your time bounds quite nicely. Now, I doubt it'll be fast, but that's not what you asked. Plus, come up with a persuasive use case for a system where you /really need/ the 4th, 27th, and 957th largest elements /now/ and none of the rest, and I promise I'll make something practically efficient. :) If someone can translate my algorithm into a non-side-effecting one, I'd appreciate it, but I think that like disjoint set/union, this is probably inherently side-effecting. Yes, yes, we could use functional arrays, but short of that I don't see a way to avoid side effects to take care of my amortized work. AHH From matthias.goergens at googlemail.com Mon Jul 6 17:03:42 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 6 16:46:00 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: <2a774a0c0907061342j312b33b5o26f7c95897a1bbd1@mail.gmail.com> References: <20090706192637.GA19982@pudlak.name> <2a774a0c0907061342j312b33b5o26f7c95897a1bbd1@mail.gmail.com> Message-ID: > If someone can translate my algorithm into a non-side-effecting one, > I'd appreciate it, but I think that like disjoint set/union, this is > probably inherently side-effecting. ?Yes, yes, we could use functional > arrays, but short of that I don't see a way to avoid side effects to > take care of my amortized work. I am just working on a side-effect-free version. From mads_lindstroem at yahoo.dk Mon Jul 6 17:50:27 2009 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Mon Jul 6 17:39:25 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: <20090706192637.GA19982@pudlak.name> References: <20090706192637.GA19982@pudlak.name> Message-ID: <1246917027.4335.19.camel@supermule.opasia.dk> Hi Petr, Maybe this will give inspiration http://en.wikipedia.org/wiki/Selection_algorithm It seems to me, that you just need a selection algorithm which works in O(n * k) time for k arbitrary elements. If you combine O(n*k) selection algorithm with any O(n * lg n) sort, you furfil your time constrain. Regards, Mads > Hi all, > > about a month ago, we were discussing sorting in Haskell with a friend. We > realized a nice property of lazy merge-sort (which is AFAIK the implementation > of Data.List.sort): Getting the first element of the sorted list actually > requires O(n) time, not O(n * log n) as in imperative languages. And > immediately we asked: Would it be possible to create a lazy selection/sorting > algorithm so that getting any element of the sorted list/array by its index > would require just O(n) time, and getting all the elements would still be in > O(n * log n)? > > More precisely: The result of sorting an n-element list or array should be a > structure that allows to ask i-th element of the result (for example, a lazy > array). Asking k arbitrary elements should take no more than > O(min(n * log n, k * n)) > > I believe that this could be done, but so far I wasn't able to implement and > show it myself. I think the solution would be somewhat modified lazy quicksort > (or "Median of Medians algorithm" if we want to be sure that we get good > pivots). > > Perhaps somebody else would also like to give it a try? Or perhaps explain me > why it's not possible? > > Best regards, > Petr > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090706/ef7756ef/attachment.bin From dons at galois.com Mon Jul 6 18:13:13 2009 From: dons at galois.com (Don Stewart) Date: Mon Jul 6 17:57:33 2009 Subject: [Haskell-cafe] Haskell Platform on Ubuntu In-Reply-To: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> Message-ID: <20090706221313.GU14155@whirlpool.galois.com> RafaelGCPP.Linux: > > Is there anyone working on a Haskell Platform package for Ubuntu? > > GHC in Ubuntu is a pain! The Debian team is working on packaging, but until then (or if someone on Ubuntu steps up), you'll need to use the Unix tarball: http://hackage.haskell.org/platform/2009.2.0.1/haskell-platform-2009.2.0.1.tar.gz -- Don From mle+hs at mega-nerd.com Mon Jul 6 18:23:57 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Mon Jul 6 18:06:22 2009 Subject: [Haskell-cafe] Haskell Platform on Ubuntu In-Reply-To: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> Message-ID: <20090707082357.e5a2c57a.mle+hs@mega-nerd.com> Rafael Gustavo da Cunha Pereira Pinto wrote: > Is there anyone working on a Haskell Platform package for Ubuntu? For Haskell on Ubuntu, the vast majority of all the work is done by the Debian Haskell maintainers. Ubuntu simply takes that work and rolls packages for Ubuntu. > GHC in Ubuntu is a pain! The same is also currently true for GHC on Debian stable and testing. Debian unstable is also a bit broken. However, if you know a bit about build Debian packages the Debian way then it is possible to use the Debian unstable sources on Ubuntu 8.04 and later. I've been meaning to blog this for some time :-). Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From RafaelGCPP.Linux at gmail.com Mon Jul 6 18:37:04 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Mon Jul 6 18:19:24 2009 Subject: [Haskell-cafe] Haskell Platform on Ubuntu In-Reply-To: <20090706221313.GU14155@whirlpool.galois.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> Message-ID: <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> Thanks. I may even be the one to step up, if nothing happens till 9.10... I really miss up-to-date ghc in Ubuntu. 2009/7/6 Don Stewart > RafaelGCPP.Linux: > > > > Is there anyone working on a Haskell Platform package for Ubuntu? > > > > GHC in Ubuntu is a pain! > > The Debian team is working on packaging, but until then (or if someone > on Ubuntu steps up), you'll need to use the Unix tarball: > > > http://hackage.haskell.org/platform/2009.2.0.1/haskell-platform-2009.2.0.1.tar.gz > > -- Don > -- 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/20090706/660214af/attachment.html From someone561 at gmx.de Mon Jul 6 18:54:01 2009 From: someone561 at gmx.de (Stefan Roggensack) Date: Mon Jul 6 18:36:19 2009 Subject: [Haskell-cafe] Haskell Platform on Ubuntu In-Reply-To: <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> Message-ID: <4A528089.1070903@gmx.de> Hello, I have uploaded the ghc package to my ppa: https://launchpad.net/~someone561/+archive/ppa But I don't work on it. I simple backport the debian sid packages. Also there are not the haskell libraries as debs. Maybe this helps you. Stefan Rafael Gustavo da Cunha Pereira Pinto wrote: > Thanks. I may even be the one to step up, if nothing happens till > 9.10... I really miss up-to-date ghc in Ubuntu. > > > > 2009/7/6 Don Stewart > > > RafaelGCPP.Linux: > > > > Is there anyone working on a Haskell Platform package for Ubuntu? > > > > GHC in Ubuntu is a pain! > > The Debian team is working on packaging, but until then (or if someone > on Ubuntu steps up), you'll need to use the Unix tarball: > > > http://hackage.haskell.org/platform/2009.2.0.1/haskell-platform-2009.2.0.1.tar.gz > > -- Don > > > From gue.schmidt at web.de Mon Jul 6 19:23:19 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Jul 6 19:05:48 2009 Subject: [Haskell-cafe] LINQ, SQL and hs-dotnet Message-ID: Hi all, is there anyone who has already tried using LINQ2SQL with hs-dotnet and would care to share the experience? I'm trying to figure out what exactly it would take to access an SQL database via LINQ / hs-dotnet. Ie. whether or not it's necessary to create Entity classes, or if one can just use LINQ to generate SQL. G?nther From matthias.goergens at googlemail.com Mon Jul 6 19:32:13 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 6 19:14:30 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: <1246917027.4335.19.camel@supermule.opasia.dk> References: <20090706192637.GA19982@pudlak.name> <1246917027.4335.19.camel@supermule.opasia.dk> Message-ID: > It seems to me, that you just need a selection algorithm which works in > O(n * k) time for k arbitrary elements. If you combine O(n*k) selection > algorithm with any O(n * lg n) sort, you furfil your time constrain. I guess, we also want the list to be sorted in O(1) after having selected every element. Matthias. From lanny at cisco.com Mon Jul 6 19:42:08 2009 From: lanny at cisco.com (Lanny Ripple) Date: Mon Jul 6 19:24:28 2009 Subject: [Haskell-cafe] simple state monad exercises? (besides labeling trees) In-Reply-To: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> References: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> Message-ID: <4A528BD0.8010704@cisco.com> Off the top of my head state is important when getting from A to B depends on the path you took. As such a common scenario I find myself in all the time is not having a good CLI craps game. (And which I resolve by rewriting in every language I learn.) Stake, current bet, bets outstanding, point. Lots of state. Also user interaction, varying output, error conditions, etc. depending on how complex you want. A much simpler problem is to model some large number of throws using different play strategies. Removes all the icky user interaction. Alternately you can just abuse toy problems. import Control.Monad.State fac n = execState (facs n) 1 facs n = do y <- get if n == 0 then return y else do put (y*n) facs (n-1) Enjoy, -ljr Thomas Hartman wrote: > Can someone give some simple common scenarios where the state monad is > useful, besides labeling trees? > > References to puzzles like those in project Euler or similar would be nice. > > Thanks! > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From andrewhhunter at gmail.com Mon Jul 6 19:42:33 2009 From: andrewhhunter at gmail.com (Andrew Hunter) Date: Mon Jul 6 19:24:50 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> <1246917027.4335.19.camel@supermule.opasia.dk> Message-ID: <2a774a0c0907061642m139b75aep7ee835dfc3f08b06@mail.gmail.com> On Mon, Jul 6, 2009 at 4:32 PM, Matthias G?rgens wrote: >> It seems to me, that you just need a selection algorithm which works in >> O(n * k) time for k arbitrary elements. If you combine O(n*k) selection >> algorithm with any O(n * lg n) sort, you furfil your time constrain. > > I guess, we also want the list to be sorted in O(1) after having > selected every element. > I think he's suggesting something along the lines of: for the first \log n requests, use a selection. On the \log n + 1th request, just sort the whole thing. This obviously isn't the spirit of what's wanted, but does in fact meet the time bounds. AHH From phil at beadling.co.uk Mon Jul 6 20:37:05 2009 From: phil at beadling.co.uk (phil@beadling.co.uk) Date: Mon Jul 6 20:19:26 2009 Subject: [Haskell-cafe] Catering for similar operations with and without state In-Reply-To: References: <89bc5e540906151723g1dadc094ledb3e3ad3123e387@mail.gmail.com> Message-ID: Well, the simplest solution I can think of is below. The OtherNormalStateT doesn't actually have any state at all, but still gets state from the StateT 'below' it and returns a result. This is still a bit ugly, but it compiles - and although I haven't tested it properly yet, simply implementing the 'other' helper function to do the work should be fine. It's a question of how smart the compiler is. Obviously this is inefficient in theory, but will the compiler notice we are passing around a 'unit' state and that the s -> (a,s) function doesn't care about the input.... perhaps. I'd expect the overhead from this to be fairly small and it does allow me to continue using the same paradigm for stateless versions of my normal generator. I have seen people do similar things when they wish to carry around state but have no result, and thus the result is set to (). I can't see why this is any less inefficient than that? type BoxMullerStateT = StateT (Maybe Double) type BoxMullerRandomStateStack = BoxMullerStateT MyRngState instance NormalClass BoxMullerRandomStateStack where generateNormal = StateT $ \s -> case s of Just d -> return (d,Nothing) Nothing -> do qrnBaseList <- nextRand let (norm1,norm2) = boxMuller (head qrnBaseList) (head $ tail qrnBaseList) return (norm1,Just norm2) -- New stateless StateT below! type OtherNormalStateT = StateT () type OtherRandomStateStack = OtherNormalStateT MyRngState instance NormalClass OtherRandomStateStack where generateNormal = StateT $ \_ -> do rn:rns <- nextRand return ( other rn, () ) On 17 Jun 2009, at 07:38, Jason Dagit wrote: > Hi Phil, > > On Mon, Jun 15, 2009 at 5:23 PM, Phil wrote: > Hi, > > I'm trying to think around a problem which is causing me some > difficulty in Haskell. > > I'm representing a stateful computation using a State Transform - > which works fine. Problem is in order to add flexibility to my > program I want to performs the > g my own Monad from scratch but this crossed my mind as another > possibillity - i.e. a Monad that either has a state of maybe double, > or has no state at all? > > I have a feeling I'd just 'return' the pure computations into the > state monad. My example code above seems weird and heavy weight to > me. > > I'd love to see what you figure you. > > Jason > > _______________________________________________ > 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/20090706/f9a64d1b/attachment.html From matthias.goergens at googlemail.com Mon Jul 6 20:49:08 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 6 20:31:25 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: <2a774a0c0907061642m139b75aep7ee835dfc3f08b06@mail.gmail.com> References: <20090706192637.GA19982@pudlak.name> <1246917027.4335.19.camel@supermule.opasia.dk> <2a774a0c0907061642m139b75aep7ee835dfc3f08b06@mail.gmail.com> Message-ID: The "sorted array of bags of unsorted input" is a nice idea. However, you have to use the data structure in a single-threaded [1] fashion to obtain the claimed bounds. Here's a pure solution that uses amortization and laziness. > import qualified Data.Sequence as S > import Data.Sequence ((><)) > import Data.Foldable > import Data.Monoid Suppose we have a function to find the the median of a list, and partition it into three sublists: Smaller than the median, equal to the media, larger than the median. That function should run in linear time. > partitionOnMedian :: forall a. (Ord a) => (S.Seq a) -> BTreeRaw a (S.Seq a) where the following data structure holds the sublists and some bookkeeping information: > data BTreeRaw a m = Leaf > | Node {cmp::(a->Ordering) > , lN :: Int > , less::m > , eq :: (S.Seq a) > , gN :: Int > , greater::m > } where 'lN' and 'gN' are the length of 'less' and 'greater'. We can make BTreeRaw a functor: > instance Functor (BTreeRaw a) where > fmap f Leaf = Leaf > fmap f (Node c lN l e gN g) = Node c lN (f l) e gN (f g) Now using a fixed-point construction we can bootstrap a sorting algorithm from partitionOnMedian: > data Fix m = Fix {unfix :: (m (Fix m))} > type BTree a = Fix (BTreeRaw a) > treeSort :: forall a. (Ord a) => S.Seq a -> BTree a > treeSort = Fix . helper . partitionOnMedian > where helper = fmap (Fix . helper . partitionOnMedian) Now treeSort produces the thunk of a balanced binary search tree. Of course we can get a sorted list out of it (forcing the whole structure): > flatten :: BTree a -> S.Seq a > flatten (Fix Leaf) = S.empty > flatten (Fix (Node _ lN l e gN g)) = flatten l >< e >< flatten g > mySort = flatten . treeSort But we can also get elements efficently, forcing only a linear amount of comparisions in the worst case: > index :: BTree a -> Int -> a > index (Fix Leaf) _ = error "tried to get an element of Leaf" > index (Fix (Node lN l e gN g)) i | i < lN > = index l i > | i - lN < S.length e > = S.index e (i-lN) > | i - lN - S.length e < gN > = index g (i - lN - S.length e) > | i - lN - S.length e - gN >= 0 > = error "index out of bounds" Although we do have to force comparisions only once every time we touch the same element in the tree, we do still have to traverse the tree (in logarithmic time). If you want linear time access on first touch of an element and constant time access afterwards us toArray: > toArray :: (IA.IArray a t) => Fix (BTreeRaw t) -> a Int t > toArray tree = IA.listArray (0,maxI) (map (index tree) [0..maxI]) > where size (Fix Leaf) = 0 > size (Fix (Node lN _ e gN _)) = lN + S.length e + gN > maxI = size tree - 1 [1] Single-Threaded in the sense of Okasaki's use of the word. From matthias.goergens at googlemail.com Mon Jul 6 21:08:43 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 6 20:51:00 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell Message-ID: A Las Vegas algorithm, like randomized quicksort, uses a source of randomness to make certain decisions. However its output is unaffected by the randomness. So a function > f :: RandomGen g => g -> a -> b implementing a Las-Vegas-Algorithm 'looks' like a pure function, ignoring its first argument and depending solely on its second argument. What is an idiomatic way to implement such a function? I believe, Monads are too linear and strict. From john at repetae.net Mon Jul 6 21:28:54 2009 From: john at repetae.net (John Meacham) Date: Mon Jul 6 21:11:11 2009 Subject: [Haskell-cafe] Re: what about moving the record system to an addendum? In-Reply-To: <878wj1lcsl.wl%naesten@gmail.com> References: <878wj1lcsl.wl%naesten@gmail.com> Message-ID: <20090707012854.GD4430@sliver.repetae.net> Well, without a replacement, it seems odd to remove it. Also, Haskell currently doesn't _have_ a record syntax (I think it was always a misnomer to call it that) it has 'labeled fields'. None of the proposed record syntaxes fit the same niche as labeled fields so I don't see them going away even if a record syntax is added to haskell in the future. I would like to see the simple modifications to the record syntax listed on this page though http://hackage.haskell.org/trac/haskell-prime/wiki/ExistingRecords and a reworking of the standard to not refer to the current system as a 'record syntax' but rather a 'labeled fields' syntax. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From john at repetae.net Mon Jul 6 21:48:10 2009 From: john at repetae.net (John Meacham) Date: Mon Jul 6 21:30:26 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <1125425151.20090702030148@gmail.com> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <434008226.20090702012612@gmail.com> <1246489049.7418.12.camel@localhost> <1125425151.20090702030148@gmail.com> Message-ID: <20090707014810.GE4430@sliver.repetae.net> On Thu, Jul 02, 2009 at 03:01:48AM +0400, Bulat Ziganshin wrote: > Hello Duncan, > > Thursday, July 2, 2009, 2:57:29 AM, you wrote: > > > You don't need it to be the same between Windows and Unix, it just has > > to be standard on each platform, which it is. There are really only two > > ABIs in common use on x86, the System V ABI and the MS one (which apart > > from the stdcall calling convention only differs in the bitfield layout > > iirc). > > you mean that on windows gcc, msvc and all other C compilers use the > same ABI for passing and packing structs? Yes. If you think about it, otherwise it would be impossible to interface with system provided shared libraries (like libc) unless there is a standard. It sometimes varies across different OS's, but for any OS/chip combo there is a single defined C ABI. It is generally called the 'system V' ABI for historical reasons, even though chances are people arn't using it for system V. Usually it is provided by the chip manufacturer and all OS's follow it. Unless they feel like being a PITA, but in that case they have their own standards document that gcc will follow as an option. So, yes. there is always _some_ well defined ABI for the C langauge on a given platform. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From dan.doel at gmail.com Mon Jul 6 21:49:46 2009 From: dan.doel at gmail.com (Dan Doel) Date: Mon Jul 6 21:32:06 2009 Subject: [Haskell-cafe] golf, predicate check function for MonadPlus (was Re: How to read safely?) In-Reply-To: References: <3bd412d40906240240q13fd4cf4oc7062cd08ae72fb@mail.gmail.com> <200906240556.17953.dan.doel@gmail.com> Message-ID: <200907062149.47605.dan.doel@gmail.com> On Thursday 02 July 2009 6:36:09 am Jon Fairbairn wrote: > check :: (MonadPlus m) => (a -> Bool) -> a -> m a > check p a > | p a = return a > | otherwise = mzero > > I tried Hoogling for a function like check, but couldn't find it. Surely > there's one in a library somewhere? It looks useful to me. (I'm rather > taken by way the "check (all isSpace . snd)" part reads) > > Monad.guard comes close but fails to get the cigar; in fact > > guard b == check (const b) () > > So check is more general. I've often noticed the need for a similar function in conjunction with unfoldr: -- This is overly general for unfoldr, but it lines up with check stopAt :: (MonadPlus m) => (a -> Bool) -> (a -> b) -> a -> m b stopAt p f x | p x = mzero | otherwise = return (f x) -- stopAt p f x = guard (not $ p x) >> return (f x) -- stopAt p f = liftM2 (>>) (guard . not . p) (return . f) -- etc. Then you can write: unfoldr (stopAt p $ f) where p is a stopping predicate based on the seed, and f unfolds the seed one step. This lets you use the many functions in the standard library that have types like: s -> (a, s) where unfoldr wants them to instead be: s -> Maybe (a, s) However, I don't really like the name stopAt, and have never come up with anything better. And of course: check = flip stopAt id . not -- Dan From lrpalmer at gmail.com Mon Jul 6 22:04:55 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jul 6 21:47:11 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: References: Message-ID: <7ca3f0160907061904h73153ca5l79d4d3863de876a4@mail.gmail.com> 2009/7/6 Matthias G?rgens > A Las Vegas algorithm, like randomized quicksort, uses a source of > randomness to make certain decisions. However its output is > unaffected by the randomness. So a function > > > f :: RandomGen g => g -> a -> b > > implementing a Las-Vegas-Algorithm 'looks' like a pure function, > ignoring its first argument and depending solely on its second > argument. What is an idiomatic way to implement such a function? I > believe, Monads are too linear and strict. Interesting question! Well, you could make your own random generator for the lifetime of the function, with a fixed seed. I'd say this is the most "honest" way to do it; however, might a malicious user discover your seed, he could design an input that would make your algorithm perform poorly. I'm wary of saying you could use unsafePerformIO . randomRIO to get a seed. But I think some sort of unsafe something has to be involved, since you are representing a very advanced proof obligation (the algorithm is independent of the randomness). Keep us (me) posted on developments on this idea. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090706/c85c9f2f/attachment.html From ravi_n at alum.mit.edu Mon Jul 6 22:30:53 2009 From: ravi_n at alum.mit.edu (Ravi Nanavati) Date: Mon Jul 6 22:13:09 2009 Subject: [Haskell-cafe] BostonHaskell: Next meeting - July 16th at MIT CSAIL Reading Room (32-G882) Message-ID: <161d443c0907061930h2e7d478fx35d8d5ddfdadc3be@mail.gmail.com> I'm pleased to announce the July meeting of the Boston Area Haskell Users' Group. Based on the feedback from the June meeting and the constraints of our speakers, the July meeting has been scheduled for Thursday, July 16th from 6:30pm - 8:30pm. Like the June meeting, it will be held in the MIT CSAIL Reading Room (32-G882, i.e. a room on the 8th floor of the Gates Tower of the MIT's Stata Center at 32 Vassar St in Cambridge, MA). We have the following two talks scheduled: "An Introduction to GHC Hacking" by Alec Heller "Haskell on the iPhone" by Ryan Trinkle (a more in-depth discussion than his on-the-spot Lightning Talk last month). As always, there will be a break between the talks for discussion and mingling. We have openings for Lightning Talks (5-minute talk, 2-minute Q&A) during that period. We are also open to short, relevant advertisements (like my Hac Phi plug last month). If you're interested in giving a Lightning Talk, have an advertisement you'd like to share or are interested in speaking at a future meeting, please contact me at ravi_n@alum.mit.edu. I'd also appreciate it if people who can (and can't) attend this meeting fill out the attendance poll here: http://www.learnmyself.com/poll10828x74C54f13 I apologize for the URL, but Google Groups seems to ban JavaScript and I didn't want to delay this announcement while I tried to come up with something more convenient. Responding to this poll will help with two things: 1. Getting an idea of what fraction of the Boston-area Haskell community can and can't attend this meeting (to help with future scheduling). 2. Giving me an estimated count of attendees, should I manage to secure a sponsor for refreshments. Sponsorship of or other assistance with refreshments is still being eagerly solicited. If you have any questions about the meeting please send them to the BostonHaskell mailing list: bostonhaskell@googlegroups.com or contact me directly. I look forward to seeing many Boston-area Haskellers at the July meeting! Thank you, - Ravi Nanavati From dagit at codersbase.com Tue Jul 7 00:03:15 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Jul 6 23:45:31 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: References: Message-ID: 2009/7/6 Matthias G?rgens > A Las Vegas algorithm, like randomized quicksort, uses a source of > randomness to make certain decisions. However its output is > unaffected by the randomness. So a function > > > f :: RandomGen g => g -> a -> b > > implementing a Las-Vegas-Algorithm 'looks' like a pure function, > ignoring its first argument and depending solely on its second > argument. What is an idiomatic way to implement such a function? I > believe, Monads are too linear and strict. I believe this would be a good place to apply "implicit configurations". http://okmij.org/ftp/Haskell/types.html#Prepose Let me know if it solves your problem. What I recall of the paper is that it should work nicely for your situation. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090706/8c63452c/attachment.html From aslatter at gmail.com Tue Jul 7 01:58:08 2009 From: aslatter at gmail.com (Antoine Latter) Date: Tue Jul 7 01:40:24 2009 Subject: [Haskell-cafe] golf, predicate check function for MonadPlus (was Re: How to read safely?) In-Reply-To: <200907062149.47605.dan.doel@gmail.com> References: <3bd412d40906240240q13fd4cf4oc7062cd08ae72fb@mail.gmail.com> <200906240556.17953.dan.doel@gmail.com> <200907062149.47605.dan.doel@gmail.com> Message-ID: <694519c50907062258y75515eb1mc0a33f9c9b482bbb@mail.gmail.com> On Mon, Jul 6, 2009 at 8:49 PM, Dan Doel wrote: > > I've often noticed the need for a similar function in conjunction with > unfoldr: > > ?-- This is overly general for unfoldr, but it lines up with check > ?stopAt :: (MonadPlus m) => (a -> Bool) -> (a -> b) -> a -> m b > ?stopAt p f x > ? ?| p x ? ? ? = mzero > ? ?| otherwise = return (f x) > > ?-- stopAt p f x = guard (not $ p x) >> return (f x) > ?-- stopAt p f = liftM2 (>>) (guard . not . p) (return . f) > ?-- etc. > > Then you can write: > > ?unfoldr (stopAt p $ f) > I have the following function sitting around: unfoldUntil :: (b -> Bool) -> (b -> (a, b)) -> b -> [a] unfoldUntil p f n = unfoldr g n where g m | p m = Nothing | otherwise = Just $ f m But I don't remeber where I picked it up from. It looks like it fills a similar niche. Antoine From aslatter at gmail.com Tue Jul 7 02:10:01 2009 From: aslatter at gmail.com (Antoine Latter) Date: Tue Jul 7 01:52:17 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: References: Message-ID: <694519c50907062310k168f88fah4955c02797a89dab@mail.gmail.com> 2009/7/6 Matthias G?rgens : > A Las Vegas algorithm, like randomized quicksort, uses a source of > randomness to make certain decisions. ?However its output is > unaffected by the randomness. ?So a function > >> f :: RandomGen g => g -> a -> b > > implementing a Las-Vegas-Algorithm 'looks' like a pure function, > ignoring its first argument and depending solely on its second > argument. ?What is an idiomatic way to implement such a function? ?I > believe, Monads are too linear and strict. If I were using the function in an executable I were writing, I would probably do something like unsafePerformIO . randomIO. Or thread in the random Gen from main if it were convenient. If I were writing it as a library function, I would leave the function as you described and let the caller make the choice. Calling into randomIO in a library function is extremely dubious, as a second library could be getting and setting the random seed used by randomIO (see setStdGen). So I'm okay taking on that risk in an application I write, but I'm not okay shipping that risk in a re-usable library, with the risk hidden behind a type signature. Maybe I'm just paranoid. Antoine From hectorg87 at gmail.com Tue Jul 7 02:51:19 2009 From: hectorg87 at gmail.com (Hector Guilarte) Date: Tue Jul 7 02:33:55 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: References: Message-ID: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> A few days ago I had to randomly choose and element of a list and continue execution, so here's what I did: I made a infinite list of Random numbers [Int] (Not IO [Int]) and I passed it around all the time in a Tuple and whenever I returned I also returned the list, so I would always have it available whenever I needed to use it. Whenever I used it I took it's head off and returned the tail, along with whatever else I was returning in a Tuple. The seed for the Random Generator was the CPUTime. Here's the code: (The function that returns the infinite list is infinito, the one on the bottom) import Random import CPUTime import System.IO.Unsafe {-| La funcion @rand@ Retorna una lista de numeros Random para ser utilizados en la seleccion de las guardias en los if y los do -} rand :: (RandomGen g, Random a) => (a,a) -> g -> [a] rand range gen = as where (a,b) = split gen -- create two separate generators as = randomRs range a -- one infinite list of randoms {-| @seed@ Retorna la semilla con la que la funcion Random va a iniciar la generacion de los numeros Randoms -} seed :: Int seed = fromInteger (unsafePerformIO getCPUTime) {-| @mygen@ Retorna el generador estandar con la semilla dada por la funcion @seed@ -} mygen = mkStdGen seed {-| @infinito@ Retorna la lista infinita de donde se van a sacar los numeros para elegir la guardia a ser ejecutada en los if y los do -} infinito:: (Num t,Random t) => [t] infinito = [ x | x <- rand (1,1000000) mygen] Hope it works for you! Hector Guilarte -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090707/9f01690a/attachment.html From newhoggy at gmail.com Tue Jul 7 03:28:18 2009 From: newhoggy at gmail.com (John Ky) Date: Tue Jul 7 03:10:33 2009 Subject: [Haskell-cafe] Where can I get GHC for Solaris? Message-ID: Hi, Anyone know where I can get the GHC compiler and libraries for Solaris?: SunOS sun05 5.9 Generic_118558-30 sun4u sparc SUNW,Sun-Fire-280R I tried to compile GHC myself and got the following error: $ ./configure --enable-hc-boot checking build system type... sparc-sun-solaris2.9 checking host system type... sparc-sun-solaris2.9 checking target system type... sparc-sun-solaris2.9 Canonicalised to: sparc-sun-solaris2 checking for ghc... no checking for nhc... no checking for nhc98... no checking for hbc... no checking for ld... /usr/ccs/bin/ld checking for path to top of build tree... ./configure: -v0: command not found ./configure: utils/pwd/pwd: No such file or directory configure: error: cannot determine current directory Thanks -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090707/82c22029/attachment.html From apfelmus at quantentunnel.de Tue Jul 7 03:37:09 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Jul 7 03:19:28 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: <20090706192637.GA19982@pudlak.name> References: <20090706192637.GA19982@pudlak.name> Message-ID: Petr Pudlak wrote: > about a month ago, we were discussing sorting in Haskell with a friend. We > realized a nice property of lazy merge-sort (which is AFAIK the implementation > of Data.List.sort): Getting the first element of the sorted list actually > requires O(n) time, not O(n * log n) as in imperative languages. Similarly, taking the first k elements will take O(n + k log n) time. And this also works for the standard lazy quicksort. See also http://apfelmus.nfshost.com/quicksearch.html > And immediately we asked: Would it be possible to create a lazy > selection/sorting algorithm so that getting any element of the sorted > list/array by its index would require just O(n) time, and getting all the > elements would still be in O(n * log n)? > > More precisely: The result of sorting an n-element list or array should be a > structure that allows to ask i-th element of the result (for example, a lazy > array). Asking k arbitrary elements should take no more than > O(min(n * log n, k * n)) If you want to take elements only from the beginning, then using a list as result type is enough. But you want random access, and you rightly note that this requires some other data structure to store the sorted result, simply because xs !! k is at least O(k) time So, a tree like Matthias implements it is the way to go. Basically, it reifies the recursive calls of quicksort as a lazy data struture which can be evaluated piecemeal. (If you don't care about the O(k) inherent in xs !! k and only ask about the number of comparisons it takes to evaluate xs !! k , then it is possible to make the standard quicksort slightly lazier so that this works, too. Details in the link given above.) Regards, apfelmus -- http://apfelmus.nfshost.com From matthias.goergens at googlemail.com Tue Jul 7 03:46:30 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Jul 7 03:28:47 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> References: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> Message-ID: Dear Hector, Yes, I thought of a similar scheme. Say we want to implemented randomized quicksort. Passing a list of random numbers would destroy laziness and linearise the algorithm --- because the right recursion branch would need to know at least how many random numbers where consumed by the left branch. So for the example of quicksort I thought of passing an infinite binary tree of random numbers. > data RandomTree v = Node (RandomTree v) v (RandomTree v) > splitOnMedian :: Ord a => SomeRandomType -> [a] -> ([a],a,[a]) > quicksort :: RandomTree (SomeRandomType) -> [a] -> [a] > quicksort _ [] = [] > quicksort _ [a] = [a] > quicksort (Node left here right) s > = let (l,median,r) = splitOnMedian here s > in quicksort left l ++ median ++ quicksort right r Of course one would need a special data structure for each recursion scheme with this approach. For a number of algorithms something like the rose trees of Data.Tree should work, though. What I wondered was, if one could hid the random plumbing in some data structure, like the state monad, but less linear. Matthias. From matthias.goergens at googlemail.com Tue Jul 7 03:49:09 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Jul 7 03:31:24 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> Message-ID: > So, a tree like Matthias implements it is the way to go. Basically, it > reifies the recursive calls of quicksort as a lazy data struture which > can be evaluated piecemeal. Yes. I wonder if it is possible to use a standard (randomized quicksort) and employ some type class magic (like continuations) to make the reification [1] transparent to the code. Matthias. [1] I reified reify. From jochem at functor.nl Tue Jul 7 03:58:53 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Tue Jul 7 03:40:53 2009 Subject: [Haskell-cafe] Haskell Platform on Ubuntu In-Reply-To: <20090707082357.e5a2c57a.mle+hs@mega-nerd.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090707082357.e5a2c57a.mle+hs@mega-nerd.com> Message-ID: <4A53003D.8070305@functor.nl> Erik de Castro Lopo wrote: >> GHC in Ubuntu is a pain! > > The same is also currently true for GHC on Debian stable and > testing. Debian unstable is also a bit broken. I only use Debian Stable, but I don't find it very hard to use. I just use the binary packages from www.haskell.org. That said, there has been a lot of activity on the debian-haskell mailing list lately (debian-haskell@lists.debian.org) so there will probably some progress quite soon! (Not sure if it will be in time for Ubuntu 9.10 though). Cheers, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From ketil at malde.org Tue Jul 7 04:04:25 2009 From: ketil at malde.org (Ketil Malde) Date: Tue Jul 7 03:46:49 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: ("Matthias =?utf-8?Q?G=C3=B6rgens=22's?= message of "Tue\, 7 Jul 2009 09\:46\:30 +0200") References: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> Message-ID: <87skh8x6k6.fsf@malde.org> Matthias G?rgens writes: > Yes, I thought of a similar scheme. Say we want to implemented > randomized quicksort. Passing a list of random numbers would destroy > laziness and linearise the algorithm --- because the right recursion > branch would need to know at least how many random numbers where > consumed by the left branch. Well, you could implement a function 'split' as split (x:xs) = (evens (x:xs), evens xs) where evens (y:_:ys) = y:evens ys This would divide your supply of random numbers in two - this is lazy, but forcing any of the sublists would force the spine of the original list, so not optimal. So the obvious followup is why not pass a randomGen around instead, which has a split operation already defined, and which causes no laziness headaches? > What I wondered was, if one could hid the random plumbing in some data > structure, like the state monad, but less linear. This problem cries for a State monad solution - but you don't need to do it yourself, there's already a Random monad defined for you. -k -- If I haven't seen further, it is by standing in the footprints of giants From matthias.goergens at googlemail.com Tue Jul 7 04:31:20 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Jul 7 04:13:38 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: <87skh8x6k6.fsf@malde.org> References: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> <87skh8x6k6.fsf@malde.org> Message-ID: >> What I wondered was, if one could hid the random plumbing in some data >> structure, like the state monad, but less linear. > > This problem cries for a State monad solution - but you don't need to > do it yourself, there's already a Random monad defined for you. Yes, but I only need the random values inside splitOnMedia. The rest is just non-linear plumbing. We do not know beforehand how many random values a branch quicksort will consume --- neither do we ware about the state of the random generator at the end. Do you consider the RandomMonad the best fit? Matthias. From gaius at gaius.org.uk Tue Jul 7 04:24:39 2009 From: gaius at gaius.org.uk (gaius hammond) Date: Tue Jul 7 04:26:15 2009 Subject: [Haskell-cafe] Where can I get GHC for Solaris? In-Reply-To: References: Message-ID: <1246955079.4a5306471fa6f@netmail.pipex.net> Quoting John Ky : > Hi, > > Anyone know where I can get the GHC compiler and libraries for Solaris?: I'm using this one: http://www.haskell.org/ghc/download_ghc_683.html#sparcsolaris Cheers, G -- ------------------------------------------------- Visit Pipex Business: The homepage for UK Small Businesses Go to http://www.pipex.co.uk/business-services From lrpalmer at gmail.com Tue Jul 7 04:59:10 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Jul 7 04:41:26 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: References: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> <87skh8x6k6.fsf@malde.org> Message-ID: <7ca3f0160907070159p6308a458h4f8667fdf2e95849@mail.gmail.com> 2009/7/7 Matthias G?rgens > >> What I wondered was, if one could hid the random plumbing in some data > >> structure, like the state monad, but less linear. > > > > This problem cries for a State monad solution - but you don't need to > > do it yourself, there's already a Random monad defined for you. > > Yes, but I only need the random values inside splitOnMedia. The rest > is just non-linear plumbing. We do not know beforehand how many > random values a branch quicksort will consume --- neither do we ware > about the state of the random generator at the end. Do you consider > the RandomMonad the best fit? Random monad is a very natural choice for "random cloud" computations. Don't think of it as a state monad -- that's an implementation detail. You can think of a value of type Random a as a "probability distribution of a's"; and there are natural definitions for the monad operators on this semantics. I blogged about this a while ago: http://lukepalmer.wordpress.com/2009/01/17/use-monadrandom/ Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090707/0e727f42/attachment.html From max.rabkin at gmail.com Tue Jul 7 05:06:33 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Tue Jul 7 04:49:09 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: <694519c50907062310k168f88fah4955c02797a89dab@mail.gmail.com> References: <694519c50907062310k168f88fah4955c02797a89dab@mail.gmail.com> Message-ID: 2009/7/7 Antoine Latter : > If I were writing it as a library function, I would leave the function > as you described and let the caller make the choice. Calling into > randomIO in a library function is extremely dubious, as a second > library could be getting and setting the random seed used by randomIO > (see setStdGen). > > So I'm okay taking on that risk in an application I write, but I'm not > okay shipping that risk in a re-usable library, with the risk hidden > behind a type signature. > > Maybe I'm just paranoid. You're not paranoid if they're really out to get you. I have been in a similar situation (on the other side: I discovered the flaw, and demonstrated an attack). I was in a Python class where our final project was a fairly fully-featured battleships game (3d graphics, network play and a computer player). Part of the evaluation (and a very fun part of the project) was an AI tournament. The TA gave us the code for the tournament server beforehand to that we could test our programs, and I observed that each player was loaded as a module into the same Python process. Python has both a global RNG and encapsulated RNG objects, but since it's an imperative language it's natural to use the global one and most people did. So one could seed the RNG at the start of each game to ones advantage: I tried this afterwards and beat all my opponents convincingly (in the real contest, where I didn't cheat, I was roughly equal to the two other top players and came second). > Antoine --Max From jon.fairbairn at cl.cam.ac.uk Tue Jul 7 05:10:03 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Tue Jul 7 04:52:34 2009 Subject: [Haskell-cafe] Re: golf, predicate check function for MonadPlus References: <3bd412d40906240240q13fd4cf4oc7062cd08ae72fb@mail.gmail.com> <200906240556.17953.dan.doel@gmail.com> <200907062149.47605.dan.doel@gmail.com> Message-ID: Dan Doel writes: > On Thursday 02 July 2009 6:36:09 am Jon Fairbairn wrote: >> check :: (MonadPlus m) => (a -> Bool) -> a -> m a >> check p a >> | p a = return a >> | otherwise = mzero > > I've often noticed the need for a similar function in conjunction with > unfoldr: > > -- This is overly general for unfoldr, but it lines up with check > stopAt :: (MonadPlus m) => (a -> Bool) -> (a -> b) -> a -> m b > stopAt p f x > | p x = mzero > | otherwise = return (f x) Yes, I've had occasion to use something like that too, eg things similar to: reverse . unfoldr (stopAt (==0) (swap . flip divMod 10)) where swap (a,b) = (b,a) > And of course: check = flip stopAt id . not or, equally, "stopAt p f = fmap f . check (not . p)" Granted, reverse . unfoldr (fmap (swap . flip divMod 10) . check (/=0)) isn't /quite/ as nice as the first version, but I imagine one could get used to it. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From bulat.ziganshin at gmail.com Tue Jul 7 05:07:20 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jul 7 04:55:25 2009 Subject: [Haskell-cafe] Re: Could FFI support pass-by-value of structs? In-Reply-To: <20090707014810.GE4430@sliver.repetae.net> References: <20090623222512.GE29066@sliver.repetae.net> <20090625014846.GE13322@sliver.repetae.net> <1246305795.28197.797.camel@localhost> <367848282.20090630004528@gmail.com> <1246321112.28197.858.camel@localhost> <434008226.20090702012612@gmail.com> <1246489049.7418.12.camel@localhost> <1125425151.20090702030148@gmail.com> <20090707014810.GE4430@sliver.repetae.net> Message-ID: <858663924.20090707130720@gmail.com> Hello John, Tuesday, July 7, 2009, 5:48:10 AM, you wrote: >> you mean that on windows gcc, msvc and all other C compilers use the >> same ABI for passing and packing structs? > Yes. If you think about it, otherwise it would be impossible to > interface with system provided shared libraries (like libc) unless there > is a standard. first, i asked about Windows. second, afair Win32 API doesn't have any functions that pass or return entire records rather than pointers. third, i've seen incompatibility problems with packing structs between MSVC (8-byte alignment, afair) and Borland C++ (1-byte) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ketil at malde.org Tue Jul 7 05:47:58 2009 From: ketil at malde.org (Ketil Malde) Date: Tue Jul 7 05:30:26 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: <7ca3f0160907070159p6308a458h4f8667fdf2e95849@mail.gmail.com> (Luke Palmer's message of "Tue\, 7 Jul 2009 00\:59\:10 -0800") References: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> <87skh8x6k6.fsf@malde.org> <7ca3f0160907070159p6308a458h4f8667fdf2e95849@mail.gmail.com> Message-ID: <878wj0x1rl.fsf@malde.org> Luke Palmer writes: > Random monad is a very natural choice for "random cloud" computations. > Don't think of it as a state monad -- that's an implementation detail. You > can think of a value of type Random a as a "probability distribution of > a's"; and there are natural definitions for the monad operators on this > semantics. I wonder if pure values and values in the Random monad as belonging to different complexity classes? It's been to long since theory of computation, but I think the relationship between BPP and the other classes is a bit unclear. (Of course, Random isn't limited to polynomial.) > I blogged about this a while ago: > http://lukepalmer.wordpress.com/2009/01/17/use-monadrandom/ Nice. I've been busy writing a simulator, and thus needed to model some of the statistical distributions. The way I did this, was to say data Distribution = Uniform low high | Normal mu sigma | StudentT ... and sample :: Distribution -> Random Double sample (Normal mu sigma) = ... one reason to go beyond simply: normal :: Double -> Double -> Random Double -- normal mu sigma = sample (Normal mu sigma) is that you might want to do other things with a probability distribution than sampling it, like querying p-values for a given sample. I haven't gotten around to it yet, but I think I can get away by defining functions for the cumulative distribution and its inverse, and just write a generic function for 'sample' (which would need to pull a random probability (0<=p<=1). (But it might turn out it is useful to specialize it for simple distributions anyway?) -k -- If I haven't seen further, it is by standing in the footprints of giants From ketil at malde.org Tue Jul 7 05:52:30 2009 From: ketil at malde.org (Ketil Malde) Date: Tue Jul 7 05:34:52 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: <878wj0x1rl.fsf@malde.org> (Ketil Malde's message of "Tue\, 07 Jul 2009 11\:47\:58 +0200") References: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> <87skh8x6k6.fsf@malde.org> <7ca3f0160907070159p6308a458h4f8667fdf2e95849@mail.gmail.com> <878wj0x1rl.fsf@malde.org> Message-ID: <87vdm4vmzl.fsf@malde.org> Ketil Malde writes: > data Distribution = Uniform low high | Normal mu sigma | StudentT ... Of course, now that it occurs to me to check this, I notice Data.Random.Distribution does the same thing, only more generally, supporting more distributions, and no doubt with more robust implementations. Used wheel for sale cheap, slightly less round than the competition. Oh well. -k -- If I haven't seen further, it is by standing in the footprints of giants From ketil at malde.org Tue Jul 7 06:47:54 2009 From: ketil at malde.org (Ketil Malde) Date: Tue Jul 7 06:30:20 2009 Subject: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell In-Reply-To: <878wj0x1rl.fsf@malde.org> (Ketil Malde's message of "Tue\, 07 Jul 2009 11\:47\:58 +0200") References: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> <87skh8x6k6.fsf@malde.org> <7ca3f0160907070159p6308a458h4f8667fdf2e95849@mail.gmail.com> <878wj0x1rl.fsf@malde.org> Message-ID: <87ocrwvkf9.fsf@malde.org> Ketil Malde writes: > sample :: Distribution -> Random Double Sorry, that's not entirely accurate. Rather: sample :: RandomGen g => Distribution -> Rand g Double -k -- If I haven't seen further, it is by standing in the footprints of giants From chris at eidhof.nl Tue Jul 7 06:50:19 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Tue Jul 7 06:32:49 2009 Subject: [Haskell-cafe] DHUG: meeting tomorrow (July 7th) in Utrecht Message-ID: Hi everyone, The Dutch HUG [1] will meet again tomorrow. This time we'll meet in Utrecht again, at the Stairway To Heaven. The meeting will start at 19h. The venue is a sometimes a bit noisy, but there's beer and nice big tables. If you want to hear everything about the Dutch HUG straight from the horse's mouth: make sure you're at the meetings and subscribed to the mailing list [2]. We already have more than 40 members after two meetings! See you tomorrow! -chris [1]: http://www.haskell.org/haskellwiki/Dutch_HUG [2]: http://groups.google.com/group/dutch-hug From duncan.coutts at worc.ox.ac.uk Tue Jul 7 05:40:04 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jul 7 06:37:42 2009 Subject: [Haskell-cafe] Re: what about moving the record system to an addendum? In-Reply-To: <20090707012854.GD4430@sliver.repetae.net> References: <878wj1lcsl.wl%naesten@gmail.com> <20090707012854.GD4430@sliver.repetae.net> Message-ID: <1246959604.22466.711.camel@localhost> On Mon, 2009-07-06 at 18:28 -0700, John Meacham wrote: > Well, without a replacement, it seems odd to remove it. Also, Haskell > currently doesn't _have_ a record syntax (I think it was always a > misnomer to call it that) it has 'labeled fields'. None of the proposed > record syntaxes fit the same niche as labeled fields so I don't see them > going away even if a record syntax is added to haskell in the future. The people proposing this can correct me if I'm wrong but my understanding of their motivation is not to remove record syntax or immediately to replace it, but to make it easier to experiment with replacements by making the existing labelled fields syntax a modular part of the language that can be turned on or off (like the FFI). I'm not sure that I agree that it's the best approach but it is one idea to try and break the current impasse. It seems currently we cannot experiment with new record systems because they inevitably clash with the current labelled fields and thus nothing changes. Duncan From marlowsd at gmail.com Tue Jul 7 07:19:31 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Tue Jul 7 07:01:49 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <4A528089.1070903@gmx.de> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> Message-ID: <4A532F43.6040107@gmail.com> Karmic (9.10) will have GHC 6.10.3, possibly 6.10.4. http://bugs.launchpad.net/ubuntu/+source/ghc6/+bug/302149 Cheers, Simon On 06/07/2009 23:54, Stefan Roggensack wrote: > Hello, > > I have uploaded the ghc package to my ppa: > https://launchpad.net/~someone561/+archive/ppa > But I don't work on it. I simple backport the debian sid packages. Also > there are not the haskell libraries as debs. Maybe this helps you. > > Stefan > > Rafael Gustavo da Cunha Pereira Pinto wrote: >> Thanks. I may even be the one to step up, if nothing happens till >> 9.10... I really miss up-to-date ghc in Ubuntu. >> >> >> >> 2009/7/6 Don Stewart> >> >> RafaelGCPP.Linux: >> > >> > Is there anyone working on a Haskell Platform package for Ubuntu? >> > >> > GHC in Ubuntu is a pain! >> >> The Debian team is working on packaging, but until then (or if someone >> on Ubuntu steps up), you'll need to use the Unix tarball: >> >> >> http://hackage.haskell.org/platform/2009.2.0.1/haskell-platform-2009.2.0.1.tar.gz >> >> -- Don >> >> >> From matthias.goergens at googlemail.com Tue Jul 7 07:27:28 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Jul 7 07:09:44 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <4A532F43.6040107@gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> Message-ID: > Karmic (9.10) will have GHC 6.10.3, possibly 6.10.4. It currently spots 6.10.3, in the alpha release I run here. From patai_gergely at fastmail.fm Tue Jul 7 07:44:27 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Tue Jul 7 07:26:41 2009 Subject: [Haskell-cafe] ANN: bloxorz clone In-Reply-To: <20090706170724.GC14155@whirlpool.galois.com> References: <1246652524.9181.1323418579@webmail.messagingengine.com> <20090705212712.GB10538@whirlpool.galois.com> <1246861803.9664.1323645631@webmail.messagingengine.com> <20090706170724.GC14155@whirlpool.galois.com> Message-ID: <1246967067.27654.1323870581@webmail.messagingengine.com> > Will the darcs (or.. ) repository for the code be made public? > I'm sure there are people in the community who'd like to contribute new > levels, etc. I asked him, and he said that he plans to develop it further during the summer and make a public repo somewhere. We'll probably have to wait a few weeks for that. Gergely -- http://www.fastmail.fm - The professional email service From Brettschneider at HS-AlbSig.de Tue Jul 7 08:08:11 2009 From: Brettschneider at HS-AlbSig.de (Matthias Brettschneider) Date: Tue Jul 7 07:50:28 2009 Subject: [Haskell-cafe] Optimizing Compiler for the ICFP 09 contest's VM In-Reply-To: <40a414c20907041412s7d5575bere74fa7cc1304a926@mail.gmail.com> References: <40a414c20907041412s7d5575bere74fa7cc1304a926@mail.gmail.com> Message-ID: <20090707120811.GA6574@v2305> Same over here, i would love to read about your discoveries :) -- Matthias On Sat, Jul 04, 2009 at 11:12:30PM +0200, minh thu wrote: > 2009/7/4 Matthias G?rgens : > > If anyboby is interested, I can document my program and put it online > > somewhere. I also made pretty graphs of the dataflow with graphviz. > > Hi Matthias, > > it would be nice to blog a little post about what you found and the > pretty graphs :) > > Thu > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From matthias.goergens at googlemail.com Tue Jul 7 08:55:47 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Jul 7 08:38:02 2009 Subject: [Haskell-cafe] Optimizing Compiler for the ICFP 09 contest's VM In-Reply-To: <20090707120811.GA6574@v2305> References: <40a414c20907041412s7d5575bere74fa7cc1304a926@mail.gmail.com> <20090707120811.GA6574@v2305> Message-ID: Since I have two readers now, I guess I'll have to start blogging. :o) From ravi at bluespec.com Tue Jul 7 10:28:11 2009 From: ravi at bluespec.com (Ravi Nanavati) Date: Tue Jul 7 10:10:27 2009 Subject: [Haskell-cafe] Re: what about moving the record system to an addendum? In-Reply-To: <1246959604.22466.711.camel@localhost> References: <878wj1lcsl.wl%naesten@gmail.com> <20090707012854.GD4430@sliver.repetae.net> <1246959604.22466.711.camel@localhost> Message-ID: <7b977d860907070728i626edd05oed4c37f4f97e6b03@mail.gmail.com> 2009/7/7 Duncan Coutts : > On Mon, 2009-07-06 at 18:28 -0700, John Meacham wrote: >> Well, without a replacement, it seems odd to remove it. Also, Haskell >> currently doesn't _have_ a record syntax (I think it was always a >> misnomer to call it that) it has 'labeled fields'. None of the proposed >> record syntaxes fit the same niche as labeled fields so I don't see them >> going away even if a record syntax is added to haskell in the future. > > The people proposing this can correct me if I'm wrong but my > understanding of their motivation is not to remove record syntax or > immediately to replace it, but to make it easier to experiment with > replacements by making the existing labelled fields syntax a modular > part of the language that can be turned on or off (like the FFI). > > I'm not sure that I agree that it's the best approach but it is one idea > to try and break the current impasse. It seems currently we cannot > experiment with new record systems because they inevitably clash with > the current labelled fields and thus nothing changes. I think it is a powerful approach to try and break the current impasse for the following reasons: 1. Once implemented, Hackage and Cabal will soon give us accurate data on what publicly available Haskell code does and does not depend on NamedFields/TraditionalRecordSyntax/WhateverWeEndUpCallingIt 2. Once deprecated, people will be encouraged to not depend on the traditional record syntax where the cost of avoiding it is small (I'm thinking of situations like the mtl-accessors / run functions where the traditional syntax is saving something like one function definition). 3. Champions of alternative record syntaxes will know what on Hackage they can use out-of-the-box and what things they'd want to consider re-writing as examples of how their approach is superior. Does anyone have a concrete dea of what it would take to carve out the existing syntax as an addendum? Thanks, - Ravi From apfelmus at quantentunnel.de Tue Jul 7 11:50:58 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Jul 7 11:33:21 2009 Subject: [Haskell-cafe] Re: Implementing Las Vegas algorithms in Haskell In-Reply-To: <7ca3f0160907070159p6308a458h4f8667fdf2e95849@mail.gmail.com> References: <69630b260907062351i2e860d78x33b00f949e181ac8@mail.gmail.com> <87skh8x6k6.fsf@malde.org> <7ca3f0160907070159p6308a458h4f8667fdf2e95849@mail.gmail.com> Message-ID: Luke Palmer wrote: >>>> What I wondered was, if one could hid the random plumbing in some data >>>> structure, like the state monad, but less linear. >>> This problem cries for a State monad solution - but you don't need to >>> do it yourself, there's already a Random monad defined for you. >> >> Yes, but I only need the random values inside splitOnMedia. The rest >> is just non-linear plumbing. We do not know beforehand how many >> random values a branch quicksort will consume --- neither do we ware >> about the state of the random generator at the end. Do you consider >> the RandomMonad the best fit? > > > Random monad is a very natural choice for "random cloud" computations. > Don't think of it as a state monad -- that's an implementation detail. You > can think of a value of type Random a as a "probability distribution of > a's"; and there are natural definitions for the monad operators on this > semantics. > > I blogged about this a while ago: > http://lukepalmer.wordpress.com/2009/01/17/use-monadrandom/ I concur with Luke that interpreting Random a as a probability distribution of values of type a is the best mental model. The fact that it's a monad is secondary, if crucial for doing anything with these values. For a concrete example, http://apfelmus.nfshost.com/random-permutations.html might help. Regards, apfelmus -- http://apfelmus.nfshost.com From dpiponi at gmail.com Tue Jul 7 13:18:56 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Tue Jul 7 13:01:11 2009 Subject: [Haskell-cafe] lazy data structure for best-first search In-Reply-To: <1245894801.5932.34.camel@martin-laptop> References: <1245894801.5932.34.camel@martin-laptop> Message-ID: <625b74080907071018s1d53444bp33971204a2b47052@mail.gmail.com> On Wed, Jun 24, 2009 at 6:53 PM, Martin Hofmann wrote: > I am looking for a good (preferably lazy) way to implement some kind of > best-first search. > So in fact, after one expansion, I need to fold over my complete search > space, maybe updating other nodes and recompute the value of the cost > function for the affected nodes. A bit late, but it just dawned on me that if I understand you correctly I may have stumbled on the same problem when I was implementing the code here http://blog.sigfpe.com/2009/07/monad-for-combinatorial-search-with.html I tried to modify that code so that I could assign costs that were of type Float. But I found that it was computing costs for more of the graph than I wanted and that for infinite search spaces I'd never get termination. The code I ended up writing in that post solves your problem, in effect by storing costs lazily. That way you can compare the cost of A and B without having to force a full computation of the cost of both A and B and making it safe to fold over infinite search trees. In fact, my zipm function is essentially a fold with a lazy version of the mergeOn function that Luke Palmer suggests in another reply. That code is best when the costs are all small non-negative integers, which may or may not be adaptable to your problem. -- Dan From marcosomarviera at gmail.com Tue Jul 7 16:00:42 2009 From: marcosomarviera at gmail.com (Marcos Viera) Date: Tue Jul 7 15:43:02 2009 Subject: [Haskell-cafe] ANNOUNCE: AspectAG 0.1.1 In-Reply-To: <1B6E1D99-7B9E-4493-88B2-0EA4A54A5906@swierstra.net> References: <1213789520.15010.837.camel@localhost> <7A61F72B-55DD-4390-AA51-1A6B6FBF2C31@swierstra.net> <49399A47.1020103@van.steenbergen.nl> <1B6E1D99-7B9E-4493-88B2-0EA4A54A5906@swierstra.net> Message-ID: <4A53A96A.2000403@gmail.com> We are pleased to announce the availability of the package "AspectAG", a library of strongly typed Attribute Grammars implemented using type-level programming. The package contains the code associated with our paper at ICFP 2009: @inproceedings{Viera:Attribute-Grammars, Author = {Marcos Viera and S.~Doaitse Swierstra and Wouter Swierstra}, Title = {Attribute Grammars Fly First-Class: How to do Aspect Oriented Programming in Haskell}, Booktitle = {ICFP'09: Proceedings of the 2009 SIGPLAN International Conference on Functional Programming}, Year = {2009} } You can find some more information at http://www.cs.uu.nl/wiki/bin/view/Center/AspectAG. Enjoy! Doaitse Swierstra Wouter Swierstra Marcos Viera From iavor.diatchki at gmail.com Tue Jul 7 17:33:00 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Tue Jul 7 17:15:14 2009 Subject: [Haskell-cafe] Re: what about moving the record system to an addendum? In-Reply-To: <7b977d860907070728i626edd05oed4c37f4f97e6b03@mail.gmail.com> References: <878wj1lcsl.wl%naesten@gmail.com> <20090707012854.GD4430@sliver.repetae.net> <1246959604.22466.711.camel@localhost> <7b977d860907070728i626edd05oed4c37f4f97e6b03@mail.gmail.com> Message-ID: <5ab17e790907071433m505d8a66j6e455e51f57bbad3@mail.gmail.com> Hello, I do not think that we should remove the current record/named fields syntax, at least for the moment. I use it a lot, and I do not want to add extra pragmas or "extensions" to my cabal file. In fact, one of the purposes of Haskell', the way I understand it, is exactly to just choose a stable set of extensions and give a name to them (so decrease, not increase the number of pragmas). I think that a new reocrd/label system is way beyond the scope of Haskell'. If people want to experiment with new record systems they may already do so, by defining a new extension. A case in point is the Trex record system, which is implemented in Hugs. -Iavor 2009/7/7 Ravi Nanavati : > 2009/7/7 Duncan Coutts : >> On Mon, 2009-07-06 at 18:28 -0700, John Meacham wrote: >>> Well, without a replacement, it seems odd to remove it. Also, Haskell >>> currently doesn't _have_ a record syntax (I think it was always a >>> misnomer to call it that) it has 'labeled fields'. None of the proposed >>> record syntaxes fit the same niche as labeled fields so I don't see them >>> going away even if a record syntax is added to haskell in the future. >> >> The people proposing this can correct me if I'm wrong but my >> understanding of their motivation is not to remove record syntax or >> immediately to replace it, but to make it easier to experiment with >> replacements by making the existing labelled fields syntax a modular >> part of the language that can be turned on or off (like the FFI). >> >> I'm not sure that I agree that it's the best approach but it is one idea >> to try and break the current impasse. It seems currently we cannot >> experiment with new record systems because they inevitably clash with >> the current labelled fields and thus nothing changes. > > I think it is a powerful approach to try and break the current impasse > for the following reasons: > > 1. Once implemented, Hackage and Cabal will soon give us accurate data > on what publicly available Haskell code does and does not depend on > NamedFields/TraditionalRecordSyntax/WhateverWeEndUpCallingIt > 2. Once deprecated, people will be encouraged to not depend on the > traditional record syntax where the cost of avoiding it is small (I'm > thinking of situations like the mtl-accessors / run functions where > the traditional syntax is saving something like one function > definition). > 3. Champions of alternative record syntaxes will know what on Hackage > they can use out-of-the-box and what things they'd want to consider > re-writing as examples of how their approach is superior. > > Does anyone have a concrete dea of what it would take to carve out the > existing syntax as an addendum? > > Thanks, > > ?- Ravi > _______________________________________________ > Haskell-prime mailing list > Haskell-prime@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-prime > From john at repetae.net Tue Jul 7 17:33:57 2009 From: john at repetae.net (John Meacham) Date: Tue Jul 7 17:16:15 2009 Subject: [Haskell-cafe] Re: what about moving the record system to an addendum? In-Reply-To: <7b977d860907070728i626edd05oed4c37f4f97e6b03@mail.gmail.com> References: <878wj1lcsl.wl%naesten@gmail.com> <20090707012854.GD4430@sliver.repetae.net> <1246959604.22466.711.camel@localhost> <7b977d860907070728i626edd05oed4c37f4f97e6b03@mail.gmail.com> Message-ID: <20090707213357.GF4430@sliver.repetae.net> On Tue, Jul 07, 2009 at 10:28:11AM -0400, Ravi Nanavati wrote: > 2. Once deprecated, people will be encouraged to not depend on the > traditional record syntax where the cost of avoiding it is small (I'm > thinking of situations like the mtl-accessors / run functions where > the traditional syntax is saving something like one function > definition). > 3. Champions of alternative record syntaxes will know what on Hackage > they can use out-of-the-box and what things they'd want to consider > re-writing as examples of how their approach is superior. Well, that's the problem. I don't want to ever deprecate the named field mechanism as it is completely independent of a record system. You can think of the possibilites as follows. named positional declared LabeledFields DataDeclarations anonymous ???? Tuples So, a record syntax fills the hole of anonymous, named field types. However, we shouldn't do it at the expense of opening another hole with declared, named field types any more than we should dispose of standard data declations in favor of making everything newtypes of tuples. Also, this supports the idea of using parethensis rather than braces for a record mechanism. this would be consistent with tuples in that parens = anonymous. Also, if you just replace braces with parens in the scoped records paper, you get no conflicts with existing syntax. (including named fields) :) John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From ryani.spam at gmail.com Tue Jul 7 17:34:18 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 7 17:16:33 2009 Subject: [Haskell-cafe] Adaptive transactions Message-ID: <2f9b2d30907071434y3af949ceje15632355400b33e@mail.gmail.com> It seems to me that the Adaptive framework[1][2] is well-suited to STM transactions. Consider this snippet: > expensive_transaction :: STM Int -- does a bunch of work > > example :: TVar Int -> STM Int > example t = (+) <$> readTVar t <*> expensive_transaction If the TVar passed to example is rapidly changing (perhaps it represents the current time), then this transaction will starve; it never gets a chance to complete, even if the values used by expensive_transaction aren't changing at all, we still re-evaluate the entire action each time we "retry" this transaction. But STM has a wonderful property: what we need to commit a transaction is just the result value and a transaction log; both of these depend only on the values of TVars read by that transaction. So, if "expensive_transaction" doesn't refer to the TVar "t", then even if "t" is rapidly changing, the transaction log generated by "expensive_transaction" must not change, and we can just re-generate the part of the transaction log for "readTVar t" and recompute the (+). This gets even better when considering big processes that are blocked by an explicit "retry"; if some change in input is just going to cause the transaction to retry again (and go back to sleep), we'd like that to happen as quickly as possible. Has anyone looked down this path? It seems quite promising to me. -- ryan [1] http://hackage.haskell.org/package/Adaptive [2] Acar et al, Adaptive Functional Programming, POPL 2002 http://citeseer.ist.psu.edu/old/752721.html From mle+hs at mega-nerd.com Tue Jul 7 18:57:26 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue Jul 7 18:39:49 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <4A532F43.6040107@gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> Message-ID: <20090708085726.76f4ebeb.mle+hs@mega-nerd.com> Simon Marlow wrote: > Karmic (9.10) will have GHC 6.10.3, possibly 6.10.4. > > http://bugs.launchpad.net/ubuntu/+source/ghc6/+bug/302149 Unfortunately thats only half the story. The GHC 6.10.3 that is going into Kamic is the one from Debian Unstable. It is important to note here that beyond doing a rebuild of the Debian source package against Ubuntu's binary versions of all the libraries, Ubuntu/Cannonical does no extra work to make Haskell (or anything else outside the Ubuntu core packages) work on Ubuntu. It should also be noted that although ghc-6.10.3 works, a huge bunch of Haskell libraries still need to be build with the new compiler for them to be useful. Since Debian is still working on getting this process sorted out, there is little reason to believe that Ubuntu is going to be any better at getting this fixed. If anyone is interested in seeing improved Haskell support in Ubuntu, they should be looking towards the Debian Haskell maintainers, not Ubuntu :-). Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From porges at porg.es Tue Jul 7 19:03:39 2009 From: porges at porg.es (George Pollard) Date: Tue Jul 7 18:45:52 2009 Subject: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor) Message-ID: <6d942a4a0907071603p6eeb24b0lc8049e6dfe76225a@mail.gmail.com> Ok, so I have a small idea I'm trying to work on; call it a Prelude-rewrite if you want. For this I want to be able to have the hierarchy Functor ? Applicative ? Monad. For Functor, I would like to be able to implement it for a wider variety of types, as there are types which have aren't polymorphic which would also benefit from having an instance. My running example for this set of types is ByteString; the module contains the method: map ? (Word8 ? Word8) ? ByteString ? ByteString However, we cannot use this for Functor because ByteString isn't polymorphic. To get around this, I devised the following: Introduce a type family which represents ?points? inside the type: type family Point f ? ? For ByteString we have: type instance Point ByteString = Word8 For a polymorphic example (lists) we have: type instance Point [a] = a Now Functor becomes: class SimpleFunctor f where fmap ? (Point f ? Point f) ? (f ? f) However, this doesn't allow for the existence of functions with the type (a ? b). I need to introduce another type into the class: class Functor f g where fmap ? (Point f ? Point g) ? (f ? g) But having two types isn't very nice (for one thing we can't introduce a fundep because for lists as it fails one of the coverage conditions), so introduce another type family to represent types which can be produced by giving a free variable: type Subst f a ? ? type Subst [a] b = [b] type Subst ByteString b = ByteString class Functor f where fmap ? (Point f ? Point (Subst f a)) ? (f ? Subst f a) I'm not sure how much of a hack this is, or if there is a better way. It seems to be OK... Now I want to implement Applicative. It would make sense to have ?return? be split out into a separate class, because this can be restricted in a similar way to Functor: class Pointed f where return ? Point f ? f instance Pointed [a] where return x = [x] instance Pointed ByteString where return = BS.singleton Now, I want to be able to restrict Applicative to things which have [Pointed f, and forall a b. Point f ~ (a ? b)]. At the moment I can't figure this out because I believe it would require something like the ?quantified contexts? proposal: class (Pointed f, ? a b. Point f ~ (a ? b)) ? Applicative f where ... I could have something like: class (Pointed f, Point f ~ (a ? b)) ? Applicative f a b where apply ? f ? Subst f a ? Subst f b This is still not very nice, because it requires two more type variables in the class, and the non-type-families version is far more straightforward... in fact, it makes sense for the Applicative class to have a polymorphic type because it must be able to have ?return? applied to arbitrary functions (remember [fmap f xs ? return f `apply` xs]). So back to: class Applicative f where apply ? f (a ? b) ? f a ? f b But then ?return? cannot be added via a superclass restriction to Pointed! I seem to have painted myself into a corner. Does anyone see a better way to go about this? Thanks, - George From porges at porg.es Tue Jul 7 19:17:22 2009 From: porges at porg.es (George Pollard) Date: Tue Jul 7 18:59:36 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> Message-ID: <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> 2009/7/7 Matthias G?rgens : >> Karmic (9.10) will have GHC 6.10.3, possibly 6.10.4. > > It currently spots 6.10.3, in the alpha release I run here. A major problem is that the libraries are still for 6.8.2, so you cannot install the required libs to install cabal. Grr. From martin.hofmann at uni-bamberg.de Tue Jul 7 20:35:51 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Tue Jul 7 20:18:11 2009 Subject: [Haskell-cafe] lazy data structure for best-first search In-Reply-To: <625b74080907071018s1d53444bp33971204a2b47052@mail.gmail.com> References: <1245894801.5932.34.camel@martin-laptop> <625b74080907071018s1d53444bp33971204a2b47052@mail.gmail.com> Message-ID: <1247013351.6244.4.camel@martin-laptop> Thanks Dan, that gave me some new input I can continue working on. Cheers, Martin Am Dienstag, den 07.07.2009, 10:18 -0700 schrieb Dan Piponi: > On Wed, Jun 24, 2009 at 6:53 PM, Martin > Hofmann wrote: > > I am looking for a good (preferably lazy) way to implement some kind of > > best-first search. > > > So in fact, after one expansion, I need to fold over my complete search > > space, maybe updating other nodes and recompute the value of the cost > > function for the affected nodes. > > A bit late, but it just dawned on me that if I understand you > correctly I may have stumbled on the same problem when I was > implementing the code here > http://blog.sigfpe.com/2009/07/monad-for-combinatorial-search-with.html > > I tried to modify that code so that I could assign costs that were of > type Float. But I found that it was computing costs for more of the > graph than I wanted and that for infinite search spaces I'd never get > termination. The code I ended up writing in that post solves your > problem, in effect by storing costs lazily. That way you can compare > the cost of A and B without having to force a full computation of the > cost of both A and B and making it safe to fold over infinite search > trees. In fact, my zipm function is essentially a fold with a lazy > version of the mergeOn function that Luke Palmer suggests in another > reply. > > That code is best when the costs are all small non-negative integers, > which may or may not be adaptable to your problem. > -- > Dan -- ------------------------- From john at repetae.net Tue Jul 7 22:29:22 2009 From: john at repetae.net (John Meacham) Date: Tue Jul 7 22:11:35 2009 Subject: [Haskell-cafe] simple state monad exercises? (besides labeling trees) In-Reply-To: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> References: <910ddf450907060954i1be18e11se788d3b92e04d4b9@mail.gmail.com> Message-ID: <20090708022921.GH4430@sliver.repetae.net> On Mon, Jul 06, 2009 at 12:54:54PM -0400, Thomas Hartman wrote: > Can someone give some simple common scenarios where the state monad is > useful, besides labeling trees? Implementing the Union-Find data structure[1] for unification based type inference. As far as I know, no good alternative exists that has the same very low computational complexity of the true stateful union-find. Also, it's computational complexity has the ackermann's function in it, which is just neat. John [1] http://en.wikipedia.org/wiki/Disjoint-set_data_structure -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From porges at porg.es Tue Jul 7 22:31:11 2009 From: porges at porg.es (George Pollard) Date: Tue Jul 7 22:13:24 2009 Subject: [Haskell-cafe] following up on space leak In-Reply-To: <65d7a7e0907052027q7a16f595w9fa53fcacb8cdaab@mail.gmail.com> References: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> <856033f20907051906j59b0e4a5k7a62679ecaeb3f82@mail.gmail.com> <65d7a7e0907051946g5e51156at9529dcc8480f45c5@mail.gmail.com> <57526e770907051952u80ba639of5fe921e64b2039c@mail.gmail.com> <65d7a7e0907052027q7a16f595w9fa53fcacb8cdaab@mail.gmail.com> Message-ID: <6d942a4a0907071931o486b3de5ua5130288aee3f0c3@mail.gmail.com> I believe there might be an elegant solution for this using the `Last` monoid From dav.vire+haskell at gmail.com Wed Jul 8 02:29:58 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Jul 8 02:12:10 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> Message-ID: <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> Even if 6.10.3 gets into Karmic, I'm sure the problem will arise again once 6.12.1 is out. It's sadly easier to install from the tarball. David. From ketil at malde.org Wed Jul 8 02:59:29 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Jul 8 02:41:50 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> (George Pollard's message of "Wed\, 8 Jul 2009 11\:17\:22 +1200") References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> Message-ID: <87ljmzpsmm.fsf@malde.org> George Pollard writes: > 2009/7/7 Matthias G?rgens : >>> Karmic (9.10) will have GHC 6.10.3, possibly 6.10.4. >> It currently spots 6.10.3, in the alpha release I run here. > A major problem is that the libraries are still for 6.8.2, so you > cannot install the required libs to install cabal. Grr. I'm sorry, but I don't follow you. Surely the libraries must be compiled against the shipping version of GHC? -k -- If I haven't seen further, it is by standing in the footprints of giants From mle+hs at mega-nerd.com Wed Jul 8 03:07:21 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Jul 8 02:49:49 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <87ljmzpsmm.fsf@malde.org> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <87ljmzpsmm.fsf@malde.org> Message-ID: <20090708170721.e421b71a.mle+hs@mega-nerd.com> Ketil Malde wrote: > I'm sorry, but I don't follow you. Surely the libraries must be > compiled against the shipping version of GHC? Yes, but the libraries that are currently there are the ones compiled with the previous version of ghc. Yes, those libraries need to be recompiled and no, that process has not yet been properly automated. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From mle+hs at mega-nerd.com Wed Jul 8 03:15:31 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Jul 8 02:57:52 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> Message-ID: <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> david48 wrote: > Even if 6.10.3 gets into Karmic, I'm sure the problem will arise again > once 6.12.1 is out. The Debian Haskell maintainers are working on fixing this. In particular, working on setting up an automated process so that when the compiler version is updated, all Haskell libraries get built with the new compiler. The Ocaml programming language has exactly the same problem, but the Debian Ocaml maintainers have automated the process and last time to Ocaml compiler version was updated over 95% of all Ocaml libraries were rebuilt within 24 hours. > It's sadly easier to install from the tarball. Currently yes. That should change in the not too distant future. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From newhoggy at gmail.com Wed Jul 8 03:32:13 2009 From: newhoggy at gmail.com (John Ky) Date: Wed Jul 8 03:21:29 2009 Subject: [Haskell-cafe] Where can I get GHC for Solaris? In-Reply-To: <1247035686.4117.17.camel@aycan> References: <1246952832.4117.11.camel@aycan> <1247035686.4117.17.camel@aycan> Message-ID: Hi Aycan, This is the version of make I am using: joky@sun05:~ $ make -v GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for sparc-sun-solaris2.9 joky@sun05:~ $ uname -a SunOS sun05 5.9 Generic_118558-30 sun4u sparc SUNW,Sun-Fire-280R Thanks, -John On Wed, Jul 8, 2009 at 4:48 PM, Aycan iRiCAN wrote: > ?ar, 2009-07-08 tarihinde 09:55 +1000 saatinde, John Ky yazd?: > > Hi, > > > > I had a go with the binary dist, and got this error message on the > > make install: > > > > /home/a-m/joky/.tools/ghc-6.8.2/lib/ghc-6.8.2"' > > -DPKG_DATADIR='"/export/home/a-m/joky/.tools/ghc-6.8.2/share/ghc-6.8.2"' > package.conf.in \ > > | grep -v '^#pragma GCC' \ > > | sed -e 's/""//g' -e 's/:[ ]*,/: /g' \ > > > > | /export/home/a-m/joky/ghc-6.8.2/utils/ghc-pkg/ghc-pkg.bin > > --global-conf > /export/home/a-m/joky/.tools/ghc-6.8.2/lib/ghc-6.8.2/package.conf update - > --force > > ld.so.1: ghc-pkg.bin: fatal: libm.so.2: version `SUNW_1.2' not found > > (required by > > file /export/home/a-m/joky/ghc-6.8.2/utils/ghc-pkg/ghc-pkg.bin) > > ld.so.1: ghc-pkg.bin: fatal: libm.so.2: open failed: No such file or > > directory > > Killed > > make[1]: *** [install] Error 137 > > make[1]: Leaving directory `/export/home/a-m/joky/ghc-6.8.2/rts' > > make: *** [install] Error 2 > > Are you using gmake? > > -- > aycan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090708/0349e891/attachment.html From marlowsd at gmail.com Wed Jul 8 03:51:58 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Jul 8 03:34:14 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> Message-ID: <4A54501E.10309@gmail.com> On 08/07/2009 00:17, George Pollard wrote: > 2009/7/7 Matthias G?rgens: >>> Karmic (9.10) will have GHC 6.10.3, possibly 6.10.4. >> It currently spots 6.10.3, in the alpha release I run here. > > A major problem is that the libraries are still for 6.8.2, so you > cannot install the required libs to install cabal. Grr. My understanding is they're waiting for 6.10.4 before recompiling all the libraries, because it's a big job and they don't want to do it twice. Cheers, Simon From jgm at berkeley.edu Wed Jul 8 04:20:11 2009 From: jgm at berkeley.edu (John MacFarlane) Date: Wed Jul 8 04:03:01 2009 Subject: [Haskell-cafe] ANN: texmath 0.1.0.1 - conversion of LaTeX math to MathML Message-ID: <20090708082011.GA16421@protagoras.phil.berkeley.edu> I'm pleased to announce an early release of texmath, a Haskell library for converting LaTeX math formulas to MathML. Hackage: http://hackage.haskell.org/package/texmath-0.1.0.1 Github: http://github.com/jgm/texmath/tree/master The package includes a standalone test program, testTeXMathML, and a CGI script, texmath-cgi, that can be used in web apps. This script is used in the demos at http://johnmacfarlane.net/texmath.xhtml http://johnmacfarlane.net/texmath.html texmath supports most of basic LaTeX and AMS extensions, but I'm sure some things have been left out, so let me know if you try a formula that should work but doesn't. John From RafaelGCPP.Linux at gmail.com Wed Jul 8 06:34:50 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Wed Jul 8 06:17:01 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> Message-ID: <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> > > The Ocaml programming language has exactly the same problem, but > the Debian Ocaml maintainers have automated the process and last > time to Ocaml compiler version was updated over 95% of all Ocaml > libraries were rebuilt within 24 hours. Since I never built GHC from scratch, it is really hard for me to estimate how much effort would I have to put through to automate the whole building process. Anyway, automating the package building process is crucial for Linux distributions. One problem I see is the binary-only distribution of packages. This makes cabal-install incompatible with most distributions except, maybe, gentoo. The automation process would have to run through hackageDB tracking dependencies and compiling each needed library. Pretty hard stuff... Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090708/e529a529/attachment.html From matthias.goergens at googlemail.com Wed Jul 8 07:27:31 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Jul 8 07:09:43 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> Message-ID: > One problem I see is the binary-only distribution of packages. This makes > cabal-install incompatible with most distributions except, maybe, gentoo. > The automation process would have to run through hackageDB tracking > dependencies and compiling each needed library. Pretty hard stuff... Yes. The sanest approach for any distribution would seem to install are bare bones ghc + cabal (cabal install) and let the cabal package system do the hard work directly. Matthias. From dav.vire+haskell at gmail.com Wed Jul 8 07:32:13 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Jul 8 07:14:25 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> Message-ID: <4c88418c0907080432i637b4b65m903b3381ea8ef025@mail.gmail.com> 2009/7/8 Matthias G?rgens : >> One problem I see is the binary-only distribution of packages. This makes >> cabal-install incompatible with most distributions except, maybe, gentoo. >> The automation process would have to run through hackageDB tracking >> dependencies and compiling each needed library. Pretty hard stuff... > > Yes. ?The sanest approach for any distribution would seem to install > are bare bones ghc + cabal (cabal install) and let the cabal package > system do the hard work directly. That wouldn't work, as cabal dependancies don't allow downloading the appropriate C libraries from the distribution repositories when needed. From ketil at malde.org Wed Jul 8 07:39:37 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Jul 8 07:21:57 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: ("Matthias =?utf-8?Q?G=C3=B6rgens=22's?= message of "Wed\, 8 Jul 2009 13\:27\:31 +0200") References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> Message-ID: <87skh7o13a.fsf@malde.org> Matthias G?rgens writes: >> One problem I see is the binary-only distribution of packages. This makes >> cabal-install incompatible with most distributions except, maybe, gentoo. >> The automation process would have to run through hackageDB tracking >> dependencies and compiling each needed library. Pretty hard stuff... > Yes. The sanest approach for any distribution would seem to install > are bare bones ghc + cabal (cabal install) and let the cabal package > system do the hard work directly. I don't have much experience with building binary packages, but surely the (binary) distributions should ship (binary) packages of as much as possible of the useful, stable libraries and executables? One reason this is important is that a major feature of binary distributions is providing a homogenous, stable, universal set of packages for all users. This makes bugs a lot more trackable: either they affect all users, or none. -k -- If I haven't seen further, it is by standing in the footprints of giants From mle+hs at mega-nerd.com Wed Jul 8 07:42:53 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Jul 8 07:25:13 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> Message-ID: <20090708214253.c4ea146d.mle+hs@mega-nerd.com> Rafael Gustavo da Cunha Pereira Pinto wrote: > One problem I see is the binary-only distribution of packages. Well Debian does have source packages as well, thats what they build the binaries from :-). > The automation process would have to run through hackageDB tracking > dependencies and compiling each needed library. On Debian, haskell libraries can be build from the same .cabal files that Hackage uses. There is no need to read anything from the HackageDB. > Pretty hard stuff... The fact that the Ocaml people can do means that it definitely possible, and Ocaml upstream libraries don't ship with anything near as useful as the .cabal files in Haskell packages. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From mle+hs at mega-nerd.com Wed Jul 8 07:47:09 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Jul 8 07:29:24 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> Message-ID: <20090708214709.b09a1e01.mle+hs@mega-nerd.com> Matthias G?rgens wrote: > Yes. The sanest approach for any distribution would seem to install > are bare bones ghc + cabal (cabal install) and let the cabal package > system do the hard work directly. Cabal works really well for a single developer on a single machine. Debian packages work really well where there are multiple developers on multiple machines and auto-build bots where you want all of these to be using the exact same binary package. The reason I am pursuing the Debian way is because I find the second option far more useful. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From magnus at therning.org Wed Jul 8 10:22:01 2009 From: magnus at therning.org (Magnus Therning) Date: Wed Jul 8 10:04:13 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <20090708214709.b09a1e01.mle+hs@mega-nerd.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> <20090708214709.b09a1e01.mle+hs@mega-nerd.com> Message-ID: On Wed, Jul 8, 2009 at 12:47 PM, Erik de Castro Lopo wrote: > Matthias G?rgens wrote: > >> Yes. ?The sanest approach for any distribution would seem to install >> are bare bones ghc + cabal (cabal install) and let the cabal package >> system do the hard work directly. > > Cabal works really well for a single developer on a single machine. > > Debian packages work really well where there are multiple developers > on multiple machines and auto-build bots where you want all of these > to be using the exact same binary package. It also works really well for _users_ of applications written in Haskell. The introduction of dynamic linking will mean that those applications need the pre-built libraries they depend on. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From johan.tibell at gmail.com Wed Jul 8 10:35:04 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Wed Jul 8 10:17:35 2009 Subject: [Haskell-cafe] Re: [Haskell] Haskell Hack Day, Edinburgh, 30 August 2009 In-Reply-To: <20090708101223.GJ12171@brighton.ac.uk> References: <20090708101223.GJ12171@brighton.ac.uk> Message-ID: <90889fe70907080735v48ecb7a3p2bca15267b575a1e@mail.gmail.com> On Wed, Jul 8, 2009 at 12:12 PM, Eric Kow wrote: > Dear Haskellers, > > I am pleased to report that we will be having a Haskell Hack Day in > Edinburgh, on Sunday 30 August (before the ICFP begins). The day will > be held at the ICFP conference venue, the Royal College of Physicians. > > The Hack Day will be free and open to all. > Come join us; it'll be a lot of fun! My flight arrives too late for actually taking part in the hackathon but I would be up for some beers after if anyone is interested. -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090708/29eeb013/attachment.html From apfelmus at quantentunnel.de Wed Jul 8 14:31:13 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed Jul 8 14:13:26 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> Message-ID: Matthias G?rgens wrote: >> So, a tree like Matthias implements it is the way to go. Basically, it >> reifies the recursive calls of quicksort as a lazy data struture which >> can be evaluated piecemeal. > > Yes. I wonder if it is possible to use a standard (randomized > quicksort) and employ some type class magic (like continuations) to > make the reification [1] transparent to the code. > > Matthias. > [1] I reified reify. Well, you can perform an abstraction similar to what leads to the definition of fold . Starting with say sum [] = 0 sum (x:xs) = x + sum xs we can replace the special values 0 and + by variables, leading to a function (fold f z) [] = z (fold f z) (x:xs) = x `f` (fold f z) xs In other words, if we specialize the variables to 0 and + again, we get fold (+) 0 = sum Similarly, we can start with quicksort quicksort :: Ord a => [a] -> [a] quicksort [] = [] quicksort (x:xs) = quicksort ls ++ [x] ++ quicksort rs where ls = filter (<= x) xs rs = filter (> x) xs and replace the operations on the return type with variables quicksort :: Ord a => (a -> b -> b -> b) -> b -> [a] -> b quicksort f z [] = z quicksort f z (x:xs) = f x (quicksort f z ls) (quicksort f z rs) where ls = filter (<= x) xs rs = filter (> x) xs Note however that this is not quite enough to handle the case of a random access tree like you wrote it, because the latter depends on the fact that quicksorts *preserves* the length of the list. What I mean is that we have to keep track of the lengths of the lists, for instance like this: quicksort :: Ord a => (a -> (Int,b) -> (Int,b) -> b) -> b -> [a] -> (Int,b) quicksort f z [] = (0,z) quicksort f z (x:xs) = (length xs + 1, f x (quicksort f z ls) (quicksort f z rs)) where ls = filter (<= x) xs rs = filter (> x) xs And we can implement a random access tree type Sized a = (Int, a) size = fst data Tree a = Empty | Branch a (Sized (Tree a)) (Sized (Tree a)) mySort :: [a] -> Sized (Tree a) mySort = quicksort Branch Empty index :: Sized (Tree a) -> Int -> Maybe a index (0,Empty) _ = Nothing index (n,Branch x a b) k | 1 <= k && k <= size a = index a k | k == size a + 1 = Just x | size a + 1 < k && k <= n = index b (k - size a - 1) | otherwise = Nothing or an ordinary sort qsort :: Ord a => [a] -> [a] qsort = quicksort (\x a b -> snd a ++ [x] ++ snd b) [] Regards, apfelmus -- http://apfelmus.nfshost.com From dons at galois.com Wed Jul 8 16:26:53 2009 From: dons at galois.com (Don Stewart) Date: Wed Jul 8 16:11:02 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <20090708214709.b09a1e01.mle+hs@mega-nerd.com> References: <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <351ff25e0907080334v44703f6fi6c7be0f403c065a4@mail.gmail.com> <20090708214709.b09a1e01.mle+hs@mega-nerd.com> Message-ID: <20090708202653.GD24309@whirlpool.galois.com> mle+hs: > Matthias G?rgens wrote: > > > Yes. The sanest approach for any distribution would seem to install > > are bare bones ghc + cabal (cabal install) and let the cabal package > > system do the hard work directly. > > Cabal works really well for a single developer on a single machine. > > Debian packages work really well where there are multiple developers > on multiple machines and auto-build bots where you want all of these > to be using the exact same binary package. > > The reason I am pursuing the Debian way is because I find the second > option far more useful. > And distro packages are much easier for new users (who can later graduate to the cabal-install cabal). -- Don From t.h at gmx.info Wed Jul 8 18:15:12 2009 From: t.h at gmx.info (Timo B. =?utf-8?q?H=C3=BCbel?=) Date: Wed Jul 8 17:57:24 2009 Subject: [Haskell-cafe] ANN: Hayoo! beta 0.4 Message-ID: <200907090015.12572.t.h@gmx.info> Hello! We are pleased to announce the next beta version 0.4 of Hayoo!, the Haskell API search engine with find-as-you-type and suggestions. Visit Hayoo! here: http://holumbus.fh-wedel.de/hayoo This release includes some major changes to the web interface: - The full description of a function can now be displayed upon request, using the small "+" symbol in front of the description text - The most common root modules for all functions found are shown as list, providing a shortcut for further restricting the current query - Some example queries on the start page for easier use of Hayoo! Additionally, we have again updated the search index. It contains all packages from Hackage as well as gtk2hs as of 06.07.2009, a total of 111.946 function and type definitions. Please let us know about any problems, hints and suggestions. Happy hacking, Timo From nomeata at debian.org Wed Jul 8 18:23:43 2009 From: nomeata at debian.org (Joachim Breitner) Date: Wed Jul 8 18:05:58 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> Message-ID: <1247091823.4581.72.camel@localhost> Hi Erik, Am Mittwoch, den 08.07.2009, 17:15 +1000 schrieb Erik de Castro Lopo: > The Ocaml programming language has exactly the same problem, but > the Debian Ocaml maintainers have automated the process and last > time to Ocaml compiler version was updated over 95% of all Ocaml > libraries were rebuilt within 24 hours. looking at http://debian.glondu.net/monitor/ocaml/ocaml_transition_monitor.html I get the impression that the Ocaml guys need to re-build everything when a new Ocaml library comes out, but not when just a dependency was upgraded. Is that right? If it is so, we have an excuse due to our slightly more complicated procedure. Also, how do they get it in 24 ? don?t they have to wait, for each level in the dependency tree, for the former level to have been built on a buildd, upload signed by a buildd admin and them moved to the archive with the next mirror push? Greetings, Joachim -- Joachim "nomeata" Breitner Debian Developer nomeata@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata@joachim-breitner.de | http://people.debian.org/~nomeata -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090708/5a8c56c0/attachment.bin From jeff at nokrev.com Wed Jul 8 18:27:51 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Wed Jul 8 18:10:06 2009 Subject: [Haskell-cafe] ANN: hsparql, a SPARQL query generator/DSL and client Message-ID: <1247092071.4864.17.camel@ulysses> I'm excited to announce the first version of hsparql. HSparql makes it easy to query SPARQL-compliant servers using a relatively intuitive DSL and very simple client. SPARQL is a SQL-ish query language for stores of RDF data. So, SPARQL lets you search the structured data in several big databases. I wrote it so that I could search DBpedia [1], a neat site that pulls structured data from Wikipedia's infoboxes, and also ties it to remote data services like MusicBrainz and US Census information. HSparql isn't tied to DBpedia in any way, though, and can search any server. The DSL looks something like this: > simple :: Query [Variable] > simple = do > resource <- prefix (iriRef "http://dbpedia.org/resource/") > dbpprop <- prefix (iriRef "http://dbpedia.org/property/") > foaf <- prefix (iriRef "http://xmlns.com/foaf/0.1/") > > x <- var > name <- var > page <- var > > triple x (dbpprop .:. "genre") (resource .:. "Web_browser") > > triple x (foaf .:. "name") name > triple x (foaf .:. "page") page > > return [name, page] It's currently available on Hackage [2], and at the moment the source is only available from the tarball hosted there. I'd greatly appreciate any feedback on this package. Thanks! Jeff Wheeler [1] http://dbpedia.org/ [2] http://hackage.haskell.org/package/hsparql From mle+hs at mega-nerd.com Wed Jul 8 18:57:03 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Jul 8 18:39:21 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <1247091823.4581.72.camel@localhost> References: <351ff25e0907061334j620d5f95o2a063e96d9320922@mail.gmail.com> <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <1247091823.4581.72.camel@localhost> Message-ID: <20090709085703.fc0eafbc.mle+hs@mega-nerd.com> Joachim Breitner wrote: > looking at > http://debian.glondu.net/monitor/ocaml/ocaml_transition_monitor.html I > get the impression that the Ocaml guys need to re-build everything when > a new Ocaml library I assume you mean compiler there? > comes out, but not when just a dependency was upgraded. Is that right? I'm not really sure about that. Ocaml libraries seem (warning, generalizations follow) seem to be fewer in number that Haskell but be more comprehensive. Haskell has far more small libraries and as a result, Haskell projects often have much deeper and wider dependency trees than similar Ocaml projects. > If it is so, we have an excuse due to our > slightly more complicated procedure. Yes, I agree that the Haskell problem is a more difficult example of the same problems the Ocaml maintainers face. There may also be parts which the Ocaml maintainers don't have to face at all, but in general, the Haskell problem is similar to the Ocaml one. > Also, how do they get it in 24 ? don?t they have to wait, for each level > in the dependency tree, for the former level to have been built on a > buildd, upload signed by a buildd admin and them moved to the archive > with the next mirror push? Sorry, I'm not sure of how they do it. I just notice that something in their first round of compiles like camlbz2 was build on amd64 on 20090629-2107 and something in their last round like json-static was built on amd64 on 20090701-1149. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From dons at galois.com Wed Jul 8 19:34:47 2009 From: dons at galois.com (Don Stewart) Date: Wed Jul 8 19:18:57 2009 Subject: [Haskell-cafe] Re: Haskell Platform on Ubuntu In-Reply-To: <20090709085703.fc0eafbc.mle+hs@mega-nerd.com> References: <20090706221313.GU14155@whirlpool.galois.com> <351ff25e0907061537s6c4c2befhed8f5e7e63599860@mail.gmail.com> <4A528089.1070903@gmx.de> <4A532F43.6040107@gmail.com> <6d942a4a0907071617p76a9fa92l8ebf2a0ee19f93f4@mail.gmail.com> <4c88418c0907072329g6380655ib66d42f5f680bb11@mail.gmail.com> <20090708171531.8ffd04dd.mle+hs@mega-nerd.com> <1247091823.4581.72.camel@localhost> <20090709085703.fc0eafbc.mle+hs@mega-nerd.com> Message-ID: <20090708233447.GK24309@whirlpool.galois.com> mle+hs: > Joachim Breitner wrote: > > > looking at > > http://debian.glondu.net/monitor/ocaml/ocaml_transition_monitor.html I > > get the impression that the Ocaml guys need to re-build everything when > > a new Ocaml library > > I assume you mean compiler there? > > > comes out, but not when just a dependency was upgraded. Is that right? > > I'm not really sure about that. > > Ocaml libraries seem (warning, generalizations follow) seem to be fewer > in number that Haskell but be more comprehensive. Haskell has far more > small libraries and as a result, Haskell projects often have much deeper > and wider dependency trees than similar Ocaml projects. The difference is cabal-install: automated dependency resolving makes for more packages. > > If it is so, we have an excuse due to our > > slightly more complicated procedure. > > Yes, I agree that the Haskell problem is a more difficult example > of the same problems the Ocaml maintainers face. There may also be > parts which the Ocaml maintainers don't have to face at all, but > in general, the Haskell problem is similar to the Ocaml one. > > > Also, how do they get it in 24 ? don?t they have to wait, for each level > > in the dependency tree, for the former level to have been built on a > > buildd, upload signed by a buildd admin and them moved to the archive > > with the next mirror push? Also, the Haskell libs are updating more frequently (more of them, and more updates). We're averaging 10 updates a day atm: http://www.galois.com/~dons/images/hackage-daily-graph.png -- Don From matthias.goergens at googlemail.com Thu Jul 9 02:20:55 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Jul 9 02:03:05 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> Message-ID: Interesting. Can you make the definition of quicksort non-recursive, too? Perhaps with help of a bootstrapping combinator like the one implicit in the approach I have given earlier? > treeSort = bootstrap partitionOnMedian > bootstrap f = Fix . helper . f > where helper = fmap (Fix . helper . f) > partitionOnMedian :: forall a. (Ord a) => (S.Seq a) -> BTreeRaw a (S.Seq a) Extra points if you can give 'bootstrap' or an equivalent in terms of existing Haskell combinators. Matthias. From apfelmus at quantentunnel.de Thu Jul 9 05:31:52 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Jul 9 05:14:07 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> Message-ID: Matthias G?rgens wrote: > Interesting. Can you make the definition of quicksort non-recursive, > too? Perhaps with help of a bootstrapping combinator like the one > implicit in the approach I have given earlier? > >> treeSort = bootstrap partitionOnMedian >> bootstrap f = Fix . helper . f >> where helper = fmap (Fix . helper . f) > >> partitionOnMedian :: forall a. (Ord a) => (S.Seq a) -> BTreeRaw a (S.Seq a) > > Extra points if you can give 'bootstrap' or an equivalent in terms of > existing Haskell combinators. Sure, no problem. Of course, some part of algorithm has to be recursive, but this can be outsourced to a general recursion scheme, like the hylomorphism hylo :: Functor f => (a -> f a) -> (f b -> b) -> (a -> b) hylo f g = g . fmap (hylo f g) . f This scheme is a combination of the anamorphism which builds the tree of recursive calls data Fix f = In { out :: f (Fix f) } ana :: Functor f => (a -> f a) -> a -> Fix f ana f = In . fmap (ana f) . f and a catamorphism which combines the results cata :: Functor f => (f b -> b) -> Fix f -> b cata g = g . fmap (cata g) . out so we could also write hylo f g = cata g . ana f For quicksort, the call tree is the fixed point of the functor type Size = Int data Q a b = Empty | Merge Size a b b instance Functor (Q a) where fmap f (Merge n x b b') = Merge n x (f b) (f b') fmap f Empty = Empty The algorithm quicksort = hylo partition merge proceeds in the two well-known phases: first, the input list is partitioned into two parts separated by a pivot partition [] = Empty partition (x:xs) = Merge (length xs + 1) x ls xs where ls = filter (<= x) xs rs = filter (> x) xs and then the sorted results are merged merge Empty = [] merge (Merge _ x a b) = a ++ [x] ++ b The random access tree implementation can be obtained by using a different merge function. In particular, the quicksort from my previous post was parametrized on merge (with a slightly different way to indicate the list lengths); any function of type (Size -> a -> b -> b -> b) -> b -> c is equivalent to a function of type (Q a b -> b) -> c Incidentally, the random access tree *is* the call tree for quicksort, so we'd have merge = In and we can shorten the whole thing to quicksort = ana partition which is essentially what you coded. To read about hylo f g = cata g . ana f with quicksort as example again in a slightly different light, see also the following blog post by Ulisses Costa http://ulissesaraujo.wordpress.com/2009/04/09/hylomorphisms-in-haskell/ Regards, apfelmus -- http://apfelmus.nfshost.com From nicolas.pouillard at gmail.com Thu Jul 9 05:34:00 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Thu Jul 9 05:17:33 2009 Subject: [Haskell-cafe] ANN: hsparql, a SPARQL query generator/DSL and client In-Reply-To: <1247092071.4864.17.camel@ulysses> References: <1247092071.4864.17.camel@ulysses> Message-ID: <1247131943-sup-704@ausone.inria.fr> Excerpts from Jeff Wheeler's message of Thu Jul 09 00:27:51 +0200 2009: > I'm excited to announce the first version of hsparql. HSparql makes it > easy to query SPARQL-compliant servers using a relatively intuitive DSL > and very simple client. I've looked at your DSL and it looks really neat. While reading I was wondering if GADTs could help having an even nicer query language. -- Nicolas Pouillard http://nicolaspouillard.fr From matthias.goergens at googlemail.com Thu Jul 9 06:14:24 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Jul 9 05:56:33 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> Message-ID: Thanks. I heard about the hylo-, ana- and catamorphisms before, but never explicitly used them. Time to get started. And yet another question: One can get the median in deterministic linear time. For quicksort choosing the median as pivot keeps the O(n log n) average running time and brings down the expected worst case, too. Do you know of a (natural) way to combine selecting the median and doing the quicksort, so that you don't compare unnecessarily? The way to de-randomize quickselect is to calculate medians of medians. I.e. solve the problem for smaller instances first. I suspect if we follow this strategy with the reified quicksort call-trees, the de-randomized quicksort will look a lot like mergesort. From allbery at ece.cmu.edu Thu Jul 9 06:45:54 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Jul 9 06:28:31 2009 Subject: [Haskell-cafe] Where can I get GHC for Solaris? In-Reply-To: References: <1246952832.4117.11.camel@aycan> <1247035686.4117.17.camel@aycan> Message-ID: <9D50550F-51B4-4770-AB0E-A6D2E63B57D0@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/20090709/8131b6e8/PGP.bin From voigt at tcs.inf.tu-dresden.de Thu Jul 9 07:40:48 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Thu Jul 9 07:22:59 2009 Subject: [Haskell-cafe] ANN: Hayoo! beta 0.4 In-Reply-To: <200907090015.12572.t.h@gmx.info> References: <200907090015.12572.t.h@gmx.info> Message-ID: <4A55D740.6090001@tcs.inf.tu-dresden.de> Timo B. H?bel wrote: > Visit Hayoo! here: http://holumbus.fh-wedel.de/hayoo > > Additionally, we have again updated the search index. It contains all packages > from Hackage as well as gtk2hs as of 06.07.2009, a total of 111.946 function > and type definitions. Is it possible that coverage has decreased in some areas? I am pretty sure that a week ago or so I could use Hayoo to find sumP :: Num a => [:a:] -> a from GHC.PArr. Now, that result does not turn up anymore. Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From me at mornfall.net Thu Jul 9 07:53:47 2009 From: me at mornfall.net (Petr Rockai) Date: Thu Jul 9 07:36:02 2009 Subject: [Haskell-cafe] ANN: darcs 2.3 beta 2 Message-ID: <87skh68438.fsf@twilight.int.mornfall.net.> Hello! Two weeks passed and it is about time to release darcs 2.3 beta 2 (it's already a day late, sorry about that). As with beta 1, there is only a single installation package for this release of darcs: cabalised source. (Please note that the final version with also come with the legacy autoconf-based buildsystem, for the last time.) You can either download a tarball from and build manually (see the build instructions in README inside the tarball), or, alternatively, you can use cabal-install to obtain a copy (the beta release is now available on Hackage): $ cabal update $ cabal install darcs-beta This, if successful, will give you a darcs binary in `~/.cabal/bin` -- you should probably add that to your PATH. What's new since beta 1 ----------------------- There are basically two relatively intrusive changes since beta 1. First, I have added index upgrade functionality to hashed-storage and this is now used by darcs, so that any bad or incompatible indexes are recreated transparently by darcs. Moreover, the index format is now architecture-independent, meaning that repositories shared across multiple architectures should not suffer from excessive index rebuilding. Second, Ganesh has done further work on his gzip CRC correction code. There is a very slight risk of regressions, so if you have around any repositories with broken CRCs in them, please test this functionality. Moreover, there is now an option to limit the repair to current repository, avoiding changes in related branches or caches. Trent, Thorkil and Eric have done cleanup work and a number of minor fixes for this release, improving overall quality and polish. One bug in the new indexing code has been found and reported by Eric and Guillaume independently, and is fixed in hashed-storage 0.3.4 (which required by this beta). You can track the release plan and progress at our wiki: . The question of GHC 6.8 ----------------------- Using GHC 6.10.3 or newer is *strongly recommended*. You may compile darcs with GHC 6.8, but there are several caveats. If you are using 6.8.2 or older, please disable mmap support (pass -f-mmap to cabal install or runghc Setup configure below). Note that the GHC 6.8.2 that ships with Debian Lenny is not affected and it should be safe to keep mmap enabled. It is also recommended to disable use of Hackage zlib when compiling with GHC 6.8.2 (including the Debian Lenny version): pass -f-zlib to cabal. When using zlib, we have seen occasional crashes with error messages like "openBinaryFile: file locked" -- this is a known GHC 6.8.2 bug (and is fixed in GHC 6.8.3). Last, if you are using a 64-bit system, darcs may hang when you exit a pager when compiled with GHC older than 6.10.3. Although this is harmless, it is quite inconvenient. Overall, the status of GHC 6.8 is "semi-supported": for many cases, things will work just fine, especially if you take a little extra caution with compilation flags. Yours, Petr. -- Petr Ro?kai | http://web.mornfall.net A physicist is an atom's way of knowing about atoms. (George Wald) From cristiano.paris at gmail.com Thu Jul 9 08:55:09 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Thu Jul 9 08:37:39 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example Message-ID: Hi, I'm wondering what a good example of why laziness enhances composability would be. I'm specifically looking for something that can't implemented in Python with iterators (at least not elegantly), but can actually be implemented in Haskell. Thanks, Cristiano -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/eec891ed/attachment.html From jeremy at n-heptane.com Thu Jul 9 09:03:51 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Jul 9 08:46:02 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: References: Message-ID: <87ws6iatzc.wl%jeremy@n-heptane.com> Hello, A wonderful, and practical example, is the techniques in this modular lazy search paper: http://web.cecs.pdx.edu/~apt/jfp01.ps They build simple solvers, like backtracking, backjumping, etc. and then compose them together like: bt . bj The techniques are very much based on laziness. - jeremy At Thu, 9 Jul 2009 14:55:09 +0200, Cristiano Paris wrote: > > [1 ] > [1.1 ] > Hi, > I'm wondering what a good example of why laziness enhances composability > would be. > > I'm specifically looking for something that can't implemented in Python with > iterators (at least not elegantly), but can actually be implemented in > Haskell. > > Thanks, > > Cristiano > [1.2 ] > > [2 ] > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From tom.davie at gmail.com Thu Jul 9 09:06:19 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Jul 9 08:48:31 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: References: Message-ID: On 9 Jul 2009, at 14:55, Cristiano Paris wrote: > Hi, > > I'm wondering what a good example of why laziness enhances > composability would be. > > I'm specifically looking for something that can't implemented in > Python with iterators (at least not elegantly), but can actually be > implemented in Haskell. Pretty much anything that uses "tying the knot" is very difficult to implement in a non-lazy language without a lot of indirection. Bob From cristiano.paris at gmail.com Thu Jul 9 09:21:24 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Thu Jul 9 09:03:53 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: References: Message-ID: Thank you for your suggestions! C. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/cf6c8dc4/attachment.html From cristiano.paris at gmail.com Thu Jul 9 09:27:57 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Thu Jul 9 09:11:38 2009 Subject: [Haskell-cafe] Alternative IO Message-ID: As a joke, I wrote an instance of Alternative for IO actions: {-# LANGUAGE ScopedTypeVariables #-} module Main where import Control.Applicative import Control.Exception instance Alternative IO where empty = undefined x <|> y = handle (\ (_ :: SomeException) -> y) x This would allow to write IO code which failsafes to a value if the previous computation failed, i.e.: *Main Control.Applicative> undefined <|> print "Hello" "Hello" *Main Control.Applicative> print "Hello" <|> undefined "Hello" It seems a neat way to catch exception in some scenarios. What do you think? Why is not Alternative IO defined in Control.Applicative? Thanks, Cristiano -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/b4f0145f/attachment.html From tom.davie at gmail.com Thu Jul 9 09:35:06 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Jul 9 09:17:18 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: References: Message-ID: To be honest -- that seems rather nice. Can has in Hackage? Bob On 9 Jul 2009, at 15:27, Cristiano Paris wrote: > As a joke, I wrote an instance of Alternative for IO actions: > > {-# LANGUAGE ScopedTypeVariables #-} > module Main where > > import Control.Applicative > import Control.Exception > > instance Alternative IO where > empty = undefined > x <|> y = handle (\ (_ :: SomeException) -> y) x > > This would allow to write IO code which failsafes to a value if the > previous computation failed, i.e.: > > *Main Control.Applicative> undefined <|> print "Hello" > "Hello" > *Main Control.Applicative> print "Hello" <|> undefined > "Hello" > > It seems a neat way to catch exception in some scenarios. What do > you think? Why is not Alternative IO defined in Control.Applicative? > > Thanks, > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ekmett at gmail.com Thu Jul 9 09:36:51 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Jul 9 09:18:59 2009 Subject: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor) In-Reply-To: <6d942a4a0907071603p6eeb24b0lc8049e6dfe76225a@mail.gmail.com> References: <6d942a4a0907071603p6eeb24b0lc8049e6dfe76225a@mail.gmail.com> Message-ID: <7fb8f82f0907090636s7b5f73b7h4b00aac73c3b5e41@mail.gmail.com> Well, you're going to wind up with a lot of cases where you really want a quantified context, even with just your Functor definition, but in that same spirit you can build an 'Applicative-like' instance as well. > type family Arg f :: * > type instance Arg [a -> b] = [a] > type family Result f :: * > type instance Result [a -> b] = [b] > class Pointed f => Applicative f where > (<*>) :: f -> Arg f -> Result f > instance Applicative [a -> b] where > fs <*> xs = do f <- fs; map f The thing is these definitions are very hard to actually use. I have a similar construction for Foldable/Traversable-like containers in the 'monoids' package as Data.Generator that you might want to look at for ideas. -Edward Kmett On Tue, Jul 7, 2009 at 7:03 PM, George Pollard wrote: > Ok, so I have a small idea I'm trying to work on; call it a > Prelude-rewrite if you want. For this I want to be able to have the > hierarchy Functor ? Applicative ? Monad. > > For Functor, I would like to be able to implement it for a wider > variety of types, as there are types which have aren't polymorphic > which would also benefit from having an instance. > My running example for this set of types is ByteString; the module > contains the method: > > map ? (Word8 ? Word8) ? ByteString ? ByteString > > However, we cannot use this for Functor because ByteString isn't > polymorphic. To get around this, I devised the following: > > Introduce a type family which represents ?points? inside the type: > > type family Point f ? ? > > For ByteString we have: > > type instance Point ByteString = Word8 > > For a polymorphic example (lists) we have: > > type instance Point [a] = a > > Now Functor becomes: > > class SimpleFunctor f where > fmap ? (Point f ? Point f) ? (f ? f) > > However, this doesn't allow for the existence of functions with the > type (a ? b). I need to introduce another type into the class: > > class Functor f g where > fmap ? (Point f ? Point g) ? (f ? g) > > But having two types isn't very nice (for one thing we can't introduce > a fundep because for lists as it fails one of the coverage > conditions), so introduce another type family to represent types which > can be produced by giving a free variable: > > type Subst f a ? ? > type Subst [a] b = [b] > type Subst ByteString b = ByteString > > class Functor f where > fmap ? (Point f ? Point (Subst f a)) ? (f ? Subst f a) > > I'm not sure how much of a hack this is, or if there is a better way. > It seems to be OK... > > Now I want to implement Applicative. It would make sense to have > ?return? be split out into a separate class, because this can be > restricted in a similar way to Functor: > > class Pointed f where > return ? Point f ? f > > instance Pointed [a] where > return x = [x] > > instance Pointed ByteString where > return = BS.singleton > > Now, I want to be able to restrict Applicative to things which have > [Pointed f, and forall a b. Point f ~ (a ? b)]. At the moment I can't > figure this out because I believe it would require something like the > ?quantified contexts? proposal: > > class (Pointed f, ? a b. Point f ~ (a ? b)) ? Applicative f where > ... > > I could have something like: > > class (Pointed f, Point f ~ (a ? b)) ? Applicative f a b where > apply ? f ? Subst f a ? Subst f b > > This is still not very nice, because it requires two more type > variables in the class, and the non-type-families version is far more > straightforward... in fact, it makes sense for the Applicative class > to have a polymorphic type because it must be able to have ?return? > applied to arbitrary functions (remember [fmap f xs ? return f `apply` > xs]). So back to: > > class Applicative f where > apply ? f (a ? b) ? f a ? f b > > But then ?return? cannot be added via a superclass restriction to > Pointed! I seem to have painted myself into a corner. Does anyone see > a better way to go about this? > > Thanks, > - George > _______________________________________________ > 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/20090709/b25d80a8/attachment.html From ekmett at gmail.com Thu Jul 9 09:42:30 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Jul 9 09:24:39 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: References: Message-ID: <7fb8f82f0907090642m225441b7gf2b6fe77f2cc94e1@mail.gmail.com> Hrmm. This should probably be made consistent with the MonadPlus instance for IO, so > empty = ioError (userError "mzero") Otherwse, I'm surprised this isn't already in the standard library. I'd suggest submitting it to libraries@. -Edward Kmett On Thu, Jul 9, 2009 at 9:27 AM, Cristiano Paris wrote: > As a joke, I wrote an instance of Alternative for IO actions: > {-# LANGUAGE ScopedTypeVariables #-} > module Main where > > import Control.Applicative > import Control.Exception > > instance Alternative IO where > empty = undefined > x <|> y = handle (\ (_ :: SomeException) -> y) x > > This would allow to write IO code which failsafes to a value if the > previous computation failed, i.e.: > > *Main Control.Applicative> undefined <|> print "Hello" > "Hello" > *Main Control.Applicative> print "Hello" <|> undefined > "Hello" > > It seems a neat way to catch exception in some scenarios. What do you > think? Why is not Alternative IO defined in Control.Applicative? > > Thanks, > > Cristiano > > _______________________________________________ > 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/20090709/c1ccc5b0/attachment.html From bulat.ziganshin at gmail.com Thu Jul 9 09:42:03 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jul 9 09:29:45 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: References: Message-ID: <316340752.20090709174203@gmail.com> Hello Cristiano, Thursday, July 9, 2009, 4:55:09 PM, you wrote: the best known example is chessmate implementation in Wadler's "why functional programming matter" but i don't know much about Python iterators, so can't say what is difference. may be its' only simplicity since lazy lists is looks like and processed just as lists while generators in any other language is separate data structure > Hi, > I'm wondering what a good example of why laziness enhances composability would be. > I'm specifically looking for something that can't implemented in > Python with iterators (at least not elegantly), but can actually be implemented in Haskell. > > Thanks, > Cristiano > > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From haskell at kudling.de Thu Jul 9 09:54:16 2009 From: haskell at kudling.de (haskell@kudling.de) Date: Thu Jul 9 09:36:24 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage Message-ID: <27288665.1362111247147656059.JavaMail.servlet@kundenserver> Hi, i find the current www.haskell.org frontpage quite overwhelming. Compare it for example with the home pages of other programming languages : http://caml.inria.fr/ http://factorcode.org/ http://sbcl.sourceforge.net/ http://www.ruby-lang.org/en/ http://www.falconpl.org/ Here is my sketch of a leaner, more structured Haskell front page: http://www.haskell.org/haskellwiki/User:Lenny222/Haskell Comments? Bye, Lenny From lemming at henning-thielemann.de Thu Jul 9 10:01:59 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jul 9 09:44:14 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: References: Message-ID: On Thu, 9 Jul 2009, Cristiano Paris wrote: > As a joke, I wrote an instance of Alternative for IO actions: > {-# LANGUAGE ScopedTypeVariables #-} > module Main where > > import Control.Applicative > import Control.Exception > > instance Alternative IO where > ??empty = undefined > ??x <|> y = handle (\ (_ :: SomeException) -> y) x > > This would allow to write IO code which failsafes to a value if the previous > computation failed, i.e.: > > *Main Control.Applicative> undefined <|> print "Hello" > "Hello" > *Main Control.Applicative> print "Hello" <|> undefined > "Hello" > > It seems a neat way to catch exception in some scenarios. What do you think? > Why is not Alternative IO defined in Control.Applicative? I just say, what I always say. :-) 'error' denotes a programming error and "catching" it is a hack, sometimes needed but less often than you think. For exceptions one must use 'throw'. Thus, you may e.g. define empty = throw ... From cristiano.paris at gmail.com Thu Jul 9 10:02:42 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Thu Jul 9 09:45:12 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: <7fb8f82f0907090642m225441b7gf2b6fe77f2cc94e1@mail.gmail.com> References: <7fb8f82f0907090642m225441b7gf2b6fe77f2cc94e1@mail.gmail.com> Message-ID: On Thu, Jul 9, 2009 at 3:42 PM, Edward Kmett wrote: > Hrmm. This should probably be made consistent with the MonadPlus instance > for IO, so > > > empty = ioError (userError "mzero") > I agree. Of course, that was only a first attempt :) Cristiano -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/40e9a5d2/attachment.html From cristiano.paris at gmail.com Thu Jul 9 10:05:43 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Thu Jul 9 09:48:17 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: <316340752.20090709174203@gmail.com> References: <316340752.20090709174203@gmail.com> Message-ID: On Thu, Jul 9, 2009 at 3:42 PM, Bulat Ziganshin wrote: > > Hello Cristiano, > > Thursday, July 9, 2009, 4:55:09 PM, you wrote: > > the best known example is chessmate implementation in Wadler's "why > functional programming matter" > > but i don't know much about Python iterators, so can't say what is > difference. may be its' only simplicity since lazy lists is looks like > and processed just as lists while generators in any other language is > separate data structure Thanks. In fact, I was stuck trying to find an example which couldn't be written using Python's iterators. The only difference coming up to my mind was that Haskell's lists are a more natural way to express a program relying on laziness. That was the reason why added the clause "at least not elegantly" in my first post. Cristiano From noteed at gmail.com Thu Jul 9 10:07:11 2009 From: noteed at gmail.com (minh thu) Date: Thu Jul 9 09:49:41 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <27288665.1362111247147656059.JavaMail.servlet@kundenserver> References: <27288665.1362111247147656059.JavaMail.servlet@kundenserver> Message-ID: <40a414c20907090707h4b0bc8e5y4c0de2f91d12ae7e@mail.gmail.com> 2009/7/9 : > Hi, > > i find the current www.haskell.org frontpage quite overwhelming. > > Compare it for example with the home pages of other programming languages : > http://caml.inria.fr/ > http://factorcode.org/ > http://sbcl.sourceforge.net/ > http://www.ruby-lang.org/en/ > http://www.falconpl.org/ > > > Here is my sketch of a leaner, more structured Haskell front page: > http://www.haskell.org/haskellwiki/User:Lenny222/Haskell > > Comments? My favorite in all these is haskell.org :) I find it very to the point and not overwhelming at all : it's easy to glance over it and find quickly what I want. In fact, the homepage reflects well the language and its community: effective, useful, healthy and joyful. Cheers, Thu From voigt at tcs.inf.tu-dresden.de Thu Jul 9 10:10:08 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Thu Jul 9 09:52:18 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: <316340752.20090709174203@gmail.com> References: <316340752.20090709174203@gmail.com> Message-ID: <4A55FA40.8070204@tcs.inf.tu-dresden.de> Bulat Ziganshin wrote: > Hello Cristiano, > > Thursday, July 9, 2009, 4:55:09 PM, you wrote: > > the best known example is chessmate implementation in Wadler's "why > functional programming matter" Aeh, ... "Wadler's" -> "Hughes'" -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From bulat.ziganshin at gmail.com Thu Jul 9 10:20:51 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jul 9 10:03:48 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <27288665.1362111247147656059.JavaMail.servlet@kundenserver> References: <27288665.1362111247147656059.JavaMail.servlet@kundenserver> Message-ID: <1089350313.20090709182051@gmail.com> Hello haskell, Thursday, July 9, 2009, 5:54:16 PM, you wrote: > i find the current www.haskell.org frontpage quite overwhelming. it's rather frequent topic here :) > Here is my sketch of a leaner, more structured Haskell front page: > http://www.haskell.org/haskellwiki/User:Lenny222/Haskell i like your design. i believe that homepage is used primarily by first-time users and here they will find all they need to understand haskell and start to use it -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From paolo.veronelli at gmail.com Thu Jul 9 10:40:15 2009 From: paolo.veronelli at gmail.com (Paolino) Date: Thu Jul 9 10:22:26 2009 Subject: [Haskell-cafe] iteratee enumHandle Message-ID: I'm testing iteratee. This is the possible bug I've found import Data.Iteratee.IO import Data.Iteratee.Base import Data.Iteratee.Char import System.IO import Control.Exception main = do h <- openFile "mamma23" ReadWriteMode hPutStrLn h "ciao" hSeek h AbsoluteSeek 0 l <- (enumHandle h stream2list :: IO (Iteratee IO String)) >>= run print $ assert (l == "ciao") () assertion failed This aside, I'd like to know if there is a way to use parsec library to make an Iteratee, so if it's possible to make parsec spit out a continuation on EOF, or maybe as in delcont language to capture it. thanks paolino From stircrazynemo at hotmail.com Thu Jul 9 10:48:59 2009 From: stircrazynemo at hotmail.com (ZhangXu) Date: Thu Jul 9 10:31:10 2009 Subject: [Haskell-cafe] About return type Message-ID: _________________________________________________________________ Messenger??????????????????Messenger??? http://im.live.cn/safe/ From haskell at kudling.de Thu Jul 9 10:49:13 2009 From: haskell at kudling.de (haskell@kudling.de) Date: Thu Jul 9 10:31:22 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage Message-ID: <13042855.1372671247150953490.JavaMail.servlet@kundenserver> > I find it very to the point and not overwhelming at all : it's easy to glance over it and find quickly what I want. Thanks for your feedback. Most people feel overwhelmed when confronted with more than 7+-2 items: http://www.smashingmagazine.com/2007/10/09/30-usability-issues-to-be-aware-of/ On the current Haskell frontpage there are over 60 links competing for attention. I am not sure whether we should design interfaces solely with few people having exceptional abilities in mind. This could be understood as a statement about who Haskell is made for in itself. Bye, Lenny From douyaxu at gmail.com Thu Jul 9 10:57:19 2009 From: douyaxu at gmail.com (xu zhang) Date: Thu Jul 9 10:39:29 2009 Subject: [Haskell-cafe] About the return type Message-ID: I have trouble in returning a list of Figures. I want return a type of m (Maybe [Figure IO]), but the type of dv_findFigure is :: a -> Point -> s (Maybe (Figure s)). How can change the code below to get a s (Maybe [Figure s])? Thank you in advance! dv_findFigure :: a -> Point -> s (Maybe (Figures)) fig_contains :: fig -> Point -> m Bool anc :: Point do fs <- dv_getSelFigs dv fs' <- filterM (`fig_contains` anc) fs f <- case fs' of [] -> dv_findFigure dv anc fig : _ -> return $ Just fig case f of Just f' -> tool_dragtrack self f' Nothing -> dv_clearSel dv >> tool_areatrack self Couldn't match expected type `Figure m' against inferred type `[Figure IO]' Expected type: m (Maybe (Figure m)) Inferred type: m (Maybe [Figure IO]) In the expression: return $ Just fs In a case alternative: fig : _ -> return $ Just fs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/b16a7041/attachment.html From jochem at functor.nl Thu Jul 9 11:02:55 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Thu Jul 9 10:45:06 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <13042855.1372671247150953490.JavaMail.servlet@kundenserver> References: <13042855.1372671247150953490.JavaMail.servlet@kundenserver> Message-ID: <4A56069F.40608@functor.nl> haskell@kudling.de wrote: > Most people feel overwhelmed when confronted with more than 7+-2 items: > http://www.smashingmagazine.com/2007/10/09/30-usability-issues-to-be-aware-of/ This refers to the number of items/things people can remember in their short-time memory. This has nothing to do with the maximum number of menu items you should use. There is of course a limit, but there is no reason to limit it to 7+-2. Cheers, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From noteed at gmail.com Thu Jul 9 11:03:09 2009 From: noteed at gmail.com (minh thu) Date: Thu Jul 9 10:45:43 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <13042855.1372671247150953490.JavaMail.servlet@kundenserver> References: <13042855.1372671247150953490.JavaMail.servlet@kundenserver> Message-ID: <40a414c20907090803j1f3575c2tb40735e550ad86dd@mail.gmail.com> 2009/7/9 : >> I find it very to the point and not overwhelming at all : it's easy to > glance over it and find quickly what I want. > > Thanks for your feedback. > > Most people feel overwhelmed when confronted with more than 7+-2 items: > http://www.smashingmagazine.com/2007/10/09/30-usability-issues-to-be-aware-of/ > > On the current Haskell frontpage there are over 60 links competing for attention. > > I am not sure whether we should design interfaces solely with few people having exceptional abilities in mind. This could be understood as a statement about who Haskell is made for in itself. Well, I guess there is room for personnal preference... But I don't find correct to say "60 links competing for attention". You forget to mention the "section titles" and the separation in two columns. You could have said "more than 600 words competing for attention"... I can understand people find it overwhelming, but only *at first sight*. I would make the comparison with a table of content for a book. I've seen book providing a "chapters at a glance" part, just before the real table of content. Glancing a few pages to see the chapter names (that is not paying attention to the sections and subsections) is not very more complicated. For the hompage we're talking about, glancing is even simpler since everything is on the same page and you can scroll it quite easily. I'm not sure hiding a level of the hierarchy of information behind a few clicks make things easier. Please don't be upset by my opinion, it's just that; I've no will to enforce it to anybody :) Cheers, Thu From haskell at kudling.de Thu Jul 9 11:44:49 2009 From: haskell at kudling.de (haskell@kudling.de) Date: Thu Jul 9 11:26:59 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage Message-ID: <24843003.1399111247154289222.JavaMail.servlet@kundenserver> > I've seen book providing a "chapters at a glance" part, just before the real table of content. Such an inverted pyramid is exactly the consequence Nielson draw from the "F shape pattern" (http://www.useit.com/alertbox/reading_pattern.html). And that's my critque: i don't see the most important things there are to be sayed about Haskell in the top left corner. > For the hompage we're talking about, glancing is even simpler since everything is on the same page and you can scroll it quite easily. I don't agree that "everything on one page" makes comprehension easier. > I'm not sure hiding a level of the hierarchy of information behind a few clicks make things easier. That depends on which task we are talking about: - getting an overview of all available information, or - finding exactly what you are looking for I think we should optimize for the latter, where "What is Haskell?" being the most improtant question. From haskell at kudling.de Thu Jul 9 11:53:01 2009 From: haskell at kudling.de (haskell@kudling.de) Date: Thu Jul 9 11:35:10 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage Message-ID: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> I never said we should only expose 7 links. Take for example the task "Find out more about this Haskell i heared about". You would need to scan the right half of the front page and you need to scan the left part of the page. There you need to scan "About", it could be explained under "Why use Haskell?" or "Language definition" or "Haskell in 5 steps" or "Learning Haskell" or "Wiki articles" or "Blog articles and news". Where should i look? I have to scan a lot of text, i have to keep a lot of options in mind and for my taste the load is too much. Be my limit 7 or 20 links. haskell@kudling.de wrote: > Most people feel overwhelmed when confronted with more than 7+-2 items: > http://www.smashingmagazine.com/2007/10/09/30-usability-issues-to-be-aware-of/ This refers to the number of items/things people can remember in their short-time memory. This has nothing to do with the maximum number of menu items you should use. There is of course a limit, but there is no reason to limit it to 7+-2. Cheers, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From ttencate at gmail.com Thu Jul 9 12:32:23 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Thu Jul 9 12:14:31 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> Message-ID: Are there any kind of hard statistics and analytics that we can base this discussion upon? There is always room for improvement, but stumbling around in the dark making blind guesses may not be the best way to go. Although I personally feel that Lenny's proposed page is an improvement, statistics could tell us what actual people actually use the site for. I don't see any tracking code in the page source. Maybe the site admins could install Google Analytics? It's free, easy to install and use, and very informative. (Or some other usage tracker; I merely suggested GA because I use it and know that it works well.) Thomas On Thu, Jul 9, 2009 at 17:53, wrote: > I never said we should only expose 7 links. > > Take for example the task "Find out more about this Haskell i heared about". > > You would need to scan the right half of the front page and you need to scan the left part of the page. There you need to scan "About", it could be explained under "Why use Haskell?" or "Language definition" or "Haskell in 5 steps" or "Learning Haskell" or "Wiki articles" or "Blog articles and news". > > Where should i look? I have to scan a lot of text, i have to keep a lot of options in mind and for my taste the load is too much. Be my limit 7 or 20 links. > > > haskell@kudling.de wrote: >> Most people feel overwhelmed when confronted with more than 7+-2 items: >> > http://www.smashingmagazine.com/2007/10/09/30-usability-issues-to-be-aware-of/ > > This refers to the number of items/things people can remember in their > short-time memory. This has nothing to do with the maximum number of > menu items you should use. There is of course a limit, but there is no > reason to limit it to 7+-2. > > Cheers, > -- > Jochem Berndsen | jochem@functor.nl > GPG: 0xE6FABFAB > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Thu Jul 9 12:33:17 2009 From: dons at galois.com (Don Stewart) Date: Thu Jul 9 12:17:23 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> Message-ID: <20090709163317.GB28909@whirlpool.galois.com> ttencate: > Are there any kind of hard statistics and analytics that we can base > this discussion upon? There is always room for improvement, but > stumbling around in the dark making blind guesses may not be the best > way to go. Although I personally feel that Lenny's proposed page is an > improvement, statistics could tell us what actual people actually use > the site for. FWIW, the current layout is actually based on previous analysis of Popular Pages a few years ago, so that we have O(1) access to key resources. -- Don From jeff at nokrev.com Thu Jul 9 12:38:43 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Thu Jul 9 12:20:53 2009 Subject: [Haskell-cafe] ANN: hsparql, a SPARQL query generator/DSL and client In-Reply-To: <1247131943-sup-704@ausone.inria.fr> References: <1247092071.4864.17.camel@ulysses> <1247131943-sup-704@ausone.inria.fr> Message-ID: <50c1e0910907090938ja219e51pc02441d30d588d9c@mail.gmail.com> On Thu, Jul 9, 2009 at 4:34 AM, Nicolas Pouillard wrote: > I've looked at your DSL and it looks really neat. While reading I was > wondering if GADTs could help having an even nicer query language. To be honest, I really only know the name GADT, I don't really know anything about them. I guess I have a good excuse to go learn them, though, now. :) Jeff Wheeler From noteed at gmail.com Thu Jul 9 12:43:42 2009 From: noteed at gmail.com (minh thu) Date: Thu Jul 9 12:26:10 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <20090709163317.GB28909@whirlpool.galois.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <20090709163317.GB28909@whirlpool.galois.com> Message-ID: <40a414c20907090943j1929f0fncaee16e4ddfdd038@mail.gmail.com> 2009/7/9 Don Stewart : > ttencate: >> Are there any kind of hard statistics and analytics that we can base >> this discussion upon? There is always room for improvement, but >> stumbling around in the dark making blind guesses may not be the best >> way to go. Although I personally feel that Lenny's proposed page is an >> improvement, statistics could tell us what actual people actually use >> the site for. > > FWIW, the current layout is actually based on previous analysis of Popular > Pages a few years ago, so that we have O(1) access to key resources. Wonderful ! Do you mean that if we put every links from haddock on the homepage, we'd have O(1) access to any piece of documentation ? haskell.org is the neatest data structure of functional programming ! Thu From rick.richardson at gmail.com Thu Jul 9 12:47:40 2009 From: rick.richardson at gmail.com (Rick R) Date: Thu Jul 9 12:29:49 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <20090709163317.GB28909@whirlpool.galois.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <20090709163317.GB28909@whirlpool.galois.com> Message-ID: <9810b81b0907090947p700cf76akc8d8e68391422588@mail.gmail.com> I think it would be best if the page were targeted towards newcomers, and not as a jump point for resources. Such a jump page is useful, but not as a homepage. Perhaps haskell.org/linkswould be a better place for such a thing. As an aside, in the current homepage, the Haskell description is outweighed by the link menu on the left. IMO the reader's eyes should move from the title, to the description, then either down or left. Currently my attention is split evenly between the link menu and the title/description, which results in confusion. On Thu, Jul 9, 2009 at 12:33 PM, Don Stewart wrote: > ttencate: > > Are there any kind of hard statistics and analytics that we can base > > this discussion upon? There is always room for improvement, but > > stumbling around in the dark making blind guesses may not be the best > > way to go. Although I personally feel that Lenny's proposed page is an > > improvement, statistics could tell us what actual people actually use > > the site for. > > FWIW, the current layout is actually based on previous analysis of Popular > Pages a few years ago, so that we have O(1) access to key resources. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- "The greatest obstacle to discovering the shape of the earth, the continents, and the oceans was not ignorance but the illusion of knowledge." - Daniel J. Boorstin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/af1d815d/attachment.html From dons at galois.com Thu Jul 9 12:52:06 2009 From: dons at galois.com (Don Stewart) Date: Thu Jul 9 12:36:17 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage Message-ID: <20090709165206.GA29030@whirlpool.galois.com> ttencate: > On Thu, Jul 9, 2009 at 18:33, Don Stewart wrote: > > ttencate: > >> Are there any kind of hard statistics and analytics that we can base > >> this discussion upon? There is always room for improvement, but > >> stumbling around in the dark making blind guesses may not be the best > >> way to go. Although I personally feel that Lenny's proposed page is an > >> improvement, statistics could tell us what actual people actually use > >> the site for. > > Thanks Don, I should have thought of that. It's a start! No matter what we decide, I'd like to advocate for maintaining the RSS feed of Hackage uploads on the front page -- this is what makes the page seem alive and active, and was introduced in response to John Hughes complaining the page was always out of date. (Similar to the Arch Linux package updates: http://www.archlinux.org/) -- Don From bulat.ziganshin at gmail.com Thu Jul 9 12:56:48 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jul 9 12:39:48 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <20090709163317.GB28909@whirlpool.galois.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <20090709163317.GB28909@whirlpool.galois.com> Message-ID: <111343925.20090709205648@gmail.com> Hello Don, Thursday, July 9, 2009, 8:33:17 PM, you wrote: > FWIW, the current layout is actually based on previous analysis of Popular > Pages a few years ago, so that we have O(1) access to key resources. yes, and it means that page is optimized for regular Haskell users what is proposed, though, is to optimize it for newcomers so they will find their way to Haskell so first we need to decide what category of users homepage should be optimized for. who can set up poll? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ttencate at gmail.com Thu Jul 9 13:00:38 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Thu Jul 9 12:42:46 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <20090709165206.GA29030@whirlpool.galois.com> References: <20090709165206.GA29030@whirlpool.galois.com> Message-ID: By the way, the most valuable pixels, right at the top of the page, are wasted on wiki stuff. Compare http://www.haskell.org/ with, for example, http://www.ruby-lang.org/ http://python.org/ If, like the consensus seems to be, the page should be made more friendly to beginners (who are unlikely to want to contribute to the wiki right away), then this should be moved elsewhere, or at the very least made smaller and less obtrusive. Thomas From dons at galois.com Thu Jul 9 12:58:48 2009 From: dons at galois.com (Don Stewart) Date: Thu Jul 9 12:43:02 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <111343925.20090709205648@gmail.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <20090709163317.GB28909@whirlpool.galois.com> <111343925.20090709205648@gmail.com> Message-ID: <20090709165848.GF28909@whirlpool.galois.com> bulat.ziganshin: > Hello Don, > > Thursday, July 9, 2009, 8:33:17 PM, you wrote: > > > FWIW, the current layout is actually based on previous analysis of Popular > > Pages a few years ago, so that we have O(1) access to key resources. > > yes, and it means that page is optimized for regular Haskell users > > what is proposed, though, is to optimize it for newcomers so they will > find their way to Haskell > > so first we need to decide what category of users homepage should be > optimized for. who can set up poll? Perhaps a newbie page can be designed separately first, and hosted concurrently. Then we can offer both: Newbies: http://haskell.org Everything regular users need at fingertips http://dashboard.haskell.org/ A newbie porthole is a great idea. -- Don From bulat.ziganshin at gmail.com Thu Jul 9 13:13:28 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jul 9 12:56:15 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <20090709165848.GF28909@whirlpool.galois.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <20090709163317.GB28909@whirlpool.galois.com> <111343925.20090709205648@gmail.com> <20090709165848.GF28909@whirlpool.galois.com> Message-ID: <1369560605.20090709211328@gmail.com> Hello Don, Thursday, July 9, 2009, 8:58:48 PM, you wrote: > Newbies: > http://haskell.org > Everything regular users need at fingertips > http://dashboard.haskell.org/ yes, my vision is that newbies will go to homepage, from google search or by typing "haskell.org". we cannot expect that they will search for some special newbie page while amateurs have more chances to know about their special page. actually, we probably need to provide link to "O(1) page" at homepage. btw, it's rather close to sitemap page provided at some sites -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dagit at codersbase.com Thu Jul 9 13:31:26 2009 From: dagit at codersbase.com (Jason Dagit) Date: Thu Jul 9 13:13:47 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <20090709165206.GA29030@whirlpool.galois.com> Message-ID: On Thu, Jul 9, 2009 at 10:00 AM, Thomas ten Cate wrote: > By the way, the most valuable pixels, right at the top of the page, > are wasted on wiki stuff. Compare > http://www.haskell.org/ > with, for example, > http://www.ruby-lang.org/ > http://python.org/ The thing I like the most from the ruby page is the top box of content where it starts describing ruby with a "Read more..." link adjacent to a code snippet. Because I doubt anyone will agree on *the one* best code snippet to show people, I think there should/could be a pool of fun snippets and loading the page picks one at random. I have no idea if the wiki engine supports this. I also like the strip of links at the top with things like, "Download", "Community", and so on. Something I think the Haskell page does much better than the other two, is the listing of events and hackage updates. Both of those sections feel "inviting" to me. It makes me curious and I want to explore. The python page looks at least as cluttered as the haskell page. Neither the haskell page or the python page have the same look and feel of the ruby page. I think the shaded/gradient backgrounds actually add a lot to the visual experience. I also like that the boxes have a different bg color for the box title and the box contents. I also like the use of icons on the ruby page. The "Download Ruby" link/box with the download icon is very inviting. I just want to download it, even if I'm not going to use ruby! Perhaps we could have a contest similar to the logo contest but for homepage asthetics redesign. I think the content on the haskell page is great, but the visual style of the presentation could be improved considerably. > > > If, like the consensus seems to be, the page should be made more > friendly to beginners (who are unlikely to want to contribute to the > wiki right away), then this should be moved elsewhere, or at the very > least made smaller and less obtrusive. Optimizing for newcomers seems wise. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/685f6547/attachment.html From marcin.kosiba at gmail.com Thu Jul 9 15:29:40 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Thu Jul 9 15:11:56 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: References: <316340752.20090709174203@gmail.com> Message-ID: <200907092129.43739.marcin.kosiba@gmail.com> On Thursday 09 July 2009, Cristiano Paris wrote: > Thanks. In fact, I was stuck trying to find an example which couldn't > be written using Python's iterators. The only difference coming up to > my mind was that Haskell's lists are a more natural way to express a > program relying on laziness. That was the reason why added the clause > "at least not elegantly" in my first post. Hi, I recently tried writing some code to simulate a certain protocol in Python. I thought I'll go the "smart" way and rely on the Python yield construct to do a CPS transformation of my code. While this worked to a certain extent, composability was a problem, because any sub-procedure which used yield (and thus was an iterator) required being called in a rather inelegant way. 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/20090709/4eee009c/attachment.bin From jefferson.r.heard at gmail.com Thu Jul 9 16:45:46 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Jul 9 16:28:14 2009 Subject: [Haskell-cafe] c2hs confusion with a simple function Message-ID: <4165d3a70907091345xd99f486s85d45071c082cc2c@mail.gmail.com> The c2hs documentation at http://www.cse.unsw.edu.au/~chak/haskell/c2hs/docu/implementing.html#id314947 gives me an example to follow for this case: {#fun notebook_query_tab_label_packing as ^ `(NotebookClass nb, WidgetClass cld)' => {notebook `nb' , widget `cld' , alloca- `Bool' peekBool*, alloca- `Bool' peekBool*, alloca- `PackType' peekEnum*} -> `()'#} so I took the original C binding: void SHPGetInfo(SHPHandle, int*, int*, double*, double*) And wrote a c2hs binding: {#fun SHPGetInfo as getInfo { fromSHPHandle `SHPHandle' , alloca- `Int' , alloca- `Int' , alloca- `Double' , alloca- `Double' } -> `()' #} The error I get: Internal.chs:85:2: Couldn't match expected type `Int' against inferred type `(Ptr b -> IO c) -> IO c' Expected type: IO (Int, Int, Double, Double) Inferred type: IO ((Ptr b -> IO c) -> IO c, (Ptr b1 -> IO c1) -> IO c1, (Ptr b2 -> IO c2) -> IO c2, (Ptr b3 -> IO c3) -> IO c3) In the expression: alloca $ \ a2' -> alloca $ \ a3' -> alloca $ \ a4' -> ... In the expression: let a1' = fromSHPHandle a1 in alloca $ \ a2' -> alloca $ \ a3' -> alloca $ ... I've tried ending it with withCIntConv and withCFloatConv to no avail. The original c2hs file is attached. I'm sure there are many more problems, but this is the one I'm working on at the moemnt... -- Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: Internal.chs Type: application/octet-stream Size: 3634 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/3b467892/Internal-0001.obj From marcin.kosiba at gmail.com Thu Jul 9 16:57:02 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Thu Jul 9 16:39:19 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: References: <200907092129.43739.marcin.kosiba@gmail.com> Message-ID: <200907092257.05201.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/20090709/ac643e12/attachment.bin From derek.a.elkins at gmail.com Thu Jul 9 18:11:18 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Jul 9 17:53:26 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <20090709165206.GA29030@whirlpool.galois.com> Message-ID: <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> On Thu, Jul 9, 2009 at 12:31 PM, Jason Dagit wrote: > > > On Thu, Jul 9, 2009 at 10:00 AM, Thomas ten Cate wrote: >> >> By the way, the most valuable pixels, right at the top of the page, >> are wasted on wiki stuff. Compare >> http://www.haskell.org/ >> with, for example, >> http://www.ruby-lang.org/ >> http://python.org/ > > The thing I like the most from the ruby page is the top box of content where > it starts describing ruby with a "Read more..." link adjacent to a code > snippet.? Because I doubt anyone will agree on *the one* best code snippet > to show people, I think there should/could be a pool of fun snippets and > loading the page picks one at random.? I have no idea if the wiki engine > supports this.? I also like the strip of links at the top with things like, > "Download", "Community", and so on.? Something I think the Haskell page does > much better than the other two, is the listing of events and hackage > updates.? Both of those sections feel "inviting" to me.? It makes me curious > and I want to explore. > > The python page looks at least as cluttered as the haskell page.? Neither > the haskell page or the python page have the same look and feel of the ruby > page.? I think the shaded/gradient backgrounds actually add a lot to the > visual experience.? I also like that the boxes have a different bg color for > the box title and the box contents.? I also like the use of icons on the > ruby page.? The "Download Ruby" link/box with the download icon is very > inviting.? I just want to download it, even if I'm not going to use ruby! > > Perhaps we could have a contest similar to the logo contest but for homepage > asthetics redesign.? I think the content on the haskell page is great, but > the visual style of the presentation could be improved considerably. > >> >> If, like the consensus seems to be, the page should be made more >> friendly to beginners (who are unlikely to want to contribute to the >> wiki right away), then this should be moved elsewhere, or at the very >> least made smaller and less obtrusive. > > Optimizing for newcomers seems wise. > Jason This is what I see when visiting the Ruby page: "DoS vulnerability in BigDecimal" From dagit at codersbase.com Thu Jul 9 18:17:10 2009 From: dagit at codersbase.com (Jason Dagit) Date: Thu Jul 9 17:59:17 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> References: <20090709165206.GA29030@whirlpool.galois.com> <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> Message-ID: On Thu, Jul 9, 2009 at 3:11 PM, Derek Elkins wrote: > On Thu, Jul 9, 2009 at 12:31 PM, Jason Dagit wrote: > > > > > > On Thu, Jul 9, 2009 at 10:00 AM, Thomas ten Cate > wrote: > >> > >> By the way, the most valuable pixels, right at the top of the page, > >> are wasted on wiki stuff. Compare > >> http://www.haskell.org/ > >> with, for example, > >> http://www.ruby-lang.org/ > >> http://python.org/ > > > > The thing I like the most from the ruby page is the top box of content > where > > it starts describing ruby with a "Read more..." link adjacent to a code > > snippet. Because I doubt anyone will agree on *the one* best code > snippet > > to show people, I think there should/could be a pool of fun snippets and > > loading the page picks one at random. I have no idea if the wiki engine > > supports this. I also like the strip of links at the top with things > like, > > "Download", "Community", and so on. Something I think the Haskell page > does > > much better than the other two, is the listing of events and hackage > > updates. Both of those sections feel "inviting" to me. It makes me > curious > > and I want to explore. > > > > The python page looks at least as cluttered as the haskell page. Neither > > the haskell page or the python page have the same look and feel of the > ruby > > page. I think the shaded/gradient backgrounds actually add a lot to the > > visual experience. I also like that the boxes have a different bg color > for > > the box title and the box contents. I also like the use of icons on the > > ruby page. The "Download Ruby" link/box with the download icon is very > > inviting. I just want to download it, even if I'm not going to use ruby! > > > > Perhaps we could have a contest similar to the logo contest but for > homepage > > asthetics redesign. I think the content on the haskell page is great, > but > > the visual style of the presentation could be improved considerably. > > > >> > >> If, like the consensus seems to be, the page should be made more > >> friendly to beginners (who are unlikely to want to contribute to the > >> wiki right away), then this should be moved elsewhere, or at the very > >> least made smaller and less obtrusive. > > > > Optimizing for newcomers seems wise. > > Jason > > This is what I see when visiting the Ruby page: > "DoS vulnerability in BigDecimal" That's true. And I never said we want to copy the ruby community :) In fact, I'd prefer to not be associated with them given the community's blatant unprofessionalism and sexism (cf. CouchDB presentation at a semi-recent ruby conference). I do think their page has more visual appeal though. So other than pointing out the DoS, did you have feedback? Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/24360226/attachment.html From rick.richardson at gmail.com Thu Jul 9 18:17:50 2009 From: rick.richardson at gmail.com (Rick R) Date: Thu Jul 9 17:59:58 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> References: <20090709165206.GA29030@whirlpool.galois.com> <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> Message-ID: <9810b81b0907091517g46d70cadx97a8454d8093957f@mail.gmail.com> IMO, causing a segfault in the interpreter is more than just a DOS vulnerability :) On Thu, Jul 9, 2009 at 6:11 PM, Derek Elkins wrote: > On Thu, Jul 9, 2009 at 12:31 PM, Jason Dagit wrote: > > > > > > On Thu, Jul 9, 2009 at 10:00 AM, Thomas ten Cate > wrote: > >> > >> By the way, the most valuable pixels, right at the top of the page, > >> are wasted on wiki stuff. Compare > >> http://www.haskell.org/ > >> with, for example, > >> http://www.ruby-lang.org/ > >> http://python.org/ > > > > The thing I like the most from the ruby page is the top box of content > where > > it starts describing ruby with a "Read more..." link adjacent to a code > > snippet. Because I doubt anyone will agree on *the one* best code > snippet > > to show people, I think there should/could be a pool of fun snippets and > > loading the page picks one at random. I have no idea if the wiki engine > > supports this. I also like the strip of links at the top with things > like, > > "Download", "Community", and so on. Something I think the Haskell page > does > > much better than the other two, is the listing of events and hackage > > updates. Both of those sections feel "inviting" to me. It makes me > curious > > and I want to explore. > > > > The python page looks at least as cluttered as the haskell page. Neither > > the haskell page or the python page have the same look and feel of the > ruby > > page. I think the shaded/gradient backgrounds actually add a lot to the > > visual experience. I also like that the boxes have a different bg color > for > > the box title and the box contents. I also like the use of icons on the > > ruby page. The "Download Ruby" link/box with the download icon is very > > inviting. I just want to download it, even if I'm not going to use ruby! > > > > Perhaps we could have a contest similar to the logo contest but for > homepage > > asthetics redesign. I think the content on the haskell page is great, > but > > the visual style of the presentation could be improved considerably. > > > >> > >> If, like the consensus seems to be, the page should be made more > >> friendly to beginners (who are unlikely to want to contribute to the > >> wiki right away), then this should be moved elsewhere, or at the very > >> least made smaller and less obtrusive. > > > > Optimizing for newcomers seems wise. > > Jason > > This is what I see when visiting the Ruby page: > "DoS vulnerability in BigDecimal" > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- "The greatest obstacle to discovering the shape of the earth, the continents, and the oceans was not ignorance but the illusion of knowledge." - Daniel J. Boorstin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/30f7e8b0/attachment.html From derek.a.elkins at gmail.com Thu Jul 9 19:12:05 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Jul 9 18:54:12 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <20090709165206.GA29030@whirlpool.galois.com> <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> Message-ID: <61f84eff0907091612h46d47ed7sd965be3446b3857e@mail.gmail.com> On Thu, Jul 9, 2009 at 5:17 PM, Jason Dagit wrote: > > > On Thu, Jul 9, 2009 at 3:11 PM, Derek Elkins > wrote: >> >> On Thu, Jul 9, 2009 at 12:31 PM, Jason Dagit wrote: >> > >> > >> > On Thu, Jul 9, 2009 at 10:00 AM, Thomas ten Cate >> > wrote: >> >> >> >> By the way, the most valuable pixels, right at the top of the page, >> >> are wasted on wiki stuff. Compare >> >> http://www.haskell.org/ >> >> with, for example, >> >> http://www.ruby-lang.org/ >> >> http://python.org/ >> > >> > The thing I like the most from the ruby page is the top box of content >> > where >> > it starts describing ruby with a "Read more..." link adjacent to a code >> > snippet.? Because I doubt anyone will agree on *the one* best code >> > snippet >> > to show people, I think there should/could be a pool of fun snippets and >> > loading the page picks one at random.? I have no idea if the wiki engine >> > supports this.? I also like the strip of links at the top with things >> > like, >> > "Download", "Community", and so on.? Something I think the Haskell page >> > does >> > much better than the other two, is the listing of events and hackage >> > updates.? Both of those sections feel "inviting" to me.? It makes me >> > curious >> > and I want to explore. >> > >> > The python page looks at least as cluttered as the haskell page. >> > Neither >> > the haskell page or the python page have the same look and feel of the >> > ruby >> > page.? I think the shaded/gradient backgrounds actually add a lot to the >> > visual experience.? I also like that the boxes have a different bg color >> > for >> > the box title and the box contents.? I also like the use of icons on the >> > ruby page.? The "Download Ruby" link/box with the download icon is very >> > inviting.? I just want to download it, even if I'm not going to use >> > ruby! >> > >> > Perhaps we could have a contest similar to the logo contest but for >> > homepage >> > asthetics redesign.? I think the content on the haskell page is great, >> > but >> > the visual style of the presentation could be improved considerably. >> > >> >> >> >> If, like the consensus seems to be, the page should be made more >> >> friendly to beginners (who are unlikely to want to contribute to the >> >> wiki right away), then this should be moved elsewhere, or at the very >> >> least made smaller and less obtrusive. >> > >> > Optimizing for newcomers seems wise. >> > Jason >> >> This is what I see when visiting the Ruby page: >> "DoS vulnerability in BigDecimal" > > That's true.? And I never said we want to copy the ruby community :)? In > fact, I'd prefer to not be associated with them given the community's > blatant unprofessionalism and sexism (cf. CouchDB presentation at a > semi-recent ruby conference).? I do think their page has more visual appeal > though.? So other than pointing out the DoS, did you have feedback? I admit it; you caught me. I'm not a newbie and I don't use the front page terribly often, but I do like most of the links that are on it. The Ruby page is certainly prettier, but the layout of the Haskell page is fine in my opinion; the difference is mainly eye-candy. On another topic, I know people have expressed that they have liked the fact that the entire Haskell site is a wiki; this expressing openness and community involvement. I personally don't find the Haskell front page too cluttered and I think most of issue in that vein could be resolved by simply making sure the most important/newbie-oriented links are "above the fold" and appropriately emphasized/categorized as is partially done already. From gue.schmidt at web.de Thu Jul 9 19:12:01 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Jul 9 18:54:27 2009 Subject: [Haskell-cafe] Haskell used for data analysis - OLAP? Message-ID: Hi, I've developed this commercial app in Haskell with all of the business logic coded in SQL with the help of haskelldb. Some of the intermediate results (of queries) I had to manifest in extra tables because the initial query was expensive, the intermediate result would be the "source" data of other queries and queries can't themselves be indexed for further efficient querying. Since the amount of data could become rather large, in-memory processing wasn't an option and I thus chose SQL (Sqlite). The solution works, but still I'm not quite happy about it, since I consider the tables that hold intermediate results fixes. I understand that the financial industry employs Haskell to analyse large data set under complex schemes. I wonder what techniques are employed for that, do they use Haskell to create some sort of OLAPish tools? Do they use Haskell to run complex queries against SQL data warehouses? G?nther From ok at cs.otago.ac.nz Thu Jul 9 20:35:33 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Jul 9 20:17:47 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <24843003.1399111247154289222.JavaMail.servlet@kundenserver> References: <24843003.1399111247154289222.JavaMail.servlet@kundenserver> Message-ID: I like the Haskell page the way it is. The O'Caml web page, is, by comparison, infuriatingly unhelpful. From hellish at comcast.net Thu Jul 9 22:49:14 2009 From: hellish at comcast.net (Echo Nolan) Date: Thu Jul 9 22:31:27 2009 Subject: [Haskell-cafe] iteratee enumHandle In-Reply-To: References: Message-ID: <4A56AC2A.2040207@comcast.net> Hi Paolino. What's happening is reading [Char] uses the Storable instance for Char which is 32-bit. Thus, you get gibberish. The below does what you want, by reading Word8s and converting them. import Control.Exception import Data.Char import Data.Iteratee.IO import Data.Iteratee.Base import Data.Word import System.IO main :: IO () main = do h <- openFile "mamma23" ReadWriteMode hPutStr h "ciao" hSeek h AbsoluteSeek 0 l <- enumHandle h readString >>= run print $ assert (l == "ciao") () -- This is declared on its own so I can give a type signature without making -- any of the above lines unmanageably long. readString :: IterateeG [] Word8 IO String readString = joinI $ mapStream (chr . fromIntegral) stream2list This only works for ASCII, of course. Someone should write some enumerators for the other encodings. Regards, Echo Nolan From jeff at nokrev.com Thu Jul 9 22:58:11 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Thu Jul 9 22:40:19 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <50c1e0910907091957p3eacffb9ge1022ed4f6566b3e@mail.gmail.com> References: <20090709165206.GA29030@whirlpool.galois.com> <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> <61f84eff0907091612h46d47ed7sd965be3446b3857e@mail.gmail.com> <50c1e0910907091957p3eacffb9ge1022ed4f6566b3e@mail.gmail.com> Message-ID: <50c1e0910907091958y52f1aaf6v790a65f4cb0258e6@mail.gmail.com> On Thu, Jul 9, 2009 at 6:12 PM, Derek Elkins wrote: > I'm not a newbie and I don't use the front page terribly often, but I > do like most of the links that are on it. ?The Ruby page is certainly > prettier, but the layout of the Haskell page is fine in my opinion; > the difference is mainly eye-candy. ?On another topic, I know people > have expressed that they have liked the fact that the entire Haskell > site is a wiki; this expressing openness and community involvement. > I personally don't find the Haskell front page too cluttered and I > think most of issue in that vein could be resolved by simply making > sure the most important/newbie-oriented links are "above the fold" and > appropriately emphasized/categorized as is partially done already. I strongly feel that the homepage should be made more newbie friendly, and I think the Ruby page has done this well, disregarding the news section. I suspect most people who like the Ruby page see the "Ruby is..." section as especially effective at introducing the language, and the random snippet is a simple way to show off a bit of code before they dive into a tutorial. Furthermore, the "Download" link is useful, but since GHC can be complicated (and varies by platform), we probably want to include pretty well thought-out instructions behind the link if we include a similar feature. I also quite like the "Participate" box on the Ruby page, which is very inviting. Regarding the current Haskell homepage, I feel the events are given far too high a place on the homepage. Almost no newbies will be interested in these, and most experienced users will know of the events via the mailing lists. The headlines below that deserve significantly more attention, and perhaps should be updated with greater frequency (and dated, and have RSS). The updated package list is fine, I think. The navigation is a bit tricky, in my opinion. To a beginner (that doesn't know what GHC is), the two download links may be confusing, although I suspect most would correctly assume that "Download Haskell" was correct option. The "Find A Library" is a good link, but the Search that follows it is awkward. There are three large search choices for beginners: 1) the search at the top, which confusingly has two submit buttons (with ambiguous differences to a beginner); 2) the Search link near the top of the navigation (which links to an almost empty page that might as well be included at the link's location); and 3) the Search link underneath the About header, which doesn't seem to belong at all. Jeff Wheeler (Sorry, sent this to just Derek at first.) From roconnor at theorem.ca Thu Jul 9 23:26:54 2009 From: roconnor at theorem.ca (roconnor@theorem.ca) Date: Thu Jul 9 23:09:02 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: References: Message-ID: > Max Rabkin wrote: >> On Sat, Jul 4, 2009 at 8:38 PM, Andrew >> Coppin wrote: >> >>> A few reasons: >>> >>> 1. I never knew it existed. ;-) >>> >> >> A good reason. However, it's good to do a quick search over Hackage >> before uploading (or before writing) so you know what's out there. >> >> Also, if you hadn't used an "AC-" prefix, you'd have had a name >> collision. Is there a particular reason why you want your name in the >> package name rather than just the author field? >> I find it amazing that you independently chose to spell colour with a `u'. It makes me feel better about my choice. >>> 2. It's mind-blowingly complex. >>> >> >> Colour *is* complex. Which is why I'm so glad Russell O'Connor did all >> the hard work for me :) >> > > Well, no, because now I'm going to have to spend a few hours trying to > find out what CIE is before I can even use that library. > > I think really it's just aimed at a different problem. It looks like > it's trying to specify actual real-world colours. [It's news to me that > this isn't fundamentally impossible...] I'm only trying to specify > colours on a computer screen. And as we all know, computer screens > aren't calibrated in any way, and the same RGB value looks different on > each display. But then, I'm only trying to write a fractal generator, so > CIE specifications are somewhat overkill here. ;-) You can use by lib without worrying about the CIE. You can use my library without ever importing or using the word CIE. However, the CIE stuff is there for those who need it. Perhaps I (maybe with some help) need to make a tutorial on the haskell wiki to try to make it less intimidating. >>> 3. It doesn't appear to provide arithmetic over colours. >>> >> >> It provides darken, blend and addition (though addition is called >> mappend rather than (+)). signum, abs and fromInteger don't make a >> huge amount of sense for colours. >> > > Yeah, I implemented signum and so forth for colours and vectors, but > they're not particularly meaningful... [Insert remark here about > Haskell's numeric class hierachy.] > > So mappend gives you colour addition [with the perplexing comments about > "gamut", presumably some kind of small mammal?], but there's no > subtraction? No multiplication? No linear blending? Linear blending is done by the affineCombo function. I think the darken function will do what you mean by multiplication Colour subtraction can be done by adding (using mappend) a colour that has been darkend by a factor of (-1). I don't believe there is any demand for a colour subtraction fuction, so I don't have a name for it. I suppose these sorts of questions can be put nicely into a short tutorial on the wiki. >>> 4. It's parameterised over the component type; my library is hard-coded > to >>> specific types for speed. >>> >> >> My feeling would be to trust the specializer until it lets me down. >> Has it let you down in the past? >> > > Heh, my colour library includes a custom floor implementation that talks > to the GHC primops directly because calling floor is too slow... > > [In case that sounds like idle talk, I had a program go from 10 seconds > to less than 1 second just by using this function. There's a few tickets > about it on the GHC Trac.] Certainly speed is an issue that I haven't tackled yet since I don't know too much about how to optimized Haskell code. I was thinking of sprinkling in some SPECIALIZE pragmas and maybe adding some RULES to make operations more effecient. For example we could have a rule to rewrite floor to some sort of GHC specific fast floor function. (Although that rule probably deserves to be in some sort of more general location). Any help in this direction would be appricated (perferably while keeping things as portable as possible). This all being said, the major problem my code solves is doing blending in a linear colour space. This necessarily make converting to non-linear sRGB for output much slower. So for people who want speed over proper blending, then probably AC-Colour is the package they need to reach for. Essentially the two packages do fill different niches! >> BTW, the EasyRaster package looks useful. >> I haven't looked at EasyRaster yet, but I got excited when I saw it announced. :) -- Russell O'Connor ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.'' From wren at freegeek.org Fri Jul 10 01:17:32 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Jul 10 00:59:58 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <24843003.1399111247154289222.JavaMail.servlet@kundenserver> References: <24843003.1399111247154289222.JavaMail.servlet@kundenserver> Message-ID: <4A56CEEC.7080909@freegeek.org> Ignoring the rest of the thread, but jumping in here... haskell@kudling.de wrote: >> For the hompage we're talking about, glancing is even simpler since > everything is on the same page and you can scroll it quite easily. > > I don't agree that "everything on one page" makes comprehension easier. > >> I'm not sure hiding a level of the hierarchy of information behind a > few clicks make things easier. > > That depends on which task we are talking about: > - getting an overview of all available information, or > - finding exactly what you are looking for I agree with minh thu. For the newcomer to the Haskell community the big question is not "what is Haskell?" but rather "I've heard of this Haskell thing, how do I get started?" and "I've tinkered with this Haskell thing, where do I get more?" The biggest thing I dislike about the alternative pages mentioned by the OP is that they fail in this task. Many of those pages are entirely unhelpful on where to go and/or are filled with administrative nonsense only the compiler developers would care about. Those that aren't are so so polished that there's no content left, or if there is it can't be easily discerned from all the other polish (e.g. the Ruby site. *I* know the content there is meaningful, but the presentation has a very corporate who-gives-a-damn flavor to it which dissuades actually reading the page). Certainly changes could be made (e.g. the verbiage of the description paragraph, moving the language choice to the top, minimizing the realestate devoted to the top bar, simplifying the many redundant search boxes/links,...) but I think by and large the page is very good as a portal for new users as well as for experienced community members looking for That One Thing Whatsitcalled. Hiding the TOC content behind links is a sure way to keep people from finding it and reading it. -- Live well, ~wren From wren at freegeek.org Fri Jul 10 01:25:29 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Jul 10 01:07:44 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <9810b81b0907090947p700cf76akc8d8e68391422588@mail.gmail.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <20090709163317.GB28909@whirlpool.galois.com> <9810b81b0907090947p700cf76akc8d8e68391422588@mail.gmail.com> Message-ID: <4A56D0C9.90609@freegeek.org> Rick R wrote: > As an aside, in the current homepage, the Haskell description is outweighed > by the link menu on the left. IMO the reader's eyes should move from the > title, to the description, then either down or left. Currently my attention > is split evenly between the link menu and the title/description, which > results in confusion. This would be (partially) fixed by reducing the whitespace between the title and the description. Our eyes are attracted to whitespaces, so this is one of the key areas that makes or breaks a design. As it stands the description is stranded and has nothing to lead one into it; whereas the sidebar is taller, in bold, in highlight color,... -- Live well, ~wren From wren at freegeek.org Fri Jul 10 01:29:44 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Jul 10 01:11:53 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <20090709165206.GA29030@whirlpool.galois.com> References: <20090709165206.GA29030@whirlpool.galois.com> Message-ID: <4A56D1C8.3030409@freegeek.org> Don Stewart wrote: > ttencate: >> On Thu, Jul 9, 2009 at 18:33, Don Stewart wrote: >>> ttencate: >>>> Are there any kind of hard statistics and analytics that we can base >>>> this discussion upon? There is always room for improvement, but >>>> stumbling around in the dark making blind guesses may not be the best >>>> way to go. Although I personally feel that Lenny's proposed page is an >>>> improvement, statistics could tell us what actual people actually use >>>> the site for. >> Thanks Don, I should have thought of that. It's a start! > > No matter what we decide, I'd like to advocate for maintaining the RSS > feed of Hackage uploads on the front page -- this is what makes the page > seem alive and active, and was introduced in response to John Hughes > complaining the page was always out of date. (Similar to the Arch Linux > package updates: http://www.archlinux.org/) +1. I also like the events listing, since community events tend to be one of the hardest things to get a single concrete listing of. -- Live well, ~wren From roconnor at theorem.ca Fri Jul 10 01:42:15 2009 From: roconnor at theorem.ca (roconnor@theorem.ca) Date: Fri Jul 10 01:24:21 2009 Subject: [Haskell-cafe] Colour tutorial (Was: AC-Vector, AC-Colour and AC-EasyRaster-GTK) In-Reply-To: References: Message-ID: On Thu, 9 Jul 2009, roconnor@theorem.ca wrote: > You can use by lib without worrying about the CIE. You can use my library > without ever importing or using the word CIE. However, the CIE stuff is > there for those who need it. > > Perhaps I (maybe with some help) need to make a tutorial on the haskell wiki > to try to make it less intimidating. Okay, I threw together a quick introduction at . Any changes, comments, corrections, and addtions are welcome. It's a wiki! The word CIE does occur at all in the document. -- Russell O'Connor ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.'' From wren at freegeek.org Fri Jul 10 01:48:58 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Jul 10 01:31:08 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <50c1e0910907091958y52f1aaf6v790a65f4cb0258e6@mail.gmail.com> References: <20090709165206.GA29030@whirlpool.galois.com> <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> <61f84eff0907091612h46d47ed7sd965be3446b3857e@mail.gmail.com> <50c1e0910907091957p3eacffb9ge1022ed4f6566b3e@mail.gmail.com> <50c1e0910907091958y52f1aaf6v790a65f4cb0258e6@mail.gmail.com> Message-ID: <4A56D64A.3010309@freegeek.org> Jeff Wheeler wrote: > I suspect most people who like the Ruby page see the "Ruby > is..." section as especially effective at introducing the language, > and the random snippet is a simple way to show off a bit of code > before they dive into a tutorial. I'll agree that that part is slick. The rest of it I dislike. In particular the whole right column is indicative of link hell where they couldn't just decide on a single way to make links: there's the download button which is different (fine), there're the first two boxes (also fine), there's the third box which is like the first two but has a whole bunch of extraneous text, there's a bullet listing of top projects which looks entirely different, there's a random RSS link which looks different again, and then it flows into the old-posts segment of the main body which is different again, and then we get to the footer links which mirror the header (this one is fine), and then i18n links are different again and relegated to a footnote (which isn't very inviting to non-English natives),... Whereas haskell.org is much more consistent in picking a single style and running with it. There are some things that could be tweaked (why is GHC in bold? can we remove the extra leading line between indented link groups and their heading link?) but it gives a much more coherent and well designed image. -- Live well, ~wren From tom.davie at gmail.com Fri Jul 10 02:14:08 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Jul 10 01:56:17 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> Message-ID: On 9 Jul 2009, at 18:32, Thomas ten Cate wrote: > Are there any kind of hard statistics and analytics that we can base > this discussion upon? There is always room for improvement, but > stumbling around in the dark making blind guesses may not be the best > way to go. Although I personally feel that Lenny's proposed page is an > improvement, statistics could tell us what actual people actually use > the site for. I'm not sure that that's useful. We can (assuming there are statistics) easily find out what the front page *is* used for. But that doesn't necessarily mean that that's what it *should* be used for. In my mind, the front page is for nothing more than enticing people to use Haskell for long enough to look at a second page where all the useful stuff is if you are a haskell programmer. It should include no more than a description of what haskell is, why it's cool, a link to the documentation, a link to a Haskell Platform Dowload and a link to the earlier mentioned "second page". Bob From noteed at gmail.com Fri Jul 10 03:04:25 2009 From: noteed at gmail.com (minh thu) Date: Fri Jul 10 02:46:54 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> Message-ID: <40a414c20907100004g4e651a45m2f66240cfdd518af@mail.gmail.com> 2009/7/10 Thomas Davie : > > On 9 Jul 2009, at 18:32, Thomas ten Cate wrote: > >> Are there any kind of hard statistics and analytics that we can base >> this discussion upon? There is always room for improvement, but >> stumbling around in the dark making blind guesses may not be the best >> way to go. Although I personally feel that Lenny's proposed page is an >> improvement, statistics could tell us what actual people actually use >> the site for. > > I'm not sure that that's useful. We can (assuming there are statistics) > easily find out what the front page *is* used for. But that doesn't > necessarily mean that that's what it *should* be used for. In my mind, the > front page is for nothing more than enticing people to use Haskell for long > enough to look at a second page where all the useful stuff is if you are a > haskell programmer. It should include no more than a description of what > haskell is, why it's cool, a link to the documentation, a link to a Haskell > Platform Dowload and a link to the earlier mentioned "second page". Hi, As said by others, I find that, beside the content you mention, the appearance of a wiki is "inviting", and the Events, Headlines and Recent package updates makes the haskell community looks active and welcoming (which it is). In fact, although it would be even more overwhelming, the titles of the last posts on planet.haskell.org and the Haskell Weekly News could maybe appear... We could even have a "featured package" section where someone give a nice introduction to a new or not well known package. (If it is too much but considered a good idea, a possibility would be to have just a little, although slightly outstanding link beside the package name in the Recent package updates section.) Cheers, Thu From tom at lokhorst.eu Fri Jul 10 03:38:30 2009 From: tom at lokhorst.eu (Tom Lokhorst) Date: Fri Jul 10 03:20:56 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <40a414c20907100004g4e651a45m2f66240cfdd518af@mail.gmail.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <40a414c20907100004g4e651a45m2f66240cfdd518af@mail.gmail.com> Message-ID: <317ca7670907100038m7a1e5548l497aae1e6443abef@mail.gmail.com> > We could even have a "featured package" section... I like that idea! If there's a blog or something (the contents of which are automatically pulled into the wiki/site), then there could be a guest writer each month to write a short post about their favorite (or their own ;-) package on hackage. This would certainly make the site seem more alive (as does that automatic hackage feed, but this would be written by a human). - Tom Lokhorst On Fri, Jul 10, 2009 at 9:04 AM, minh thu wrote: > 2009/7/10 Thomas Davie : >> >> On 9 Jul 2009, at 18:32, Thomas ten Cate wrote: >> >>> Are there any kind of hard statistics and analytics that we can base >>> this discussion upon? There is always room for improvement, but >>> stumbling around in the dark making blind guesses may not be the best >>> way to go. Although I personally feel that Lenny's proposed page is an >>> improvement, statistics could tell us what actual people actually use >>> the site for. >> >> I'm not sure that that's useful. ?We can (assuming there are statistics) >> easily find out what the front page *is* used for. ?But that doesn't >> necessarily mean that that's what it *should* be used for. ?In my mind, the >> front page is for nothing more than enticing people to use Haskell for long >> enough to look at a second page where all the useful stuff is if you are a >> haskell programmer. ?It should include no more than a description of what >> haskell is, why it's cool, a link to the documentation, a link to a Haskell >> Platform Dowload and a link to the earlier mentioned "second page". > > Hi, > > As said by others, I find that, beside the content you mention, the > appearance of a wiki is "inviting", and the Events, Headlines and > Recent package updates makes the haskell community looks active and > welcoming (which it is). > > In fact, although it would be even more overwhelming, the titles of > the last posts on planet.haskell.org and the Haskell Weekly News could > maybe appear... > > We could even have a "featured package" section where someone give a > nice introduction to a new or not well known package. (If it is too > much but considered a good idea, a possibility would be to have just a > little, although slightly outstanding link beside the package name in > the Recent package updates section.) > > Cheers, > Thu > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dav.vire+haskell at gmail.com Fri Jul 10 03:54:46 2009 From: dav.vire+haskell at gmail.com (david48) Date: Fri Jul 10 03:36:52 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? Message-ID: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> Hello all, I made a small program for my factory and I wanted to try to document it using haddock. The thing is, the comments are in French and the resulting html pages are unreadable because the accentuated letters are mangled. It's not acceptable to use HTML entities, as I'd like the comments to remain readable when/if I edit the code. Anyone has had the same problem ? Found a workaround ? Thanks, David. From g9ks157k at acme.softbase.org Fri Jul 10 04:35:15 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 10 04:17:32 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: References: Message-ID: <200907101035.15723.g9ks157k@acme.softbase.org> Am Donnerstag, 9. Juli 2009 15:27 schrieb Cristiano Paris: > As a joke, I wrote an instance of Alternative for IO actions: > {-# LANGUAGE ScopedTypeVariables #-} > module Main where > > import Control.Applicative > import Control.Exception > > instance Alternative IO where > empty = undefined > x <|> y = handle (\ (_ :: SomeException) -> y) x > > This would allow to write IO code which failsafes to a value if the > previous computation failed, i.e.: > > *Main Control.Applicative> undefined <|> print "Hello" > "Hello" > *Main Control.Applicative> print "Hello" <|> undefined > "Hello" > > It seems a neat way to catch exception in some scenarios. What do you > think? Why is not Alternative IO defined in Control.Applicative? > > Thanks, > > Cristiano Hello Cristiano, I fear that this instance doesn?t satisfy required laws. As far as I know, the following equalities should hold: (*>) = (>>) f *> empty = empty empty <|> g = g This implies the following: (f >> empty) <|> g = g But this wouldn?t hold with your instance. (f >> empty) <|> g would cause the side effects of f and of g, while g would (obviously) only cause the side effects of g. If empty would be a real empty, it would have to undo the effects of previous actions (like f above). So an Applicative instance makes sense for STM but not for IO. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Jul 10 04:44:51 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 10 04:26:58 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: References: Message-ID: <200907101044.52078.g9ks157k@acme.softbase.org> Am Freitag, 10. Juli 2009 05:26 schrieb roconnor@theorem.ca: > I find it amazing that you independently chose to spell colour with a `u'. > It makes me feel better about my choice. I have to admit that it makes me unhappy. :-( Why do we use English for identifiers? Because English is the language of computer science. What English should we use? It?s tempting to say, we should use the original English, which is British English. But we should ask again what is the language of computer science. And the language of computer science is American English. To my knowledge, most early developments in computer science had their roots in the US. One consequence of this is that reserved words of programming languages are typically in American English. PASCAL uses ?program?, not ?programme?, and BASIC uses ?COLOR?, not ?COLOUR?. So, in my opinion, Haskell color packages should use the identifier Color, not Colour. By the way, I also write my papers and documentation in American English. Best wishes, Wolfgang (who is neither British nor American) From magnus at therning.org Fri Jul 10 04:55:46 2009 From: magnus at therning.org (Magnus Therning) Date: Fri Jul 10 04:37:53 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> Message-ID: On Fri, Jul 10, 2009 at 8:54 AM, david48 wrote: > Hello all, > > I made a small program for my factory and I wanted to try to document > it using haddock. The thing is, the comments are in French and the > resulting html pages are unreadable because the accentuated letters > are mangled. > > It's not acceptable to use HTML entities, as I'd like the comments to > remain readable when/if I edit the code. > > Anyone has had the same problem ? Found a workaround ? Not that I have any hope of being able to answer your question, but I think it might be useful if you informed us _where_ the characters are mangled. Is it when you view it in a browser, or when you open the Haddock-generated HTML files in a text editor? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From greenrd at greenrd.org Tue Jul 7 08:42:39 2009 From: greenrd at greenrd.org (Robin Green) Date: Fri Jul 10 05:20:23 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <200907101044.52078.g9ks157k@acme.softbase.org> References: <200907101044.52078.g9ks157k@acme.softbase.org> Message-ID: <20090707134239.0cdbc1c2@fedora> On Fri, 10 Jul 2009 10:44:51 +0200 Wolfgang Jeltsch wrote: > PASCAL > uses ?program?, not ?programme?, The word program (as in computer program) is spelled program in both British and American English. -- Robin From frodo at theshire.org Fri Jul 10 05:43:42 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Jul 10 05:26:08 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: <200907092129.43739.marcin.kosiba@gmail.com> References: <316340752.20090709174203@gmail.com> <200907092129.43739.marcin.kosiba@gmail.com> Message-ID: 2009/7/9 Marcin Kosiba : > On Thursday 09 July 2009, Cristiano Paris wrote: >> Thanks. In fact, I was stuck trying to find an example which couldn't >> be written using Python's iterators. The only difference coming up to >> my mind was that Haskell's lists are a more natural way to express a >> program relying on laziness. That was the reason why added the clause >> "at least not elegantly" in my first post. > > Hi, > ? ? ? ?I recently tried writing some code to simulate a certain protocol in Python. > I thought I'll go the "smart" way and rely on the Python yield construct to > do a CPS transformation of my code. > ? ? ? ?While this worked to a certain extent, composability was a problem, because > any sub-procedure which used yield (and thus was an iterator) required being > called in a rather inelegant way. I think I'll investigate Python's Iterator composability. Cristiano From frodo at theshire.org Fri Jul 10 05:45:55 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Jul 10 05:28:21 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: <200907101035.15723.g9ks157k@acme.softbase.org> References: <200907101035.15723.g9ks157k@acme.softbase.org> Message-ID: On Fri, Jul 10, 2009 at 10:35 AM, Wolfgang Jeltsch wrote: > ... > Hello Cristiano, > > I fear that this instance doesn?t satisfy required laws. As far as I know, the > following equalities should hold: > > ? ?(*>) = (>>) > > ? ?f *> empty = empty > > ? ?empty <|> g = g > > This implies the following: > > ? ?(f >> empty) <|> g = g > > But this wouldn?t hold with your instance. (f >> empty) <|> g would cause the > side effects of f and of g, while g would (obviously) only cause the side > effects of g. > > If empty would be a real empty, it would have to undo the effects of previous > actions (like f above). So an Applicative instance makes sense for STM but > not for IO. Thanks. That's an argument :) -- Cristiano From alexey.skladnoy at gmail.com Fri Jul 10 05:55:21 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Fri Jul 10 05:33:37 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> Message-ID: <200907101355.21269.alexey.skladnoy@gmail.com> On ??????? 10 ???? 2009 12:55:46 Magnus Therning wrote: > Not that I have any hope of being able to answer your question, but I > think it might be useful if you informed us where the characters are > mangled. Is it when you view it in a browser, or when you open the > Haddock-generated HTML files in a text editor? Both. I just checked it. Source files were UTF8 encoded and every 2-byte letter converted to 1-byte so nothing could be read. From dav.vire+haskell at gmail.com Fri Jul 10 06:07:17 2009 From: dav.vire+haskell at gmail.com (david48) Date: Fri Jul 10 05:49:24 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> Message-ID: <4c88418c0907100307k59937d25g31bcb75173c3bdc7@mail.gmail.com> On Fri, Jul 10, 2009 at 10:55 AM, Magnus Therning wrote: > On Fri, Jul 10, 2009 at 8:54 AM, david48 wrote: > Not that I have any hope of being able to answer your question, but I > think it might be useful if you informed us _where_ the characters are > mangled. ?Is it when you view it in a browser, or when you open the > Haddock-generated HTML files in a text editor? Sorry for the lack of information. They're mangled both in vim and the browser. For example, in vim ? becomes ^B Thanks, David. From gleb.alexeev at gmail.com Fri Jul 10 07:46:13 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Fri Jul 10 07:28:35 2009 Subject: [Haskell-cafe] Re: Laziness enhances composability: an example In-Reply-To: <200907092257.05201.marcin.kosiba@gmail.com> References: <200907092129.43739.marcin.kosiba@gmail.com> <200907092257.05201.marcin.kosiba@gmail.com> Message-ID: Marcin Kosiba wrote: > Hi, > To illustrate what I meant I'm attaching two examples. In example_1.py I've > written code the way I think would be elegant (but it doesn't work). In > example_2.py I've written code so that it works, but it isn't elegant. > I know I'm abusing Python iterators here. Also, I'm not sure the way to > compose iterators shown in example_2.py is the only option. Actually I'd love > to see a better solution, because it would remove a lot of bloat from my > code ;) > You may want to look at Lua coroutines, which are more powerful than Python iterators. Your example_1.py is very similiar to the example in the Coroutines Tutorial [1]. [1] http://lua-users.org/wiki/CoroutinesTutorial From ttencate at gmail.com Fri Jul 10 09:06:26 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Fri Jul 10 08:48:32 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> Message-ID: I ran a little experiment of my own, using a GHC HEAD build of a week or so ago. Here's a hex dump of my test source, so that we can see that it's really UTF-8. $ od -xc Test.hs 0000000 6f6d 7564 656c 4d20 6961 206e 6877 7265 m o d u l e M a i n w h e r 0000020 0a65 2d0a 202d 207c 7250 6e69 7374 7420 e \n \n - - | P r i n t s t 0000040 6568 7420 7865 2074 4822 6c65 6f6c 7720 h e t e x t " H e l l o w 0000060 726f 646c 2e22 2d0a 202d 6548 6572 7327 o r l d " . \n - - H e r e ' s 0000100 6120 6520 7275 206f 6973 6e67 202c 82e2 a e u r o s i g n , 342 202 0000120 20ac 5528 322b 4130 2943 202c 6e61 2064 254 ( U + 2 0 A C ) , a n d 0000140 6e61 6520 656c 656d 746e 6f2d 2066 6973 a n e l e m e n t - o f s i 0000160 6e67 203a 88e2 208a 5528 322b 3032 2941 g n : 342 210 212 ( U + 2 2 0 A ) 0000200 0a2e 616d 6e69 3a20 203a 4f49 2820 0a29 . \n m a i n : : I O ( ) \n 0000220 616d 6e69 3d20 7020 7475 7453 4c72 206e m a i n = p u t S t r L n 0000240 4822 6c65 6f6c 7720 726f 646c 0a22 " H e l l o w o r l d " \n 0000256 Then I invoked $ haddock -h Test.hs The generated Main.html contains this tag: Firefox picks this up, because in the View menu, Character Encoding is set to UTF-8. Yet, I see the little blocks instead of the characters from my source file! Why? $ od -xc Main.html ... 0003220 6120 6520 7275 206f 6973 6e67 202c 2004 a e u r o s i g n , 004 ... 0003260 6520 656c 656d 746e 6f2d 2066 6973 6e67 e l e m e n t - o f s i g n 0003300 203a 2004 5528 322b 3032 2941 0a2e 2f3c : 004 ( U + 2 2 0 A ) . \n < / It seems that Haddock replaced both characters with a 0x04 (ASCII end-of-transmission) byte! Apparently you've hit a bug in Haddock. Since Haskell source files are UTF-8 by definition, and the HTML file it produces is also UTF-8, this is clearly incorrect behaviour. Thomas From briqueabraque at yahoo.com Fri Jul 10 09:24:51 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Fri Jul 10 09:07:16 2009 Subject: [Haskell-cafe] Mixing C and Haskell code in the same file Message-ID: Is it possible to insert C code directly to, say, .hsc files? I see this construct in ghc user docs: #def ... which should insert definitions, but I could not find examples of usage in Hackage. My goal is to write some cpp macros that build both a C function and its 'foreign import ccall' wrapper in the same file. Thanks for your help, Maur?cio From ithika at gmail.com Fri Jul 10 09:43:17 2009 From: ithika at gmail.com (Dougal Stanton) Date: Fri Jul 10 09:25:23 2009 Subject: [Haskell-cafe] Colour tutorial (Was: AC-Vector, AC-Colour and AC-EasyRaster-GTK) In-Reply-To: References: Message-ID: <2d3641330907100643q554d2306te0cfd8489fc75ac6@mail.gmail.com> On Fri, Jul 10, 2009 at 6:42 AM, wrote: > On Thu, 9 Jul 2009, roconnor@theorem.ca wrote: > >> You can use by lib without worrying about the CIE. ?You can use my library >> without ever importing or using the word CIE. ?However, the CIE stuff is >> there for those who need it. >> >> Perhaps I (maybe with some help) need to make a tutorial on the haskell >> wiki to try to make it less intimidating. > > Okay, I threw together a quick introduction at > . ?Any changes, comments, > corrections, and addtions are welcome. ?It's a wiki! Excellent! I admit to being Quite Baffled by the new terminology when I tried using this library a few months ago. Spent a lot of time on WP trying to find out what everything was! Even something as simple as stating "yes, just use Colour Double" makes the library seem a lot easier to plumb in to other things. A couple of notes: Section 4.2: "Out of gamut channels be clamped to either to the range 0 to 255" <-- some kind of mix-up here Section 5: "Note that\n\nOne should avoid dissolving" has a spurious line break, or an unfinished sentence. Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From marcin.kosiba at gmail.com Fri Jul 10 10:55:59 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Fri Jul 10 10:38:17 2009 Subject: [Haskell-cafe] Re: Laziness enhances composability: an example In-Reply-To: References: <200907092257.05201.marcin.kosiba@gmail.com> Message-ID: <200907101656.05693.marcin.kosiba@gmail.com> On Friday 10 July 2009, Gleb Alexeyev wrote: > Marcin Kosiba wrote: > > Hi, > > To illustrate what I meant I'm attaching two examples. In example_1.py > > I've written code the way I think would be elegant (but it doesn't work). > > In example_2.py I've written code so that it works, but it isn't elegant. > > I know I'm abusing Python iterators here. Also, I'm not sure the way to > > compose iterators shown in example_2.py is the only option. Actually I'd > > love to see a better solution, because it would remove a lot of bloat > > from my code ;) > > You may want to look at Lua coroutines, which are more powerful than > Python iterators. Your example_1.py is very similiar to the example in > the Coroutines Tutorial [1]. > > [1] http://lua-users.org/wiki/CoroutinesTutorial That in turn looks similar to Stackless Python[1], which I've been looking over recently ;) [1] http://www.stackless.com/wiki/Channels 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/20090710/c5df7d62/attachment.bin From r.kelsall at millstream.com Fri Jul 10 11:14:25 2009 From: r.kelsall at millstream.com (Richard Kelsall) Date: Fri Jul 10 10:56:32 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <50c1e0910907091958y52f1aaf6v790a65f4cb0258e6@mail.gmail.com> References: <20090709165206.GA29030@whirlpool.galois.com> <61f84eff0907091511t50610f7i1b4142c3e376c051@mail.gmail.com> <61f84eff0907091612h46d47ed7sd965be3446b3857e@mail.gmail.com> <50c1e0910907091957p3eacffb9ge1022ed4f6566b3e@mail.gmail.com> <50c1e0910907091958y52f1aaf6v790a65f4cb0258e6@mail.gmail.com> Message-ID: <4A575AD1.70003@millstream.com> Jeff Wheeler wrote: ... > Search that follows it is awkward. There are three large search > choices for beginners: 1) the search at the top, which confusingly has > two submit buttons (with ambiguous differences to a beginner); 2) the > Search link near the top of the navigation (which links to an almost > empty page that might as well be included at the link's location); and > 3) the Search link underneath the About header, which doesn't seem to > belong at all. I agree the search aspect could be improved: the MediaWiki software/ database indexing need an upgrade, the Google 'custom search' Haskell logos are out-of-date and having two Google search links seems excessive. Repeating my old search for 'mdo' which started me on this thread http://www.mail-archive.com/haskell-cafe@haskell.org/msg33337.html the box at the top still returns no results, but it is better because it does now suggest looking at this page http://haskell.org/haskellwiki/HaskellWiki:Searching As I understand it the box at the top is built into the wiki software and can be improved by upgrading the MediaWiki version/indexing. (It would be good to report to MediaWiki that the error message should if possible say "Search words of X characters or less are not indexed" when appropriate rather than "Zero results". Maybe the latest version is cleverer.) The two Google links, neither of them added by me, both have old logos and seem to give similar results for 'mdo' except that the first returns results beyond just haskell.org. For this 'mdo' search I can't see any advantage in having two Google search links. Richard. From jvranish at gmail.com Fri Jul 10 11:34:13 2009 From: jvranish at gmail.com (Job Vranish) Date: Fri Jul 10 11:16:20 2009 Subject: [Haskell-cafe] Problems with nested Monads Message-ID: I'm trying to make a function that uses another monadic function inside a preexisting monad, and I'm having trouble. Basically my problem boils down to this. I have three monadic functions with the following types: f :: A -> M B g :: B -> N C h :: C -> M D (M and N are in the monad class) I want a function i where i :: A -> M (N D) the best I can come up with is: i :: A -> M (N (M D)) i a = liftM (liftM h) =<< (return . g) (f a) I'm starting to feel pretty sure that what I'm going for is impossible. Is this the case? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090710/80f98fe4/attachment.html From dons at galois.com Fri Jul 10 12:41:54 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 10 12:26:00 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> Message-ID: <20090710164153.GB1585@whirlpool.galois.com> tom.davie: > > On 9 Jul 2009, at 18:32, Thomas ten Cate wrote: > >> Are there any kind of hard statistics and analytics that we can base >> this discussion upon? There is always room for improvement, but >> stumbling around in the dark making blind guesses may not be the best >> way to go. Although I personally feel that Lenny's proposed page is an >> improvement, statistics could tell us what actual people actually use >> the site for. > > I'm not sure that that's useful. We can (assuming there are statistics) > easily find out what the front page *is* used for. But that doesn't > necessarily mean that that's what it *should* be used for. In my mind, > the front page is for nothing more than enticing people to use Haskell > for long enough to look at a second page where all the useful stuff is if > you are a haskell programmer. It should include no more than a > description of what haskell is, why it's cool, a link to the > documentation, a link to a Haskell Platform Dowload and a link to the > earlier mentioned "second page". Maybe that's actually a new Haskell Platform page you're describing? -- Don From ekmett at gmail.com Fri Jul 10 15:09:48 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Jul 10 14:51:55 2009 Subject: [Haskell-cafe] Problems with nested Monads In-Reply-To: References: Message-ID: <7fb8f82f0907101209q43e45c8ne750b269aeec47f2@mail.gmail.com> The problem you have is that monad composition isn't defined in general. You would need some form of distributive law either for your monads in general, or for your particular monads wrapped around this particular kind of value. What I would look for is a function of the form of one of: distribute :: N (M a) -> M (N a) joinInner :: M (N (M a)) -> M (N a) joinOuter :: N (M (N a)) -> M (N a) that holds for your partiular monads M and N. IIRC Mark P. Jones wrote a paper or a lib back around '93 that used these forms of distributive laws to derive monads from the composition of a monad and a pointed endofunctor. -Edward Kmett On Fri, Jul 10, 2009 at 11:34 AM, Job Vranish wrote: > I'm trying to make a function that uses another monadic function inside a > preexisting monad, and I'm having trouble. > Basically my problem boils down to this. I have three monadic functions > with the following types: > f :: A -> M B > g :: B -> N C > h :: C -> M D > (M and N are in the monad class) > I want a function i where > i :: A -> M (N D) > > the best I can come up with is: > i :: A -> M (N (M D)) > i a = liftM (liftM h) =<< (return . g) (f a) > > I'm starting to feel pretty sure that what I'm going for is impossible. Is > this 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/20090710/a5399fc5/attachment.html From marco-oweber at gmx.de Fri Jul 10 15:51:36 2009 From: marco-oweber at gmx.de (Marc Weber) Date: Fri Jul 10 15:33:44 2009 Subject: [Haskell-cafe] haskell.org: what can be improved causing what efforts? In-Reply-To: Message-ID: <1247162857-sup-5348@nixos> (I wrote this two days ago.. unfortunately I missed that my new client didnt't sent it at all) Not wasting so much space on top for wiki space +1 competition to get a new design: +1, but is it feasable? Is there enough man power to implement it? Moving wiki content again? This is much more work than just embedding a new logo. code snippet: no hello world please. That's not a way to judge a language! But: a random haskell one line snippet with explanation would be cool. If a redesign causes too much work what about adding one eye catcher which everyone who wants to learn haskell will find immediately but won't disturb users who are used to the current design? Eg adding "start learning / tutorial" above "Download Haskell" would be enough. On that page you can tell the new user about everything (irc, mailinglists, ...) Another nice thing which could be done is adding a JS snippet scrolling down some pixpels so that the wiki header gets hidden. My comments about the design focusing on newcomers still preseving current content: current design: | TOP | | left side right side | ================================================================ | LEFT BAR | | | | CONTENT | If you're not used to this kind of "white is important" design you end up reading these words: left side Haskell: great, but nonsense because you are already on this page. Do you ever click on that link? I mean removing part of the url is nearly as fast but less intrusive Wiki community: great. but missplaced. I'd move this link nearby "Download Haskell" ... "Search" on the left Recent changes: (*) Random page: (*) Special pages: (*) [ search ] [Go] [Search]: Why two buttons? What is the difference? eg even netbeans has only one ctrl-i search field for all: types, help, open windowsn right side: Not logged in, _Log in | Help ... "Note: new account creation has been disabled as an anti-spam measure." (*) (*): No newcomer will care about these items. LEFT BAR (navigation) Search: ? A third way to do a search? Search haskell.org: a fourth way to do a search? History of Haskell: Who cares? I'm a new and I want to see wether it's worth learning haskell. I only care about the future! So this item should be below "Future of Haskell" "Learning" is most important. Where to get started ? Don't ask. Just click and start.. So I'd move those items that it looks like this (removing those two searches!) implementations: GHC, hugs, nhc98, UHC, Yhc, jhc, lhc learning: Why use haskell ? Haskell in 5 steps Learning Haskell Books and tutorials Wiki articles Blog articles and news Videos Wikibook Research papers the language: Language definition future history libraries (the user who is looking for libraries has started. he'll find this information because he'll look and pay attention) Standard libraries Hackage library database Applications and libraries Hoogle and Hayoo API search I'd reduce those 6 search only keeping two: SEARCH Site: [ ... ][wiki][go] img dice Code: [ ... ][go] [wiki] is a select allowing to choose a google search) Code: runs both: hayoo and hoogle search img dice = random page Comparison: How do other sites manage to put much content on one page? They only put enough and provide links. Some do even use DHTML. One example is xing ( a German business network ): http://www.buzinkay.net/blog-de/wp-content/uploads/2007/11/screenshot4.jpeg "Neue Mitglieder" = new users "Kontakte meiner Kontakte" = contacts of my contacts You only get a small list of items and can click on "more" Same applies to big companies such as www.gmx.de: They use DHTML and many tabs to hide information and only catch your eye by topics. Also note how the size of items changes (fish-eye like) when moving the cursor above the news items.. (below "Blickpunkt") Don't get me wrong. I don't want the haskell page to look like gmx.de.. But this kind of tab style could be nice: | Events | Headlines | Recent package updates | recent wiki changes | * item * item or Events a) b) c) [+] Headlines a) b) c) [+] Recent Package Updates a) b) c) [+] Do you see that you can make the user be aware of all three headlines without having to scroll? Overall haskell.org is a great resource! Let's the value of its contens, please. Marc Weber From dons at galois.com Fri Jul 10 16:31:52 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 10 16:15:59 2009 Subject: [Haskell-cafe] haskell.org: what can be improved causing what efforts? In-Reply-To: <1247162857-sup-5348@nixos> References: <1247162857-sup-5348@nixos> Message-ID: <20090710203152.GA2559@whirlpool.galois.com> One issue no one has raised yet is how to integrate this with MediaWiki. First we'd need to upgrade our mediawiki instance (which means moving to a new server), and then we'd need a template for the front page with these design features. Someone want to step up to lead such an effort? -- Don marco-oweber: > (I wrote this two days ago.. unfortunately I missed that my new client > didnt't sent it at all) > > Not wasting so much space on top for wiki space > +1 > > competition to get a new design: > +1, but is it feasable? Is there enough man power to implement it? > Moving wiki content again? > This is much more work than just embedding a new logo. > > code snippet: no hello world please. That's not a way to judge a > language! But: a random haskell one line snippet with explanation would > be cool. > > If a redesign causes too much work what about adding one eye catcher which > everyone who wants to learn haskell will find immediately but won't > disturb users who are used to the current design? > Eg adding "start learning / tutorial" above "Download Haskell" > would be enough. On that page you can tell the new user about > everything (irc, mailinglists, ...) > > Another nice thing which could be done is adding a JS snippet scrolling > down some pixpels so that the wiki header gets hidden. > From jjenning at gmail.com Fri Jul 10 17:08:28 2009 From: jjenning at gmail.com (Jared Jennings) Date: Fri Jul 10 16:50:32 2009 Subject: [Haskell-cafe] first project. code reviews? Message-ID: <362bb3ce0907101408t6b227ed8naa251fceaf7c08a2@mail.gmail.com> I've written a parser for OFX 1.x (these are the files you can download from most banks detailing recent account activity). I'm not sure I've written it well. This is my first serious thing in Haskell. (Kudos to the writers of the guide for how to make a new Hackage project! It's brilliant.) http://patch-tag.com/r/ofx1/pullrepo From johan.tibell at gmail.com Fri Jul 10 17:19:58 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Fri Jul 10 17:02:22 2009 Subject: [Haskell-cafe] haskell.org: what can be improved causing what efforts? In-Reply-To: <1247162857-sup-5348@nixos> References: <1247162857-sup-5348@nixos> Message-ID: <90889fe70907101419k57fb331aoce70fb1981f50a96@mail.gmail.com> On Fri, Jul 10, 2009 at 9:51 PM, Marc Weber wrote: > (I wrote this two days ago.. unfortunately I missed that my new client > didnt't sent it at all) > > Not wasting so much space on top for wiki space > +1 > > competition to get a new design: > +1, but is it feasable? Is there enough man power to implement it? > Moving wiki content again? > This is much more work than just embedding a new logo. > > code snippet: no hello world please. That's not a way to judge a > language! But: a random haskell one line snippet with explanation would > be cool. > > If a redesign causes too much work what about adding one eye catcher which > everyone who wants to learn haskell will find immediately but won't > disturb users who are used to the current design? > Eg adding "start learning / tutorial" above "Download Haskell" > would be enough. On that page you can tell the new user about > everything (irc, mailinglists, ...) > Could we get hold of (anonymized) logs for haskell.org and mine them for click pattern so we can be a bit more scientific about what things should be made more prominent in a new design? -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090710/075e6877/attachment.html From dagit at codersbase.com Fri Jul 10 17:20:36 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri Jul 10 17:02:40 2009 Subject: [Haskell-cafe] first project. code reviews? In-Reply-To: <362bb3ce0907101408t6b227ed8naa251fceaf7c08a2@mail.gmail.com> References: <362bb3ce0907101408t6b227ed8naa251fceaf7c08a2@mail.gmail.com> Message-ID: On Fri, Jul 10, 2009 at 2:08 PM, Jared Jennings wrote: > I've written a parser for OFX 1.x (these are the files you can > download from most banks detailing recent account activity). > > I'm not sure I've written it well. This is my first serious thing in > Haskell. At a quick glance I can give some stylistic feedback: * I like to have at least 1 blank line between functions * Add type signatures for top level definitions, this helps later on * More haddocks next to function definitions :) I didn't read your code deeply enough to comment on the way you used things, named stuff, built abstractions, etc. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090710/4cad0fc3/attachment.html From jvranish at gmail.com Fri Jul 10 17:25:55 2009 From: jvranish at gmail.com (Job Vranish) Date: Fri Jul 10 17:07:59 2009 Subject: [Haskell-cafe] Problems with nested Monads In-Reply-To: <7fb8f82f0907101209q43e45c8ne750b269aeec47f2@mail.gmail.com> References: <7fb8f82f0907101209q43e45c8ne750b269aeec47f2@mail.gmail.com> Message-ID: Yeah, I think the problem with my case is that while M is a specific monad (essentially StateT), N can be an arbitrary monad, which I think destroys my changes of making a valid joinInner/joinOuter/distribute. Maybe someday Haskell will infer valid joinInner/joinOuter for simple cases :D Thanks for you help. I'll definitely have to see if I can find that paper. - Job Vranish On Fri, Jul 10, 2009 at 3:09 PM, Edward Kmett wrote: > The problem you have is that monad composition isn't defined in general. > You would need some form of distributive law either for your monads in > general, or for your particular monads wrapped around this particular kind > of value. > > What I would look for is a function of the form of one of: > > distribute :: N (M a) -> M (N a) > joinInner :: M (N (M a)) -> M (N a) > joinOuter :: N (M (N a)) -> M (N a) > > that holds for your partiular monads M and N. > > IIRC Mark P. Jones wrote a paper or a lib back around '93 that used these > forms of distributive laws to derive monads from the composition of a monad > and a pointed endofunctor. > > -Edward Kmett > > On Fri, Jul 10, 2009 at 11:34 AM, Job Vranish wrote: > >> I'm trying to make a function that uses another monadic function inside a >> preexisting monad, and I'm having trouble. >> Basically my problem boils down to this. I have three monadic functions >> with the following types: >> f :: A -> M B >> g :: B -> N C >> h :: C -> M D >> (M and N are in the monad class) >> I want a function i where >> i :: A -> M (N D) >> >> the best I can come up with is: >> i :: A -> M (N (M D)) >> i a = liftM (liftM h) =<< (return . g) (f a) >> >> I'm starting to feel pretty sure that what I'm going for is impossible. Is >> this 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/20090710/49c12dd3/attachment.html From s.clover at gmail.com Fri Jul 10 17:41:58 2009 From: s.clover at gmail.com (Sterling Clover) Date: Fri Jul 10 17:29:19 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: <200907101035.15723.g9ks157k@acme.softbase.org> References: <200907101035.15723.g9ks157k@acme.softbase.org> Message-ID: On Jul 10, 2009, at 4:35 AM, Wolfgang Jeltsch wrote: > > I fear that this instance doesn?t satisfy required laws. As far as > I know, the > following equalities should hold: > > (*>) = (>>) > > f *> empty = empty > > empty <|> g = g > > This implies the following: > > (f >> empty) <|> g = g > > But this wouldn?t hold with your instance. (f >> empty) <|> g would > cause the > side effects of f and of g, while g would (obviously) only cause > the side > effects of g. I think the third equality you provide is too strong (which isn't to say that it might not be the law that people have documented and expect). Lots of useful alternative instances fail it, not least any parser combinator library (such as Parsec) without automatic backtracking. A more realistic law would perhaps be: > (f *> empty) <|> g = f *> g Additionally, the second equality you provide is just wrong. f *> empty = empty is no more true than f *> g = g, which is no more true than f >> g = g, which is obviously not true at all, as putStrLn "Hey There" >> return () obviously /= return () Cheers, Sterl From dan.doel at gmail.com Fri Jul 10 18:16:59 2009 From: dan.doel at gmail.com (Dan Doel) Date: Fri Jul 10 18:09:11 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: <200907101035.15723.g9ks157k@acme.softbase.org> References: <200907101035.15723.g9ks157k@acme.softbase.org> Message-ID: <200907101816.59847.dan.doel@gmail.com> On Friday 10 July 2009 4:35:15 am Wolfgang Jeltsch wrote: > I fear that this instance doesn?t satisfy required laws. As far as I know, > the following equalities should hold: > > (*>) = (>>) > > f *> empty = empty IO already fails at this law, because (f *> empty) is not the same as empty, it is a failing computation with the side effects of f. empty is only a left- zero in the IO monad. > This implies the following: > > (f >> empty) <|> g = g > > But this wouldn?t hold with your instance. (f >> empty) <|> g would cause > the side effects of f and of g, while g would (obviously) only cause the > side effects of g. Of course, this can be seen as a different symptom of the same underlying problem (although if the initial equation for empty held, it'd work). There's been talk before of splitting MonadPlus into multiple classes for choice, which pick and choose which of these sorts of laws apply to each particular class. MonadPlus vs. MonadOrElse is one splitting, for instance, but I can't recall if IO would satisfy all the laws for either.* -- Dan * For instance, you might expect MonadOrElse to satisfy: f <|> g = f OR f <|> g = g but IO will only satisfy: f <|> g = f OR f <|> g = g-with-side-effects-from-f From psujkov at gmail.com Fri Jul 10 18:27:09 2009 From: psujkov at gmail.com (Paul Sujkov) Date: Fri Jul 10 18:09:18 2009 Subject: [Haskell-cafe] [Haskell Cafe] Parsec: buildExpressionParser and parens typecheck problem Message-ID: <9760562b0907101527i3927b740iff0e243e686fabc0@mail.gmail.com> Hi haskellers, I'm trying to use buildExpressionParser parser generator from ParsecExpr module of Parsec ( http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#ParsecExpr). It works well, except for the "parens" token parser ( http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#parens). This code (sample from Expressions part of the manual) typechecks fine: expr :: Parser Integer expr = buildExpressionParser table factor "expression" table = [[op "*" (*) AssocLeft, op "/" div AssocLeft] ,[op "+" (+) AssocLeft, op "-" (-) AssocLeft] ] where op s f assoc = Infix (do{ string s; return f}) assoc factor = do{ char '(' ; x <- expr ; char ')' ; return x } <|> number "simple expression" but if I try to use parens: factor = parens expr <|> number "simple expression" it fails to typecheck: Couldn't match expected type `GenTokenParser s u m' against inferred type `Parser Integer' In the first argument of `parens', namely `expr' In the first argument of `(<|>)', namely `parens expr' In the first argument of `()', namely `parens expr <|> number' Failed, modules loaded: none. the type of expr infers to GenParser Char () Integer, and the expected type for the parens is GenTokenParser s u m (however, manual introduces it with the type CharParser st a expected) It seems pretty weird for me, as there are numerous examples of using parens with the buildExpressionParser (e.g. http://blog.moertel.com/articles/2005/08/27/power-parsing-with-haskell-and-parsec) and nobody comments such an error. I know I'm missing something very simple here, maybe someone could help me with it? Thanks in advace I'm using GHC 6.10.1 and Parsec 3.0.0 -- Regards, Paul Sujkov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090710/de181677/attachment.html From miguelimo38 at yandex.ru Fri Jul 10 18:49:23 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Jul 10 18:32:09 2009 Subject: [Haskell-cafe] Problems with nested Monads In-Reply-To: References: Message-ID: You can do this if D -> M (N D) is a monad itself. I suggest you study monad transformers - may be it's what you really want. On 10 Jul 2009, at 19:34, Job Vranish wrote: > I'm trying to make a function that uses another monadic function > inside a preexisting monad, and I'm having trouble. > Basically my problem boils down to this. I have three monadic > functions with the following types: > f :: A -> M B > g :: B -> N C > h :: C -> M D > (M and N are in the monad class) > I want a function i where > i :: A -> M (N D) > > the best I can come up with is: > i :: A -> M (N (M D)) > i a = liftM (liftM h) =<< (return . g) (f a) > > I'm starting to feel pretty sure that what I'm going for is > impossible. Is this the case? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From simon.clarkstone at gmail.com Fri Jul 10 21:21:09 2009 From: simon.clarkstone at gmail.com (Simon Richard Clarkstone) Date: Fri Jul 10 21:03:11 2009 Subject: [Haskell-cafe] Laziness enhances composability: an example In-Reply-To: References: Message-ID: <4A57E905.4050700@gmail.com> Thomas Davie wrote: > On 9 Jul 2009, at 14:55, Cristiano Paris wrote: >> I'm wondering what a good example of why laziness enhances >> composability would be. >> >> I'm specifically looking for something that can't implemented in >> Python with iterators (at least not elegantly), but can actually be >> implemented in Haskell. > > Pretty much anything that uses "tying the knot" is very difficult to > implement in a non-lazy language without a lot of indirection. I disagree; mutation can work rather well instead. One application I work on has to parse input containing items with forward and backward references using keys into a graph of objects, a classic tying-the-knot problem. However, we are not using a lazy language, so have only one procedure to create or look up the object corresponding to an item, by key. Parsing references to an item will just store the returned address, but parsing the definition of an item will mutate the object to fill in the data. The effect is that all the references end up as pointers to the right objects, and the objects for undefined items end up keeping their default values (caught by later checks). Situations like that make either mutation or laziness very handy, and if one cannot imagine the "tying the knot" technique then mutation looks like the only good way. No wonder people don't "get" pure FP! ;-) -- src/ From mxcantor at gmail.com Fri Jul 10 22:13:50 2009 From: mxcantor at gmail.com (Max Cantor) Date: Fri Jul 10 21:56:01 2009 Subject: [Haskell-cafe] Text.JSON, Speed and Bytestrings Message-ID: <5BB93925-B631-4065-8FFC-A1DC07EEAA28@gmail.com> Hi Cafe, I am using the Text.JSON library to [un]marshall messages passed over the network and was wondering if the speed would be significantly improved by either changing the code or adding a module to implement the same functionality using Bytestrings instead of classical strings? If the consensus is that it would be worth it, I'll look into adding that code.. Thanks, Max From keithshep at gmail.com Fri Jul 10 23:46:02 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Fri Jul 10 23:28:05 2009 Subject: [Haskell-cafe] get cabal info for self? Message-ID: <92e42b740907102046r7e8277d5u9c48e5d54882e402@mail.gmail.com> Is there a way for a cabalized program to get its own info. I'm specifically interested in version info. Thanks Keith -- keithsheppard.name From gwern0 at gmail.com Sat Jul 11 00:10:55 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Jul 10 23:52:58 2009 Subject: [Haskell-cafe] get cabal info for self? In-Reply-To: <92e42b740907102046r7e8277d5u9c48e5d54882e402@mail.gmail.com> References: <92e42b740907102046r7e8277d5u9c48e5d54882e402@mail.gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Fri, Jul 10, 2009 at 11:46 PM, Keith Sheppard wrote: > Is there a way for a cabalized program to get its own info. I'm > specifically interested in version info. > > Thanks > Keith > Sure, via the Paths_* mechanism. For your reference, here's what it looks like for xmonad: module Paths_xmonad ( version, getBinDir, getLibDir, getDataDir, getLibexecDir, getDataFileName ) where import Data.Version (Version(..)) import System.Environment (getEnv) version :: Version version = Version {versionBranch = [0,8,1], versionTags = []} bindir, libdir, datadir, libexecdir :: FilePath bindir = "/home/gwern/bin/bin" libdir = "/home/gwern/bin/lib/xmonad-0.8.1/ghc-6.10.2" datadir = "/home/gwern/bin/share/xmonad-0.8.1" libexecdir = "/home/gwern/bin/libexec" getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath getBinDir = catch (getEnv "xmonad_bindir") (\_ -> return bindir) getLibDir = catch (getEnv "xmonad_libdir") (\_ -> return libdir) getDataDir = catch (getEnv "xmonad_datadir") (\_ -> return datadir) getLibexecDir = catch (getEnv "xmonad_libexecdir") (\_ -> return libexecdir) getDataFileName :: FilePath -> IO FilePath getDataFileName name = do dir <- getDataDir return (dir ++ "/" ++ name) So if you wanted the version number "081", you could do something like 'concatMap show $ versionBranch $ version' - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkpYD98ACgkQvpDo5Pfl1oI6gACZATzqwtJgBFhAl/qo0ZPauqhg zBcAnRdHtv5nFzNAo2Z9ulHdW1DxiJBE =XyEM -----END PGP SIGNATURE----- From wren at freegeek.org Sat Jul 11 00:26:32 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 11 00:08:36 2009 Subject: [Haskell-cafe] Problems with nested Monads In-Reply-To: References: <7fb8f82f0907101209q43e45c8ne750b269aeec47f2@mail.gmail.com> Message-ID: <4A581478.1040902@freegeek.org> Job Vranish wrote: > Yeah, I think the problem with my case is that while M is a specific monad > (essentially StateT), N can be an arbitrary monad, which I think destroys my > changes of making a valid joinInner/joinOuter/distribute. > Maybe someday Haskell will infer valid joinInner/joinOuter for simple cases > :D Another alternative is to define a typeclass DistributesOverM, and provide instances for the particular monads, n, you care about. Just because you can't do it in general doesn't mean you can't do it :) -- Live well, ~wren From jeff at nokrev.com Sat Jul 11 03:35:27 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Sat Jul 11 03:17:32 2009 Subject: [Haskell-cafe] Re: Adding an ignore function to Control.Monad In-Reply-To: <20090711031032.GA3717@whirlpool.galois.com> References: <4A4C2572.60006@isaac.cedarswampstudios.org> <404396ef0907012326j6ca93absa27d01bcf04eafe1@mail.gmail.com> <7fb8f82f0907020100n4a8bc570q60e9550ec57aef0a@mail.gmail.com> <20090702172217.GE27889@whirlpool.galois.com> <5ab17e790907021501o9676fe8yc296c62407976d5c@mail.gmail.com> <20090711031032.GA3717@whirlpool.galois.com> Message-ID: <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> On Fri, Jul 10, 2009 at 10:10 PM, Don Stewart wrote: >> ## Control.Monad.void m a -> m () >> Don Stewart >> Iavor Diatchki For whatever it's worth, I prefer void as well, for the exact reason Don said. Indeed, 'ignore' indicates to me that the argument won't even be evaluated: it'll be ignored, and skipped. But it is, and only part --- the result --- is ignored. What about 'void' with functors? Jeff Wheeler From johan.tibell at gmail.com Sat Jul 11 04:05:15 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Sat Jul 11 03:47:36 2009 Subject: [Haskell-cafe] Re: Adding an ignore function to Control.Monad In-Reply-To: <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> References: <4A4C2572.60006@isaac.cedarswampstudios.org> <404396ef0907012326j6ca93absa27d01bcf04eafe1@mail.gmail.com> <7fb8f82f0907020100n4a8bc570q60e9550ec57aef0a@mail.gmail.com> <20090702172217.GE27889@whirlpool.galois.com> <5ab17e790907021501o9676fe8yc296c62407976d5c@mail.gmail.com> <20090711031032.GA3717@whirlpool.galois.com> <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> Message-ID: <90889fe70907110105v52a72cc1ga45a5cb1fd000216@mail.gmail.com> On Sat, Jul 11, 2009 at 9:35 AM, Jeff Wheeler wrote: > On Fri, Jul 10, 2009 at 10:10 PM, Don Stewart wrote: > > >> ## Control.Monad.void m a -> m () > >> Don Stewart > >> Iavor Diatchki > > For whatever it's worth, I prefer void as well, for the exact reason > Don said. Indeed, 'ignore' indicates to me that the argument won't > even be evaluated: it'll be ignored, and skipped. But it is, and only > part --- the result --- is ignored. > I also think void is clearer than ignore. -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090711/fc777cbc/attachment.html From dan.doel at gmail.com Sat Jul 11 04:17:35 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sat Jul 11 03:59:41 2009 Subject: [Haskell-cafe] Re: Adding an ignore function to Control.Monad In-Reply-To: <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> References: <20090711031032.GA3717@whirlpool.galois.com> <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> Message-ID: <200907110417.35904.dan.doel@gmail.com> On Saturday 11 July 2009 3:35:27 am Jeff Wheeler wrote: > On Fri, Jul 10, 2009 at 10:10 PM, Don Stewart wrote: > >> ## Control.Monad.void m a -> m () > >> Don Stewart > >> Iavor Diatchki > > For whatever it's worth, I prefer void as well, for the exact reason > Don said. Indeed, 'ignore' indicates to me that the argument won't > even be evaluated: it'll be ignored, and skipped. But it is, and only > part --- the result --- is ignored. > > What about 'void' with functors? Perhaps it should be noted that 'void' is sometimes associated with the type: data Void the 'empty' type (which isn't empty in Haskell). In typical catamorphism style, void would be its eliminator: void :: forall a. Void -> a void _ = undefined -- if you're writing Agda -- void () This, doesn't see much use in Haskell, though, so perhaps it's irrelevant. -- Dan From deduktionstheorem at web.de Sat Jul 11 04:25:39 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Sat Jul 11 04:07:47 2009 Subject: [Haskell-cafe] Re: Adding an ignore function to Control.Monad In-Reply-To: <90889fe70907110105v52a72cc1ga45a5cb1fd000216@mail.gmail.com> References: <4A4C2572.60006@isaac.cedarswampstudios.org> <404396ef0907012326j6ca93absa27d01bcf04eafe1@mail.gmail.com> <7fb8f82f0907020100n4a8bc570q60e9550ec57aef0a@mail.gmail.com> <20090702172217.GE27889@whirlpool.galois.com> <5ab17e790907021501o9676fe8yc296c62407976d5c@mail.gmail.com> <20090711031032.GA3717@whirlpool.galois.com> <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> <90889fe70907110105v52a72cc1ga45a5cb1fd000216@mail.gmail.com> Message-ID: <4A584C83.8020300@web.de> Johan Tibell wrote: > [...] > > I also think void is clearer than ignore. So do I. Another point is, that it's familiar from other languages; a function "void f(...)" doesn't return anything but may have an effect on the environment. Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From nenekotan at gmail.com Sat Jul 11 05:57:26 2009 From: nenekotan at gmail.com (Bas van Gijzel) Date: Sat Jul 11 05:39:31 2009 Subject: [Haskell-cafe] [Haskell Cafe] Parsec: buildExpressionParser and parens typecheck problem In-Reply-To: <9760562b0907101527i3927b740iff0e243e686fabc0@mail.gmail.com> References: <9760562b0907101527i3927b740iff0e243e686fabc0@mail.gmail.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: ExpressionsWithLexer.hs Type: application/octet-stream Size: 1578 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090711/e8d18595/ExpressionsWithLexer.obj From malcolm.wallace at cs.york.ac.uk Sat Jul 11 05:58:42 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Sat Jul 11 05:40:46 2009 Subject: [Haskell-cafe] Re: Adding an ignore function to Control.Monad In-Reply-To: <4A584C83.8020300@web.de> References: <4A4C2572.60006@isaac.cedarswampstudios.org> <404396ef0907012326j6ca93absa27d01bcf04eafe1@mail.gmail.com> <7fb8f82f0907020100n4a8bc570q60e9550ec57aef0a@mail.gmail.com> <20090702172217.GE27889@whirlpool.galois.com> <5ab17e790907021501o9676fe8yc296c62407976d5c@mail.gmail.com> <20090711031032.GA3717@whirlpool.galois.com> <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> <90889fe70907110105v52a72cc1ga45a5cb1fd000216@mail.gmail.com> <4A584C83.8020300@web.de> Message-ID: <0EEAB4BD-3C49-45A7-A730-C07BD289BB4A@cs.york.ac.uk> > Johan Tibell wrote: >> [...] >> >> I also think void is clearer than ignore. > > So do I. Another point is, that it's familiar from other languages; a > function "void f(...)" doesn't return anything but may have an > effect on > the environment. +1. Regards, Malcolm From jon.fairbairn at cl.cam.ac.uk Sat Jul 11 06:02:40 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sat Jul 11 05:44:59 2009 Subject: [Haskell-cafe] Re: ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK References: <200907101044.52078.g9ks157k@acme.softbase.org> Message-ID: Wolfgang Jeltsch writes: > Am Freitag, 10. Juli 2009 05:26 schrieb roconnor@theorem.ca: >> I find it amazing that you independently chose to spell colour with a `u'. >> It makes me feel better about my choice. > > I have to admit that it makes me unhappy. :-( > > Why do we use English for identifiers? Because English is the language > of computer science. What English should we use? It?s tempting to say, > we should use the original English, which is British English. But we > should ask again what is the language of computer science. And the > language of computer science is American English. I don't buy that. And don't forget India. > To my knowledge, most early developments in computer science had their roots > in the US. Really? Manchester Mark I, EDSAC I, EDSAC II? Alan Turing, David Wheeler, Maurice Wilkes? To mention a random selection of early ones (leaving aside Konrad Zuse and colleagues and various Russian pioneers on account of not speaking English). > One consequence of this is that reserved words of programming > languages are typically in American English. PASCAL uses ?program?, The use of "program" rather than "programme" in programming was mandated by the IFIP in what I regard as an attempt to act outwith their remit. I've never accepted it. > not ?programme?, and BASIC uses ?COLOR?, not ?COLOUR?. I'm not sure I would use BASIC as an authority for any aspect of programming language design. Going back to the early developments aspect, a high proportion of early work in functional programming was done in Britain and elsewhere in Europe (at a time when Europeans typically preferred British spellings), so perhaps one should recognise that in choosing identifiers. But anyway, where's the harm in a bit of variety? If someone who prefers British spellings originates a package, why get het up about it if they use them in identifiers? I have to put up with American spellings all over the place, so a few British spellings might even up the balance a bit. -- J?n Fairbairn (British, but with a tendency to identify myself as European) From a.biurvOir4 at asuhan.com Sat Jul 11 06:15:53 2009 From: a.biurvOir4 at asuhan.com (Kim-Ee Yeoh) Date: Sat Jul 11 05:57:57 2009 Subject: [Haskell-cafe] Flipping *->*->* kinds, or monadic finally-tagless madness In-Reply-To: <4A4EDB8A.6050102@freegeek.org> References: <24314553.post@talk.nabble.com> <7fb8f82f0907021849m105018cy1651ac7799c2e137@mail.gmail.com> <24326046.post@talk.nabble.com> <4A4EDB8A.6050102@freegeek.org> Message-ID: <24439023.post@talk.nabble.com> >Kim-Ee Yeoh wrote: >> As for fixing the original bug, I've found that the real magic lies >> in the incantation (Y . unY) inserted at the appropriate places. >Aka unsafeCoerce, changing the phantom type |a|. The type of (Y . unY) is (Y . unY) :: forall a b c. Y c a -> Y c b so modulo (Y c), it is indeed unsafeCoerce. >The need to do it is caused by wanting to erase the existential introduced >by Za/MkZa. That's not the primary reason. The earlier version of the code in my original message doesn't use existentials. We still however, need to "wobble" the type via (Y . unY) in order to typecheck. >Depending on what the phantom type is supposed to represent, this may or >may not give the semantics/safety you're after. If you're referring to the safety of the object/target language, then even without any Symantics instances, only type-correct code can compile, thanks to the finally-tagless embedding that "lifts" type-checking in the meta-language (Haskell) into type-checking for the target language. That safety isn't in the least bit compromised. The pretty-printing Symantics instance in question actually type-checks fine without unsafeCoerce or its like when written out without the additional Monad type-class abstraction and Y-Z isomorphism. Translating to the latter was entirely straightforward. Thanks to all who responded. -- View this message in context: http://www.nabble.com/Flipping-*-%3E*-%3E*-kinds%2C-or-monadic-finally-tagless-madness-tp24314553p24439023.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From apfelmus at quantentunnel.de Sat Jul 11 07:20:07 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sat Jul 11 07:02:27 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> Message-ID: Matthias G?rgens wrote: > Thanks. I heard about the hylo-, ana- and catamorphisms before, but > never explicitly used them. Time to get started. You did use them explicitly :) , namely in treeSort = bootstrap partitionOnMedian bootstrap f = Fix . helper . f where helper = fmap (Fix . helper . f) partitionOnMedian :: (Ord a) => (S.Seq a) -> BTreeRaw a (S.Seq a) since bootstrap f = ana f In particular, we have this slight reformulation bootstrap f = helper' where helper = fmap helper' helper' = Fix . helper . f and hence bootstrap f = helper' where helper' = Fix . fmap helper' . f and thus bootstrap f = Fix . fmap (bootstrap f) . f which is the definition of ana f . > And yet another question: One can get the median in deterministic > linear time. For quicksort choosing the median as pivot keeps the O(n > log n) average running time and brings down the expected worst case, > too. Do you know of a (natural) way to combine selecting the median > and doing the quicksort, so that you don't compare unnecessarily? > > The way to de-randomize quickselect is to calculate medians of > medians. I.e. solve the problem for smaller instances first. I > suspect if we follow this strategy with the reified quicksort > call-trees, the de-randomized quicksort will look a lot like > mergesort. Interesting question! (Of which I don't know the answer of. ;) ) I never understood the median of median method because I always thought that it calculates an approximate median of approximate medians, which I now realize is not the case. I concur that there should be something better than "recursively wasting" comparisons in quickselect just for finding the median pivot in quicksort, especially since both are the same algorithm modulo lazy evaluation. Concerning quicksort looking like mergesort, it seems like a good idea to somehow merge the groups of 5 from the median-of-medians calculation. However, there is an important difference between quicksort and mergesort, namely lazy quicksort is able to produce the batch of the first k smallest elements in O(n + k log k) total time [1] while lazy mergesort needs O(n + k log n) total time [2] There is something about quicksort that makes it "better" than mergesort. [1] Proof goes like this: First, quicksort chooses a sublist of smallest items recursively until a list of the smallest k items remains, this takes O(n) time. Then the list consisting of the smallest k items is sorted in ?(k log k). [2] Mergesort builds a tournament tree in ?(n) time and then performs k tournaments that take O(log n) time each, so the the second phase is O(k log n). I need to think about this. Regards, apfelmus -- http://apfelmus.nfshost.com From keithshep at gmail.com Sat Jul 11 09:54:15 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Sat Jul 11 09:36:18 2009 Subject: [Haskell-cafe] get cabal info for self? In-Reply-To: References: <92e42b740907102046r7e8277d5u9c48e5d54882e402@mail.gmail.com> Message-ID: <92e42b740907110654q2938bcbrdc97fe962134301@mail.gmail.com> That's perfect. Thanks! On Sat, Jul 11, 2009 at 12:10 AM, Gwern Branwen wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > On Fri, Jul 10, 2009 at 11:46 PM, Keith Sheppard wrote: >> Is there a way for a cabalized program to get its own info. I'm >> specifically interested in version info. >> >> Thanks >> Keith >> > > Sure, via the Paths_* mechanism. For your reference, here's what it > looks like for xmonad: > > module Paths_xmonad ( > ? ?version, > ? ?getBinDir, getLibDir, getDataDir, getLibexecDir, > ? ?getDataFileName > ?) where > > import Data.Version (Version(..)) > import System.Environment (getEnv) > > version :: Version > version = Version {versionBranch = [0,8,1], versionTags = []} > > bindir, libdir, datadir, libexecdir :: FilePath > > bindir ? ? = "/home/gwern/bin/bin" > libdir ? ? = "/home/gwern/bin/lib/xmonad-0.8.1/ghc-6.10.2" > datadir ? ?= "/home/gwern/bin/share/xmonad-0.8.1" > libexecdir = "/home/gwern/bin/libexec" > > getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath > getBinDir = catch (getEnv "xmonad_bindir") (\_ -> return bindir) > getLibDir = catch (getEnv "xmonad_libdir") (\_ -> return libdir) > getDataDir = catch (getEnv "xmonad_datadir") (\_ -> return datadir) > getLibexecDir = catch (getEnv "xmonad_libexecdir") (\_ -> return libexecdir) > > getDataFileName :: FilePath -> IO FilePath > getDataFileName name = do > ?dir <- getDataDir > ?return (dir ++ "/" ++ name) > > So if you wanted the version number "081", you could do something like > 'concatMap show $ versionBranch $ version' > > - -- > gwern > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEAREKAAYFAkpYD98ACgkQvpDo5Pfl1oI6gACZATzqwtJgBFhAl/qo0ZPauqhg > zBcAnRdHtv5nFzNAo2Z9ulHdW1DxiJBE > =XyEM > -----END PGP SIGNATURE----- > -- keithsheppard.name From derek.a.elkins at gmail.com Sat Jul 11 13:54:09 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Jul 11 13:36:11 2009 Subject: [Haskell-cafe] Colour tutorial (Was: AC-Vector, AC-Colour and AC-EasyRaster-GTK) In-Reply-To: References: Message-ID: <61f84eff0907111054y22332c75h31afadd1ee704e9e@mail.gmail.com> On Fri, Jul 10, 2009 at 12:42 AM, wrote: > On Thu, 9 Jul 2009, roconnor@theorem.ca wrote: > >> You can use by lib without worrying about the CIE. ?You can use my library >> without ever importing or using the word CIE. ?However, the CIE stuff is >> there for those who need it. >> >> Perhaps I (maybe with some help) need to make a tutorial on the haskell >> wiki to try to make it less intimidating. > > Okay, I threw together a quick introduction at > . ?Any changes, comments, > corrections, and addtions are welcome. ?It's a wiki! > > The word CIE does occur at all in the document. I read this and it irks me that opaque is not a monoid homomorphism despite being the natural injection of non-transparent colours into semi-transparent colours with pureColour being the projection back. [Incidentally, you have a typo in pureColour, ac `over` mempty should be ac `over` black or opaque black presumably, or even opaque mempty, which I think was what you were going for, illustrating my point.] It's like defining mappend on Integers as (+) and on Reals as (*); actually, I think this is very close to what is actually happening. From derek.a.elkins at gmail.com Sat Jul 11 14:12:33 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Jul 11 13:54:34 2009 Subject: [Haskell-cafe] Colour tutorial (Was: AC-Vector, AC-Colour and AC-EasyRaster-GTK) In-Reply-To: <61f84eff0907111054y22332c75h31afadd1ee704e9e@mail.gmail.com> References: <61f84eff0907111054y22332c75h31afadd1ee704e9e@mail.gmail.com> Message-ID: <61f84eff0907111112x4c5ab168v2c8bfd3fc234d60@mail.gmail.com> On Sat, Jul 11, 2009 at 12:54 PM, Derek Elkins wrote: > On Fri, Jul 10, 2009 at 12:42 AM, wrote: >> On Thu, 9 Jul 2009, roconnor@theorem.ca wrote: >> >>> You can use by lib without worrying about the CIE. ?You can use my library >>> without ever importing or using the word CIE. ?However, the CIE stuff is >>> there for those who need it. >>> >>> Perhaps I (maybe with some help) need to make a tutorial on the haskell >>> wiki to try to make it less intimidating. >> >> Okay, I threw together a quick introduction at >> . ?Any changes, comments, >> corrections, and addtions are welcome. ?It's a wiki! >> >> The word CIE does occur at all in the document. > > I read this and it irks me that opaque is not a monoid homomorphism > despite being the natural injection of non-transparent colours into > semi-transparent colours with pureColour being the projection back. > [Incidentally, you have a typo in pureColour, ac `over` mempty should > be ac `over` black or opaque black presumably, or even opaque mempty, > which I think was what you were going for, illustrating my point.] > It's like defining mappend on Integers as (+) and on Reals as (*); > actually, I think this is very close to what is actually happening. I'm mistaken about the typo in pureColour, but luckily the mistake just further illustrates my point. From jeremy.yallop at ed.ac.uk Sat Jul 11 14:31:28 2009 From: jeremy.yallop at ed.ac.uk (Jeremy Yallop) Date: Sat Jul 11 14:14:25 2009 Subject: [Haskell-cafe] Type families and polymorphism Message-ID: <4A58DA80.4010902@ed.ac.uk> Why does compiling the following program give an error? > {-# LANGUAGE TypeFamilies, RankNTypes #-} > > type family TF a > > identity :: (forall a. TF a) -> (forall a. TF a) > identity x = x GHC 6.10.3 gives me: Couldn't match expected type `TF a1' against inferred type `TF a' In the expression: x In the definition of `identity': identity x = x -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From uhollerbach at gmail.com Sat Jul 11 15:15:43 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sat Jul 11 14:57:46 2009 Subject: [Haskell-cafe] following up on space leak In-Reply-To: <6d942a4a0907071931o486b3de5ua5130288aee3f0c3@mail.gmail.com> References: <65d7a7e0907040039l35b46a64head5ebcebe519f08@mail.gmail.com> <856033f20907051906j59b0e4a5k7a62679ecaeb3f82@mail.gmail.com> <65d7a7e0907051946g5e51156at9529dcc8480f45c5@mail.gmail.com> <57526e770907051952u80ba639of5fe921e64b2039c@mail.gmail.com> <65d7a7e0907052027q7a16f595w9fa53fcacb8cdaab@mail.gmail.com> <6d942a4a0907071931o486b3de5ua5130288aee3f0c3@mail.gmail.com> Message-ID: <65d7a7e0907111215g79e0d07esa39110357ef5468c@mail.gmail.com> Hi, George, thanks for the pointer, it led me to some interesting reading. Alas, the problem which it solves was already solved, and the unsolved problem didn't yield any further... At this point, I've concluded that my interpreter just simply isn't tail-recursive enough: in the Collatz test case I had originally looked at and mentioned, it seems that no matter what I do the memory usage stays the same. Initially, a significant portion of the usage showed up as one particular function in the interpreter which applies binary numerical operators to a list of numbers. It's a moderately complex function, as it deals with any number of operands, and it takes care of type conversions as well: if I add two integers, I want the result to be an integer; if I add in a float, the result will be a float, etc. In my particular usage in this test case, it was only getting used to increment an integer; so I simplified that, I added an "incr" function to my interpreter and called that instead... now exactly the same amount of memory usage shows up in the cost center labeled "incr" as was previously being used in the more-complex numeric-binary-operator function. I've cut down the interpreter to about a quarter of its original size, now I've got a version that really is only useful for running this Collatz test case, and... it uses exactly the same amount of memory as before. The last thing I tried before giving up was to try and make a more-strict bind operator, I think I wrote that as (!>=) !m !k = m >>= k with appropriate -XBangPatterns added to the compiler options. It passed all the self-tests for the interpreter, so I'm pretty sure I didn't do anything wrong, but it made no difference to the memory usage. So for now I've shelved that problem, I'm looking instead at adding proper continuations to the interpreter. Uwe On 7/7/09, George Pollard wrote: > I believe there might be an elegant solution for this using the `Last` > monoid > From byorgey at seas.upenn.edu Sat Jul 11 15:33:00 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Jul 11 15:15:02 2009 Subject: [Haskell-cafe] About the return type In-Reply-To: References: Message-ID: <20090711193300.GB5960@seas.upenn.edu> On Thu, Jul 09, 2009 at 10:57:19AM -0400, xu zhang wrote: > I have trouble in returning a list of Figures. I want return a type of m > (Maybe [Figure IO]), but the type of dv_findFigure is :: a -> Point -> s > (Maybe (Figure s)). How can change the code below to get a s (Maybe [Figure > s])? > Thank you in advance! > > dv_findFigure :: a -> Point -> s (Maybe (Figures)) > fig_contains :: fig -> Point -> m Bool > anc :: Point > do > fs <- dv_getSelFigs dv > fs' <- filterM (`fig_contains` anc) fs > f <- case fs' of > [] -> dv_findFigure dv anc > fig : _ -> return $ Just fig > case f of > Just f' -> tool_dragtrack self f' > Nothing -> dv_clearSel dv >> tool_areatrack self > > Couldn't match expected type `Figure m' > against inferred type `[Figure IO]' > Expected type: m (Maybe (Figure m)) > Inferred type: m (Maybe [Figure IO]) > In the expression: return $ Just fs > In a case alternative: fig : _ -> return $ Just fs I'm not sure what you're trying to do here, and the code you gave does not match the error message (the error message cites the code 'fig : _ -> return $ Just fs', but the code you gave has a line 'fig : _ -> return $ Just fig'.) If you still need help, can you provide a more detailed explanation of what this code is supposed to do, and an up-to-date version of the code and error message? -Brent From allbery at ece.cmu.edu Sat Jul 11 17:01:35 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Jul 11 16:43:52 2009 Subject: [Haskell-cafe] Type families and polymorphism In-Reply-To: <4A58DA80.4010902@ed.ac.uk> References: <4A58DA80.4010902@ed.ac.uk> Message-ID: <01907326-1B7F-4FDE-8520-15767ACF3B93@ece.cmu.edu> On Jul 11, 2009, at 14:31 , Jeremy Yallop wrote: > Why does compiling the following program give an error? > >> {-# LANGUAGE TypeFamilies, RankNTypes #-} >> >> type family TF a >> >> identity :: (forall a. TF a) -> (forall a. TF a) >> identity x = x The scope of each a is the surrounding parentheses, so the de facto type is TF a -> TF b. Or, put otherwise, you're saying that for *any* type (TF a) you can produce *any* type (TF a) (because of the delimited forall-s), but then the code asserts that they are the same type. -- 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/20090711/9018cfb7/PGP.bin From roma at ro-che.info Sat Jul 11 17:54:13 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Sat Jul 11 17:36:08 2009 Subject: [Haskell-cafe] Type families and polymorphism In-Reply-To: <01907326-1B7F-4FDE-8520-15767ACF3B93@ece.cmu.edu> References: <4A58DA80.4010902@ed.ac.uk> <01907326-1B7F-4FDE-8520-15767ACF3B93@ece.cmu.edu> Message-ID: <20090711215413.GA6321@flit> * Brandon S. Allbery KF8NH [2009-07-11 17:01:35-0400] > On Jul 11, 2009, at 14:31 , Jeremy Yallop wrote: >> Why does compiling the following program give an error? >> >>> {-# LANGUAGE TypeFamilies, RankNTypes #-} >>> >>> type family TF a >>> >>> identity :: (forall a. TF a) -> (forall a. TF a) >>> identity x = x > > > The scope of each a is the surrounding parentheses, so the de facto type > is TF a -> TF b. Or, put otherwise, you're saying that for *any* type (TF > a) No, for any (forall a. TF a), which should make the difference. > you can produce *any* type (TF a) (because of the delimited forall-s), > but then the code asserts that they are the same type. -- 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 Jul 11 18:24:34 2009 From: dons at galois.com (Don Stewart) Date: Sat Jul 11 18:08:34 2009 Subject: [Haskell-cafe] Text.JSON, Speed and Bytestrings In-Reply-To: <5BB93925-B631-4065-8FFC-A1DC07EEAA28@gmail.com> References: <5BB93925-B631-4065-8FFC-A1DC07EEAA28@gmail.com> Message-ID: <20090711222434.GC7280@whirlpool.galois.com> mxcantor: > Hi Cafe, > > I am using the Text.JSON library to [un]marshall messages passed over > the network and was wondering if the speed would be significantly > improved by either changing the code or adding a module to implement the > same functionality using Bytestrings instead of classical strings? If > the consensus is that it would be worth it, I'll look into adding that > code.. > I think porting the parsec-based JSON parser in the json package to attoparsec + bytestrings would be easy and useful. -- Don From dan.doel at gmail.com Sat Jul 11 18:48:20 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sat Jul 11 18:30:25 2009 Subject: [Haskell-cafe] Type families and polymorphism In-Reply-To: <4A58DA80.4010902@ed.ac.uk> References: <4A58DA80.4010902@ed.ac.uk> Message-ID: <200907111848.20598.dan.doel@gmail.com> On Saturday 11 July 2009 2:31:28 pm Jeremy Yallop wrote: > Why does compiling the following program give an error? > > > {-# LANGUAGE TypeFamilies, RankNTypes #-} > > > > type family TF a > > > > identity :: (forall a. TF a) -> (forall a. TF a) > > identity x = x > > GHC 6.10.3 gives me: > > Couldn't match expected type `TF a1' against inferred type `TF a' > In the expression: x > In the definition of `identity': identity x = x It has to do with the way that type families are checked, and the fact that they aren't guaranteed to be injective. You can massage the type to look like: identity :: forall b. (forall a. TF a) -> TF b Which means that the caller gives us a 'b' and a 'forall a. TF a', and wants us to return a 'TF b'. That sounds fine, but when GHC goes to check things, things go awry. It instantiates things something like... x :: TF c (for some fresh c) TF c ~ TF b (this constraint must be solved for the return type to work) However, since type families aren't necessarily injective, it can't deduce c ~ b since there might well be distinct 'b' and 'c' such that 'TF b ~ TF c'. So, it fails to come to the conclusion that: x :: TF b which is what is actually needed for the function as a whole to type. Thus, checking fails. I think that's a reasonably accurate description of the process; if not someone will probably correct me. One could imagine extensions to solve this. For instance, if you could (optionally) do something like: identity@b x = x@b to specifically apply the type variables, the compiler might have an easier time accepting such things. You can fake it now by having non-family types fix the variable: data Witness a -- = W -- if you don't like empty types identity :: (forall a. Witness a -> TF a) -> (forall a. Witness a -> TF a) identity x w = x w This will be accepted, because inference/checking for Witness provides enough information to deduce the 'c ~ b' above. But of course, it's somewhat less than ideal. Hope that helps. -- Dan From bertram.felgenhauer at googlemail.com Sun Jul 12 03:51:04 2009 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sun Jul 12 03:33:10 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: <20090706192637.GA19982@pudlak.name> References: <20090706192637.GA19982@pudlak.name> Message-ID: <4a5995eb.0a1ad00a.3577.ffffe345@mx.google.com> Petr Pudlak wrote: > Would it be possible to create a lazy selection/sorting > algorithm so that getting any element of the sorted list/array by its index > would require just O(n) time, and getting all the elements would still be in > O(n * log n)? The (merge) sorting algorithm provided by Data.List has this property, providing the first k elements in O(n + k log(n)) time. (source at [1]) As a mental model, you can think of suspended 'merge' evaluations as internal nodes in a tree, with the two arguments as subtrees. In that model, the algorithm turns into heap sort: It builds a balanced binary tree with n external nodes, taking O(n) time -- this job is done by merge_pairs -- and then repeatedly extracts the minimum element, taking O(log(n)) time for each one. regards, Bertram [1] http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/Data-List.html#mergesort From magnus at therning.org Sun Jul 12 04:12:01 2009 From: magnus at therning.org (Magnus Therning) Date: Sun Jul 12 03:54:09 2009 Subject: [Haskell-cafe] Re: Adding an ignore function to Control.Monad In-Reply-To: <4A584C83.8020300@web.de> References: <4A4C2572.60006@isaac.cedarswampstudios.org> <404396ef0907012326j6ca93absa27d01bcf04eafe1@mail.gmail.com> <7fb8f82f0907020100n4a8bc570q60e9550ec57aef0a@mail.gmail.com> <20090702172217.GE27889@whirlpool.galois.com> <5ab17e790907021501o9676fe8yc296c62407976d5c@mail.gmail.com> <20090711031032.GA3717@whirlpool.galois.com> <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> <90889fe70907110105v52a72cc1ga45a5cb1fd000216@mail.gmail.com> <4A584C83.8020300@web.de> Message-ID: <4A599AD1.1080403@therning.org> Stephan Friedrichs wrote: > Johan Tibell wrote: >> [...] >> >> I also think void is clearer than ignore. > > So do I. Another point is, that it's familiar from other languages; a > function "void f(...)" doesn't return anything but may have an effect on the > environment. That depends on what languages you are familiar with, of course. To me void is a type (C/C++) while ignore is a function (OCaml) ;-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090712/06173080/signature.bin From bulat.ziganshin at gmail.com Sun Jul 12 04:25:52 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Jul 12 04:15:42 2009 Subject: [Haskell-cafe] Re: Adding an ignore function to Control.Monad In-Reply-To: <4A599AD1.1080403@therning.org> References: <4A4C2572.60006@isaac.cedarswampstudios.org> <404396ef0907012326j6ca93absa27d01bcf04eafe1@mail.gmail.com> <7fb8f82f0907020100n4a8bc570q60e9550ec57aef0a@mail.gmail.com> <20090702172217.GE27889@whirlpool.galois.com> <5ab17e790907021501o9676fe8yc296c62407976d5c@mail.gmail.com> <20090711031032.GA3717@whirlpool.galois.com> <50c1e0910907110035k4253661cnf8119018737e3a0f@mail.gmail.com> <90889fe70907110105v52a72cc1ga45a5cb1fd000216@mail.gmail.com> <4A584C83.8020300@web.de> <4A599AD1.1080403@therning.org> Message-ID: <1016791730.20090712122552@gmail.com> Hello Magnus, Sunday, July 12, 2009, 12:12:01 PM, you wrote: > That depends on what languages you are familiar with, of course. To me void > is a type (C/C++) while ignore is a function (OCaml) ;-) you can write "(void)" :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From shinnonoir at gmail.com Sun Jul 12 05:03:35 2009 From: shinnonoir at gmail.com (Raynor Vliegendhart) Date: Sun Jul 12 04:45:35 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> Message-ID: <6d961e560907120203h44d37bf4ibc9febe0356c636f@mail.gmail.com> On 7/9/09, Heinrich Apfelmus wrote: > > Of course, some part of algorithm has to be recursive, but this can be > outsourced to a general recursion scheme, like the hylomorphism > > hylo :: Functor f => (a -> f a) -> (f b -> b) -> (a -> b) > hylo f g = g . fmap (hylo f g) . f > Is that definition of hylo actually usuable? A few on IRC tried to use that definition for a few examples, but the examples failed to terminate or blew up the stack. From bertram.felgenhauer at googlemail.com Sun Jul 12 05:03:35 2009 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sun Jul 12 04:45:43 2009 Subject: [Haskell-cafe] Type families and polymorphism In-Reply-To: <4A58DA80.4010902@ed.ac.uk> References: <4A58DA80.4010902@ed.ac.uk> Message-ID: <4a59a6ea.0508d00a.3210.fffff090@mx.google.com> Jeremy Yallop wrote: > Why does compiling the following program give an error? > >> {-# LANGUAGE TypeFamilies, RankNTypes #-} >> >> type family TF a >> >> identity :: (forall a. TF a) -> (forall a. TF a) >> identity x = x > > GHC 6.10.3 gives me: > > Couldn't match expected type `TF a1' against inferred type `TF a' > In the expression: x > In the definition of `identity': identity x = x The error message is slightly better in GHC head: Couldn't match expected type `TF a1' against inferred type `TF a' NB: `TF' is a type function, and may not be injective In the expression: x In the definition of `identity': identity x = x Dan Doel already explained how the lack of injectivity leads to a type checking error. FWIW, the same code would work with a data family, because data families are injective. regards, Bertram From ekmett at gmail.com Sun Jul 12 08:49:50 2009 From: ekmett at gmail.com (Edward Kmett) Date: Sun Jul 12 08:31:50 2009 Subject: [Haskell-cafe] Haskell used for data analysis - OLAP? In-Reply-To: References: Message-ID: <7fb8f82f0907120549o393ac6c6n4f3febb796ea783f@mail.gmail.com> 2009/7/9 G?nther Schmidt > Hi, > > I've developed this commercial app in Haskell with all of the business > logic coded in SQL with the help of haskelldb. Some of the intermediate > results (of queries) I had to manifest in extra tables because the initial > query was expensive, the intermediate result would be the "source" data of > other queries and queries can't themselves be indexed for further efficient > querying. Since the amount of data could become rather large, in-memory > processing wasn't an option and I thus chose SQL (Sqlite). > > The solution works, but still I'm not quite happy about it, since I > consider the tables that hold intermediate results fixes. > > I understand that the financial industry employs Haskell to analyse large > data set under complex schemes. I wonder what techniques are employed for > that, do they use Haskell to create some sort of OLAPish tools? Do they use > Haskell to run complex queries against SQL data warehouses? > > G?nther > A couple of years back when I was forced to learn MDX in excruciating detail, I wound up building a little Haskell DSL for manipulating small OLAP-like datasets; I never really liked the API though, and the embedding was pretty weak, because there wasn't much middle ground between getting almost no type protection and having to keep a bunch of HLists around to make sure you don't reuse a dimension attribute in a query incorrectly. As for interfacing with 3rd party OLAP cubes, I haven't heard of anyone having been masochistic enough to build an interface to something like ADO MD from Haskell. -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090712/e3687a09/attachment.html From hjgtuyl at chello.nl Sun Jul 12 09:05:15 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sun Jul 12 08:47:14 2009 Subject: [Haskell-cafe] Mixing C and Haskell code in the same file In-Reply-To: References: Message-ID: On Fri, 10 Jul 2009 15:24:51 +0200, Maur??cio wrote: > Is it possible to insert C code directly to, say, > .hsc files? I see this construct in ghc user docs: I think you can find your answer here: http://www.haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html -- Reagrds, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From mxcantor at gmail.com Sun Jul 12 11:22:30 2009 From: mxcantor at gmail.com (Max Cantor) Date: Sun Jul 12 11:04:37 2009 Subject: [Haskell-cafe] Goldman Sachs - your home for OCaml and Erlang? Message-ID: I know that this is a bit off topic, but thought it would interest several readers. Apparently, GS, which. AFAIK, doesn't make a lot of noise in the FP space compared to some other banks, does use some FP: http://www.zerohedge.com/article/aleynikov-code-dump-uncovered From apfelmus at quantentunnel.de Sun Jul 12 11:26:55 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sun Jul 12 11:08:52 2009 Subject: [Haskell-cafe] Re: excercise - a completely lazy sorting algorithm In-Reply-To: <6d961e560907120203h44d37bf4ibc9febe0356c636f@mail.gmail.com> References: <20090706192637.GA19982@pudlak.name> <6d961e560907120203h44d37bf4ibc9febe0356c636f@mail.gmail.com> Message-ID: Raynor Vliegendhart wrote: > On 7/9/09, Heinrich Apfelmus wrote: >> Of course, some part of algorithm has to be recursive, but this can be >> outsourced to a general recursion scheme, like the hylomorphism >> >> hylo :: Functor f => (a -> f a) -> (f b -> b) -> (a -> b) >> hylo f g = g . fmap (hylo f g) . f >> > > Is that definition of hylo actually usable? A few on IRC tried to use > that definition for a few examples, but the examples failed to > terminate or blew up the stack. The implementation of quicksort with hylo works fine for me, given medium sized inputs like for example quicksort (reverse [1..1000]) . What were the examples you tried? Regards, apfelmus -- http://apfelmus.nfshost.com From byorgey at seas.upenn.edu Sun Jul 12 12:08:04 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sun Jul 12 11:50:04 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 125 - July 12, 2009 Message-ID: <20090712160804.GA31474@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090712 Issue 125 - July 12, 2009 --------------------------------------------------------------------------- Welcome to issue 125 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements Announcing the new Haskell Prime process, and Haskell 2010. Simon Marlow [2]announced the new and improved [3]Haskell Prime process, and a list of proposals which are currently under consideration to be accepted into the next (2010) revision of the standard. AspectAG 0.1.1. Marcos Viera [4]announced the release of [5]AspectAG, a library of strongly typed Attribute Grammars implemented using type-level programming. Colour tutorial. Russell O'Connor [6]announced a [7]tutorial wiki page for the [8]colour library. Haskell Hack Day, Edinburgh, 30 August 2009. Eric Kow [9]announced a [10]Haskell Hack Day to be held in Edinburgh, on Sunday 30 August, before ICFP. The Hack Day will be held at the ICFP conference venue, the Royal College of Physicians. sendfile-0.3. Matthew Elder [11]announced the release of [12]sendfile-0.3, which includes a more general interface, updated documentation, and more. Gtk2hsGenerics. Michael Dever [13]announced the release of [14]Gtk2hsGenerics, a package which contains utility functions for extracting from and adding to stores. darcs 2.3 beta 2. Petr Rockai [15]announced that darcs 2.3 beta 2 is available for testing. It can be installed using the [16]darcs-beta package on Hackage (be sure to 'cabal update' first). The new beta release adds index upgrade functionality to hashed-storage, and now uses an architecture-independent index format. hsparql, a SPARQL query generator/DSL and client. Jeff Wheeler [17]announced the first version of [18]hsparql, which makes it easy to query SPARQL-compliant servers using a relatively intuitive DSL and very simple client. SPARQL is a SQL-ish query language for stores of RDF data. Hayoo! beta 0.4. Timo B. [19]announced the next beta version 0.4 of [20]Hayoo!, the Haskell API search engine with find-as-you-type and suggestions. This release includes some major changes to the web interface, including the ability to display the full description of a function, and some example queries featured on the start page, as well as an updated search index. texmath 0.1.0.1 - conversion of LaTeX math to MathML. John MacFarlane [21]announced an early release of [22]texmath, a Haskell library for converting LaTeX math formulas to MathML. The package includes a standalone test program, testTeXMathML, and a CGI script, texmath-cgi, that can be used in web apps. You can see demos of the script [23]here and [24]here. BostonHaskell: Next meeting - July 16th at MIT CSAIL Reading Room (32-G882). Ravi Nanavati [25]announced the July meeting of the [26]Boston Area Haskell Users' Group, to be held Thursday, July 16th from 6:30pm - 8:30pm in the MIT CSAIL Reading Room. Scheduled talks include "An Introduction to GHC Hacking" by Alec Heller, and "Haskell on the iPhone" by Ryan Trinkle. There are still openings for Lightning Talks (5-minute talk, 2-minute Q&A). See the announcement for more details. AC-Vector, AC-Colour and AC-EasyRaster-GTK. Andrew Coppin [27]announced the release of three packages: [28]AC-Vector, which provides unboxed vectors of Doubles with arithmetic, dot product and cross product, and a few other useful items; [29]AC-Colour, which provides two simple RGB color types, optimized for simplicity and speed; and [30]AC-EasyRaster-GTK, a layer over Gtk2hs which provides easy pixel-twiddling functionality. Google Summer of Code Progress updates from participants in the 2008 [31]Google Summer of Code. Haddock improvements. Isaac Dupree has had a [32]good deal of success getting cross-package documentation to work, with a few remaining loose ends. space profiling. Gergely Patai's profile graphing application [33]is now capable of connecting to a profile relay server that can broadcast the heap profile of its associated process on the fly, so it is now possible to attach an observer to a program that was started earlier. He now plans to shift to working on a history manager. fast darcs. Petr Rockai has produced [34]another darcs 2.3 beta release, and has done more work on [35]designing an efficient storage system. Discussion Leaner Haskell.org frontpage. haskell [36]proposed a new design for the haskell.org front page. Bikeshedding ensues, news at 11. exercise - a completely lazy sorting algorithm. Petr Pudlak [37]asked whether it is possible to write a lazy sorting algorithm which allows access to the kth item of the sorted output in linear time, for all k. An interesting discussion and mind-expanding code followed. Implementing Las Vegas algorithms in Haskell. Matthias G?rgens began a [38]discussion on implementing Las Vegas algorithms, which use a source of randomness but have results which are still deterministic. What should the type of such functions be? Is it OK to use unsafePerformIO in their definition? Blog noise [39]Haskell news from the [40]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Petr Rockai: [41]Designing Storage for darcs. * >>> haskelladdict: [42]Having fun sorting with Haskell. * Jeff Heard: [43]C2HS example: To save other people frustration. * JP Moresmau: [44]Mazes of Monad: 1.0.5 and (maybe) final version uploaded. * Sean Leather: [45]Fun and generic things to do with EMGM at the London HUG. * Greg Bacon: [46]Gyrigrams. * Magnus Therning: [47]Making a choice from a list in Haskell, Vty (part 2). * Jeff Heard: [48]A quick buster example. * Jeff Heard: [49]An ugly force-directed layout implementation. * Petr Rockai: [50]darcs 2.3 beta 2. * Isaac Dupree: [51]Cross-package documentation going well!. * >>> dasuxullebt: [52]I (don't) like Haskell. * Holumbus: [53]Some Hayoo! Improvements. * David Amos: [54]Conjugacy classes, part 2. * Michael Snoyman: [55]hack-handler-webkit. * Dan Piponi (sigfpe): [56]A Monad for Combinatorial Search with Heuristics. * Greg Bacon: [57]A programmable semicolon explained. * Holumbus: [58]Another Hayoo! Update. * Gergely Patai: [59]Remote profiling at your fingertips. * The GHC Team: [60]Visualising the Haskell package dependency graph. * Bryan O'Sullivan: [61]First steps with Haskell text API improvement. * Paul Hudak: [62]Haskell and the Arts. * >>> John Gunderman: [63]Haskell Cabal in Ubuntu. * Sebastian Sylvan: [64]Ray tracing signed distance functions. Quotes of the Week * SimonPJ: [re: class constraints on data declarations] In GHC's source code these contexts are consistently called stupid_theta. * JN: this tutorial just introduced _|_ and called it bottom. I assume that's because it looks like an ass? * uman: so you can pass functions around as objects... this sounds like JavaScript * Twey: Mr. Wing, sir, if you are listening: you have the I.Q. of a semolina pudding. And your homepage is full of tags. I'm not sure which is the greater insult, but at least one is objectively true. * jmcarthur: #haskell: Overwhelmingly helpful. * lilac: class Monad m where / return and Kleisli compose / must form a monoid that's my new monad tutorial haiku i think that is the best monad tutorial i have ever read * dcoutts: make sure happy is on your path and it'll all be ok * ski: my answer to that is : don't deduce, denote! * roco: guys i have problem, does anybody know programming ? * dhjdhj: All new features added to C++ are intended to fix previously new features added to C++ About the Haskell Weekly News New editions are posted to [65]the Haskell mailing list as well as to [66]the Haskell Sequence and [67]Planet Haskell. [68]RSS is also available, and headlines appear on [69]haskell.org. To help create new editions of this newsletter, please see the information on [70]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [71]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://www.haskell.org//pipermail/haskell/2009-July/021472.html 3. http://hackage.haskell.org/trac/haskell-prime/wiki/Process 4. http://www.haskell.org//pipermail/haskell/2009-July/021475.html 5. http://hackage.haskell.org/package/AspectAG 6. http://www.haskell.org//pipermail/haskell-cafe/2009-July/064065.html 7. http://www.haskell.org/haskellwiki/Colour 8. http://hackage.haskell.org/package/colour 9. http://article.gmane.org/gmane.comp.lang.haskell.general/17345 10. http://www.haskell.org/haskellwiki/Hac7 11. http://article.gmane.org/gmane.comp.lang.haskell.general/17343 12. http://hackage.haskell.org/package/sendfile 13. http://article.gmane.org/gmane.comp.lang.haskell.general/17336 14. http://hackage.haskell.org/package/Gtk2hsGenerics 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/61071 16. http://hackage.haskell.org/package/darcs%2Dbeta 17. http://article.gmane.org/gmane.comp.lang.haskell.cafe/61062 18. http://hackage.haskell.org/package/hsparql 19. http://article.gmane.org/gmane.comp.lang.haskell.cafe/61060 20. http://holumbus.fh-wedel.de/hayoo 21. http://article.gmane.org/gmane.comp.lang.haskell.cafe/61049 22. http://hackage.haskell.org/package/texmath 23. http://johnmacfarlane.net/texmath.xhtml 24. http://johnmacfarlane.net/texmath.html 25. http://article.gmane.org/gmane.comp.lang.haskell.cafe/61003 26. http://www.haskell.org/haskellwiki/Boston_Area_Haskell_Users%27_Group 27. http://article.gmane.org/gmane.comp.lang.haskell.cafe/60944 28. http://hackage.haskell.org/package/AC-Vector 29. http://hackage.haskell.org/package/AC-Colour 30. http://hackage.haskell.org/package/AC-EasyRaster-GTK 31. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 32. http://haddock2009.wordpress.com/2009/07/09/cross-package-documentation-going-well/ 33. http://just-bottom.blogspot.com/2009/07/remote-profiling-at-your-fingertips.html 34. http://web.mornfall.net/blog/darcs_2.3_beta_2.html 35. http://web.mornfall.net/blog/designing_storage_for_darcs.html 36. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/61082 37. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/60981 38. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/60998 39. http://planet.haskell.org/ 40. http://haskell.org/haskellwiki/Blog_articles 41. http://web.mornfall.net/blog/designing_storage_for_darcs.html 42. http://haskelladdict.wordpress.com/2009/07/11/having-fun-sorting-with-haskell/ 43. http://vis.renci.org/jeff/2009/07/10/c2hs-example-to-save-other-people-frustration/ 44. http://jpmoresmau.blogspot.com/2009/07/mazes-of-monad-105-and-maybe-final.html 45. http://feedproxy.google.com/~r/splonderzoek/~3/qnt94yp_Er4/fun-and-generic-things-to-do-with-emgm.html 46. http://feedproxy.google.com/~r/gbacon/~3/QKPjQ0Fxl_4/gyrigrams.html 47. http://therning.org/magnus/archives/689 48. http://vis.renci.org/jeff/2009/07/09/a-quick-buster-example/ 49. http://vis.renci.org/jeff/2009/07/09/an-ugly-force-directed-layout-implementation/ 50. http://web.mornfall.net/blog/darcs_2.3_beta_2.html 51. http://haddock2009.wordpress.com/2009/07/09/cross-package-documentation-going-well/ 52. http://uxul.wordpress.com/2009/07/09/i-dont-like-haskell/ 53. http://holumbus.fh-wedel.de/blog/?p=24 54. http://haskellformaths.blogspot.com/2009/07/conjugacy-classes-part-2.html 55. http://blog.snoyman.com/2009/07/08/hack-handler-webkit/ 56. http://blog.sigfpe.com/2009/07/monad-for-combinatorial-search-with.html 57. http://feedproxy.google.com/~r/gbacon/~3/UGYWKr-huLY/programmable-semicolon-explained.html 58. http://holumbus.fh-wedel.de/blog/?p=23 59. http://just-bottom.blogspot.com/2009/07/remote-profiling-at-your-fingertips.html 60. http://ghcmutterings.wordpress.com/2009/07/06/visualising-the-haskell-package-dependency-graph/ 61. http://www.serpentine.com/blog/2009/07/06/first-steps-with-haskell-text-api-improvement/ 62. http://www.infoq.com/presentations/haskell-arts-paul-hudak 63. http://sporkcode.wordpress.com/2009/07/05/haskell-cabal-in-ubuntu/ 64. http://sebastiansylvan.spaces.live.com/blog/cns!4469F26E93033B8C!173.entry 65. http://www.haskell.org/mailman/listinfo/haskell 66. http://sequence.complete.org/ 67. http://planet.haskell.org/ 68. http://sequence.complete.org/node/feed 69. http://haskell.org/ 70. http://haskell.org/haskellwiki/HWN 71. http://code.haskell.org/~byorgey/code/hwn/ From shinnonoir at gmail.com Sun Jul 12 13:01:11 2009 From: shinnonoir at gmail.com (Raynor Vliegendhart) Date: Sun Jul 12 12:43:12 2009 Subject: Hylomorphisms (was: [Haskell-cafe] excercise - a completely lazy sorting algorithm) Message-ID: <6d961e560907121001xe34fa9dr26c8c85fbad8c464@mail.gmail.com> On 7/12/09, Heinrich Apfelmus wrote: > Raynor Vliegendhart wrote: > > On 7/9/09, Heinrich Apfelmus wrote: > >> Of course, some part of algorithm has to be recursive, but this can be > >> outsourced to a general recursion scheme, like the hylomorphism > >> > >> hylo :: Functor f => (a -> f a) -> (f b -> b) -> (a -> b) > >> hylo f g = g . fmap (hylo f g) . f > >> > > > > Is that definition of hylo actually usable? A few on IRC tried to use > > that definition for a few examples, but the examples failed to > > terminate or blew up the stack. > > The implementation of quicksort with hylo works fine for me, given > medium sized inputs like for example quicksort (reverse [1..1000]) . > > What were the examples you tried? > One of the examples I tried was: hylo (unfoldr (\a -> Just (a,a))) head $ 42 This expression fails to determinate. Here are two examples copumpkin tried on IRC: > let hylo f g = g . fmap (hylo f g) . f in hylo (flip replicate 2) length 5 5 > let hylo f g = g . fmap (hylo f g) . f in hylo (flip replicate 2) sum 5 * Exception: stack overflow From briqueabraque at yahoo.com Sun Jul 12 13:11:53 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sun Jul 12 12:54:07 2009 Subject: [Haskell-cafe] Re: Mixing C and Haskell code in the same file In-Reply-To: References: Message-ID: >> Is it possible to insert C code directly to, say, >> .hsc files? I see this construct in ghc user docs: > > I think you can find your answer here: > http://www.haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html I did read that. It says I can use "#def" to insert a C definition, but there are no examples of use, and I could not find one. Maur?cio From byorgey at seas.upenn.edu Sun Jul 12 13:33:50 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sun Jul 12 13:15:49 2009 Subject: Hylomorphisms (was: [Haskell-cafe] excercise - a completely lazy sorting algorithm) In-Reply-To: <6d961e560907121001xe34fa9dr26c8c85fbad8c464@mail.gmail.com> References: <6d961e560907121001xe34fa9dr26c8c85fbad8c464@mail.gmail.com> Message-ID: <20090712173350.GA17985@seas.upenn.edu> On Sun, Jul 12, 2009 at 07:01:11PM +0200, Raynor Vliegendhart wrote: > On 7/12/09, Heinrich Apfelmus wrote: > > Raynor Vliegendhart wrote: > > > On 7/9/09, Heinrich Apfelmus wrote: > > >> Of course, some part of algorithm has to be recursive, but this can be > > >> outsourced to a general recursion scheme, like the hylomorphism > > >> > > >> hylo :: Functor f => (a -> f a) -> (f b -> b) -> (a -> b) > > >> hylo f g = g . fmap (hylo f g) . f > > >> > > > > > > Is that definition of hylo actually usable? A few on IRC tried to use > > > that definition for a few examples, but the examples failed to > > > terminate or blew up the stack. > > > > The implementation of quicksort with hylo works fine for me, given > > medium sized inputs like for example quicksort (reverse [1..1000]) . > > > > What were the examples you tried? > > > > One of the examples I tried was: > > hylo (unfoldr (\a -> Just (a,a))) head $ 42 > > This expression fails to determinate. > > Here are two examples copumpkin tried on IRC: > > > let hylo f g = g . fmap (hylo f g) . f in hylo (flip > replicate 2) length 5 > 5 > > > let hylo f g = g . fmap (hylo f g) . f in hylo (flip > replicate 2) sum 5 > * Exception: stack overflow [] is a strange functor to use with hylo, since it is already recursive and its only base case (the empty list) doesn't contain any a's. Think about the intermediate structure that hylo (unfoldr (\a -> Just (a,a))) head is building up: it is a list of lists of lists of lists of lists of lists of.... no wonder it doesn't terminate! =) Instead, it would be more normal to use something like data ListF a l = Nil | Cons a l head :: ListF a l -> a head Nil = error "FLERG" head (Cons a _) = a instance Functor (ListF a) where fmap _ Nil = Nil fmap f (Cons a l) = Cons a (f l) Taking the fixed point of (ListF a) gives us (something isomorphic to) the normal [a], so we can do what you were presumably trying to do with your example: hylo (\a -> Cons a a) head $ 42 The intermediate structure built up by this hylo is (isomorphic to) an infinite list of 42's, and it evaluates to '42' just fine. -Brent From briqueabraque at yahoo.com Sun Jul 12 13:40:06 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sun Jul 12 13:22:18 2009 Subject: [Haskell-cafe] Could C libraries be part of Haskell Platform? Message-ID: Probably not, but... There are stable and portable libraries that implement functionality missing in Haskell. It could be nice to be able to list then in a cabal file (using, say, pkgconfig-depends) and know for sure that any system with Haskell Platform will have then available for use with FFI. An example would be sqlite3. To me, this seems to be ugly in theory and good in practice. Best, Maur?cio From bulat.ziganshin at gmail.com Sun Jul 12 14:26:52 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Jul 12 14:11:35 2009 Subject: [Haskell-cafe] Re: Mixing C and Haskell code in the same file In-Reply-To: References: Message-ID: <212312311.20090712222652@gmail.com> Hello Maur??cio, Sunday, July 12, 2009, 9:11:53 PM, you wrote: > I did read that. It says I can use "#def" to insert > a C definition, but there are no examples of use, and I > could not find one. #def inline int signof(int x) {return x<0?-1:x>0?1:0;} foreign import ccall safe "" signof :: CInt -> CInt main = print (signof 33) compilation: hsc2hs tabi.hsc ghc --make tabi.hs tabi_hsc.c -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Sun Jul 12 14:30:58 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Jul 12 14:21:39 2009 Subject: [Haskell-cafe] Could C libraries be part of Haskell Platform? In-Reply-To: References: Message-ID: <09442862.20090712223058@gmail.com> Hello Maur??cio, Sunday, July 12, 2009, 9:40:06 PM, you wrote: > An example would be sqlite3. w/o haskell binding it's useless for most of HP users -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From allbery at ece.cmu.edu Sun Jul 12 16:30:41 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 12 16:13:07 2009 Subject: [Haskell-cafe] Could C libraries be part of Haskell Platform? In-Reply-To: References: Message-ID: <0FC5FE5E-0EE4-4400-8440-E48EAD4EA26F@ece.cmu.edu> On Jul 12, 2009, at 13:40 , Maur? cio wrote: > Probably not, but... There are stable and portable libraries > that implement functionality missing in Haskell. It could be > nice to be able to list then in a cabal file (using, say, > pkgconfig-depends) and know for sure that any system with > Haskell Platform will have then available for use with FFI. > An example would be sqlite3. I think we currently address this by including the C libraries with the Haskell bindings (e.g. zlib). -- 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/20090712/c9778585/PGP.bin From briqueabraque at yahoo.com Sun Jul 12 19:38:15 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sun Jul 12 19:20:24 2009 Subject: [Haskell-cafe] Re: Could C libraries be part of Haskell Platform? In-Reply-To: <0FC5FE5E-0EE4-4400-8440-E48EAD4EA26F@ece.cmu.edu> References: <0FC5FE5E-0EE4-4400-8440-E48EAD4EA26F@ece.cmu.edu> Message-ID: >> Probably not, but... There are stable and portable libraries >> that implement functionality missing in Haskell. It could be >> nice to be able to list then in a cabal file (using, say, >> pkgconfig-depends) and know for sure that any system with >> Haskell Platform will have then available for use with FFI. An >> example would be sqlite3. > w/o haskell binding it's useless for most of HP users > I think we currently address this by including the C libraries > with the Haskell bindings (e.g. zlib). That, of course, would be the goal. Today, it's disappointing to write bindings, since Hackage won't build them properly (since the libraries are not installed on hackage. Of course, for simple packages like zlib or sqlite3 you have the alternative of including them with your code). If good C libraries were available in HP, bindings would flourish. Maur?cio From allbery at ece.cmu.edu Sun Jul 12 20:06:28 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 12 19:48:53 2009 Subject: [Haskell-cafe] Re: Could C libraries be part of Haskell Platform? In-Reply-To: References: <0FC5FE5E-0EE4-4400-8440-E48EAD4EA26F@ece.cmu.edu> Message-ID: On Jul 12, 2009, at 19:38 , Maur? cio wrote: > That, of course, would be the goal. Today, it's disappointing to > write bindings, since Hackage won't build them properly (since > the libraries are not installed on hackage. Of course, for > simple packages like zlib or sqlite3 you have the alternative of > including them with your code). If good C libraries were available > in HP, bindings would flourish. This isn't clear to me; in general you only need to bind them once and then they're available in Haskell. Why not include the library with its bindings? -- 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/20090712/dc1bb0a0/PGP.bin From allbery at ece.cmu.edu Sun Jul 12 20:12:29 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 12 19:54:32 2009 Subject: [Haskell-cafe] Re: Could C libraries be part of Haskell Platform? In-Reply-To: References: <0FC5FE5E-0EE4-4400-8440-E48EAD4EA26F@ece.cmu.edu> Message-ID: On Jul 12, 2009, at 20:06 , Brandon S. Allbery KF8NH wrote: > This isn't clear to me; in general you only need to bind them once > and then they're available in Haskell. Why not include the library > with its bindings? The exception here is the still-evolving bindings to e.g. BLAS. It's not at all clear to me that including BLAS in the Haskell Platform is going to help with this; more important is having people who understand BLAS, who probably already have it, and making BLAS libs available won't help someone like me understand it well enough to work on the bindings. -- 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/20090712/dc565826/PGP.bin From icfp.publicity at googlemail.com Sun Jul 12 22:45:40 2009 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Sun Jul 12 22:27:37 2009 Subject: [Haskell-cafe] ICFP09 Final Call for Participation Message-ID: <53ff55480907121945s1a66a7eck5ce5074eb99dc306@mail.gmail.com> ===================================================================== Final Call for Participation The 14th ACM SIGPLAN International Conference on Functional Programming (ICFP 2009) http://www.cs.nott.ac.uk/~gmh/icfp09.html Edinburgh, Scotland, 31 August - 2 September 2009 ===================================================================== ***** Accommodation Deadline: July 20, 2009 ***** Due to the overlap with Edinburgh Festival, accommodations may be difficult to secure after the deadline. Reserve now! http://www.haskell.org/haskellwiki/ICFP_2009_Local_Arrangements ***** Early Registration Deadline: July 30, 2009 ***** http://www.regmaster.com/conf/icfp2009.html ICFP 2009 provides a forum for researchers and developers to hear about the latest work on the design, implementations, principles, and uses of functional programming. The conference covers the entire spectrum of work, from practice to theory, including its peripheries. Preliminary program: * Abstracts: + http://web.cecs.pdx.edu/~apt/icfp09_accepted_papers/accepted.html * Schedule: + http://web.cecs.pdx.edu/~apt/icfp09_preliminary_program.pdf * Invited speakers: + Guy Steele -- Organizing Functional Code for Parallel Execution: or, foldl and foldr Considered Slightly Harmful + Benjamin Pierce -- Lambda, the Ultimate TA: Using a Proof Assistant to Teach Programming Language Foundations + Dan Piponi -- Commutative Monads, Diagrams and Knots Schedule including related workshops: * Aug 30: ACM SIGPLAN Workshop on ML * Aug 30: ACM SIGPLAN Workshop on Generic Programming * Aug 31-Sep 2: ICFP09 * Sep 3: ACM SIGPLAN Haskell Symposium * Sep 3: ACM SIGPLAN Developer Tracks on Functional Programming * Sep 4: Commercial Users of Functional Programming * Sep 4: ACM SIGPLAN Workshop on Mechanizing Metatheory * Sep 4: ACM SIGPLAN Workshop on Approaches and Applications of Inductive Programming * Sep 5: ACM SIGPLAN Erlang Workshop * Sep 5: ACM SIGPLAN Developer Tracks on Functional Programming * Sep 5: ACM SIGPLAN Haskell Implementors Workshop Conference organizers: * General Chair: Graham Hutton (University of Nottingham) * Program Chair: Andrew Tolmach (Portland State University) * Local Arrangements Chairs: Philip Wadler (University of Edinburgh), Kevin Hammond (University of St Andrews), and Gregory Michaelson (Heriot-Watt University) * Workshop Co-Chairs: Christopher Stone (Harvey Mudd College), and Michael Sperber (DeinProgramm) * Programming Contest Chair: Andrew Gill (University of Kansas) * Publicity Chair: Matthew Fluet (Toyota Technological Institute at Chicago) From briqueabraque at yahoo.com Sun Jul 12 22:56:15 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sun Jul 12 22:38:27 2009 Subject: [Haskell-cafe] Re: Could C libraries be part of Haskell Platform? In-Reply-To: References: <0FC5FE5E-0EE4-4400-8440-E48EAD4EA26F@ece.cmu.edu> Message-ID: >> This isn't clear to me; in general you only need to bind them >> once and then they're available in Haskell. Why not include the >> library with its bindings? There are many ways to bind to a library. The first one isn't usually the best. Including the library with its bindings means you have to take care of doing a portable distribution, something even the authors of libraries usually find difficult to do. Doing that on one place (like, say, Haskell Platform) means no one else will have to do it, at least for a set of libraries. > (...) and making BLAS libs available won't help someone like me > understand it well enough to work on the bindings. I hope not! If you can, avoid that kind of work, it won't do you any good. Other's like me, however, had to learn FFI, and would like to do as much as possible to avoid others having to do the same. However, it's not nice to work on bindings that I know others (including hackage) won't be able to build and criticize. Maur?cio From magicloud.magiclouds at gmail.com Mon Jul 13 02:45:00 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon Jul 13 02:26:58 2009 Subject: [Haskell-cafe] Why this cannot be compiled? Message-ID: <3bd412d40907122345l5c655c3av16925aed4038f829@mail.gmail.com> Hi, The following code failed to compiled, with error: Attribute.hs:46:91: Couldn't match expected type `[t]' against inferred type `(a, String)' In the expression: (color_, rest_) In a case alternative: [(color_, rest_)] -> (color_, rest_) In the expression: case reads rest1 of { [(color_, rest_)] -> (color_, rest_) _ -> (Color 0 0 0, rest1) } 43 instance Read Attribute where 44 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) <- lex str 45 , (color, rest) <- case reads rest1 of 46 [(color_, rest_)] -> (color_, rest_) 47 _ -> (Color 0 0 0, rest1) ] 48 where mkAttr "AttrFgColor" color = AttrFgColor color 49 mkAttr "AttrBgColor" color = AttrBgColor color 50 mkAttr "AttrInverse" _ = AttrInverse 51 mkAttr "AttrWeak" _ = AttrWeak 52 mkAttr "AttrUnderline" _ = AttrUnderline -- ??????? ??????? From ketil at malde.org Mon Jul 13 03:33:09 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Jul 13 03:15:06 2009 Subject: [Haskell-cafe] Why this cannot be compiled? In-Reply-To: <3bd412d40907122345l5c655c3av16925aed4038f829@mail.gmail.com> (Magicloud Magiclouds's message of "Mon\, 13 Jul 2009 14\:45\:00 +0800") References: <3bd412d40907122345l5c655c3av16925aed4038f829@mail.gmail.com> Message-ID: <87d485rqa2.fsf@malde.org> Magicloud Magiclouds writes: > 43 instance Read Attribute where > 44 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) <- lex str > 45 , (color, rest) <- case reads rest1 of > 46 [(color_, rest_)] -> (color_, rest_) > 47 _ -> (Color 0 0 0, rest1) ] Doesn't the (color,rest) pair in the list comprehension need to be pulled from a list? The case expression only returns a pair so you're basically left with [something| something, (color,rest) <- (somecolor,somerest) ] Since you're only producing a single (color,rest) for each rest1, you might consider lifting it out in the left side of the list comprehension. -k -- If I haven't seen further, it is by standing in the footprints of giants From magicloud.magiclouds at gmail.com Mon Jul 13 03:47:26 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon Jul 13 03:29:23 2009 Subject: [Haskell-cafe] Why this cannot be compiled? In-Reply-To: <87d485rqa2.fsf@malde.org> References: <3bd412d40907122345l5c655c3av16925aed4038f829@mail.gmail.com> <87d485rqa2.fsf@malde.org> Message-ID: <3bd412d40907130047m23cf7e77h274bea4f0711e2b3@mail.gmail.com> Hum.... I must lost my mind.... Thank you. On Mon, Jul 13, 2009 at 3:33 PM, Ketil Malde wrote: > Magicloud Magiclouds writes: > >> ?43 instance Read Attribute where >> ?44 ? readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) <- lex str >> ?45 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?, (color, rest) ?<- case reads rest1 of >> ?46 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?[(color_, rest_)] -> (color_, rest_) >> ?47 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_ -> (Color 0 0 0, rest1) ] > > Doesn't the (color,rest) pair in the list comprehension need to be > pulled from a list? ?The case expression only returns a pair so you're > basically left with [something| something, (color,rest) <- (somecolor,somerest) ] > > Since you're only producing a single (color,rest) for each rest1, you might > consider lifting it out in the left side of the list comprehension. > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > -- ??????? ??????? From apfelmus at quantentunnel.de Mon Jul 13 06:13:15 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Mon Jul 13 05:55:15 2009 Subject: [Haskell-cafe] Re: Hylomorphisms (was: excercise - a completely lazy sorting algorithm) In-Reply-To: <20090712173350.GA17985@seas.upenn.edu> References: <6d961e560907121001xe34fa9dr26c8c85fbad8c464@mail.gmail.com> <20090712173350.GA17985@seas.upenn.edu> Message-ID: Brent Yorgey wrote: > Raynor Vliegendhart wrote: > >> One of the examples I tried was: >> >> hylo (unfoldr (\a -> Just (a,a))) head $ 42 >> >> This expression fails to determinate. >> >> Here are two examples copumpkin tried on IRC: >> >> > let hylo f g = g . fmap (hylo f g) . f in hylo (flip >> replicate 2) length 5 >> 5 >> >> > let hylo f g = g . fmap (hylo f g) . f in hylo (flip >> replicate 2) sum 5 >> * Exception: stack overflow > > [] is a strange functor to use with hylo, since it is already > recursive and its only base case (the empty list) doesn't contain any > a's. Think about the intermediate structure that > > hylo (unfoldr (\a -> Just (a,a))) head > > is building up: it is a list of lists of lists of lists of lists of > lists of.... no wonder it doesn't terminate! =) Yep, not terminating is the correct behavior here. In particular, we have example = hylo repeat head = cata head . ana repeat and the intermediate data structure is Fix [] which is an infinite nested tower of infinite lists. Regards, apfelmus -- http://apfelmus.nfshost.com From maillist at kevinmahoney.co.uk Mon Jul 13 06:41:25 2009 From: maillist at kevinmahoney.co.uk (Kev Mahoney) Date: Mon Jul 13 06:23:23 2009 Subject: [Haskell-cafe] Are GADTs what I need? Message-ID: Hi there, I'm currently writing an interpreter that I would like to be able to use with other haskell programs. I would like to be able to pass along arbitrary types though the interpreter. I've seen hints that GADTs can do this, but I am having trouble understanding them. So far, I've learnt you can do this: data Value where VInt :: Integer -> Value ... VWrapper :: a -> Value which can let you encode arbitrary 'dynamic' types into Value. I was hoping to be able to pattern match to get the value out again e.g. doSomething :: Value -> .... doSomething (VWrapper String s) = ..... Also, anything that can help me out with GADTs in general will be much appreciated. Thanks, Kevin. From matthias.goergens at googlemail.com Mon Jul 13 06:43:07 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 13 06:25:03 2009 Subject: [Haskell-cafe] haskell.org: what can be improved causing what efforts? In-Reply-To: <1247162857-sup-5348@nixos> References: <1247162857-sup-5348@nixos> Message-ID: > code snippet: no hello world please. That's not a way to judge a > language! But: a random haskell one line snippet with explanation would > be cool. Perhaps a solution to a problem like the ones you can find on Project Euler (http://projecteuler.net/index.php?section=problems). Of course you can't take an actual problem from Project Euler, because they do not like solutions to be posted in the wild. But you can get your inspiration from there. From jeremy.yallop at ed.ac.uk Mon Jul 13 07:52:17 2009 From: jeremy.yallop at ed.ac.uk (Jeremy Yallop) Date: Mon Jul 13 07:34:52 2009 Subject: [Haskell-cafe] Type families and polymorphism In-Reply-To: <200907111848.20598.dan.doel@gmail.com> References: <4A58DA80.4010902@ed.ac.uk> <200907111848.20598.dan.doel@gmail.com> Message-ID: <4A5B1FF1.4030100@ed.ac.uk> Dan Doel wrote: > Hope that helps. It does, thanks! Jeremy -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From chris at eidhof.nl Mon Jul 13 08:09:57 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Jul 13 07:51:58 2009 Subject: [Haskell-cafe] Are GADTs what I need? In-Reply-To: References: Message-ID: Hey Kev, The types are "thrown away" during compile time. Therefore, if you have a constructor "VWrapper :: a -> Value" nothing is known about that "a" when you scrutinize it. What you could do, however, is something like this: > data Value a where > VInt :: Integer -> Value Integer > ... > VWrapper :: a -> Value a And then you can write a function doSomething: > doSomething :: Value String -> String > doSomething (VWrapper s) = s HTH, -chris On 13 jul 2009, at 12:41, Kev Mahoney wrote: > Hi there, > > I'm currently writing an interpreter that I would like to be able to > use with other haskell programs. I would like to be able to pass along > arbitrary types though the interpreter. I've seen hints that GADTs can > do this, but I am having trouble understanding them. > > So far, I've learnt you can do this: > > data Value where > VInt :: Integer -> Value > ... > VWrapper :: a -> Value > > which can let you encode arbitrary 'dynamic' types into Value. I was > hoping to be able to pattern match to get the value out again e.g. > > doSomething :: Value -> .... > doSomething (VWrapper String s) = ..... > > Also, anything that can help me out with GADTs in general will be much > appreciated. > > Thanks, > Kevin. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From hjgtuyl at chello.nl Mon Jul 13 09:26:59 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Mon Jul 13 09:08:55 2009 Subject: [Haskell-cafe] haskell.org: what can be improved causing what efforts? In-Reply-To: References: <1247162857-sup-5348@nixos> Message-ID: On Mon, 13 Jul 2009 12:43:07 +0200, Matthias G?rgens wrote: >> code snippet: no hello world please. That's not a way to judge a >> language! But: a random haskell one line snippet with explanation would >> be cool. > > Perhaps a solution to a problem like the ones you can find on Project > Euler (http://projecteuler.net/index.php?section=problems). Of course > you can't take an actual problem from Project Euler, because they do > not like solutions to be posted in the wild. But you can get your > inspiration from there. I like the quicksort example at http://www.haskell.org/haskellwiki/Introduction very much; it shows how much time you can save when you use Haskell. -- Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From matthias.goergens at googlemail.com Mon Jul 13 10:05:06 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 13 09:47:04 2009 Subject: [Haskell-cafe] haskell.org: what can be improved causing what efforts? In-Reply-To: References: <1247162857-sup-5348@nixos> Message-ID: > I like the quicksort example at > http://www.haskell.org/haskellwiki/Introduction very much; it shows how much > time you can save when you use Haskell. Nice idea. Perhaps use a merge sort, because that is actually useful, because it does not degenerate for large lists. Matthias. From bulat.ziganshin at gmail.com Mon Jul 13 10:14:32 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jul 13 09:56:40 2009 Subject: [Haskell-cafe] haskell.org: what can be improved causing what efforts? In-Reply-To: References: <1247162857-sup-5348@nixos> Message-ID: <543506078.20090713181432@gmail.com> Hello Matthias, Monday, July 13, 2009, 6:05:06 PM, you wrote: >> I like the quicksort example at > Nice idea. Perhaps use a merge sort, because that is actually useful, > because it does not degenerate for large lists. Great idea if we want to keep Haskell community compact :))) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From matthias.goergens at googlemail.com Mon Jul 13 10:32:37 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Jul 13 10:14:35 2009 Subject: [Haskell-cafe] haskell.org: what can be improved causing what efforts? In-Reply-To: <543506078.20090713181432@gmail.com> References: <1247162857-sup-5348@nixos> <543506078.20090713181432@gmail.com> Message-ID: >> Nice idea. ?Perhaps use a merge sort, because that is actually useful, >> because it does not degenerate for large lists. > > Great idea if we want to keep Haskell community compact :))) Or stay with quicksort --- which is treesort. :o) From chris at eidhof.nl Mon Jul 13 11:54:52 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Jul 13 11:36:49 2009 Subject: [Haskell-cafe] Are GADTs what I need? In-Reply-To: References: Message-ID: Then you could add a specific constructor for String. The main point is: the case construct only works for values, not for types. There is no typecase construct. If you want to have certain restrictions on the 'a', such as the Show class, you could also do something like this: > data Value where > VWrapper :: (Show a) => a -> Value If you could elaborate a bit on what you're trying to accomplish (from a higher viewpoint) then maybe we can help you some more. -chris On 13 jul 2009, at 17:42, Kev Mahoney wrote: > Thanks, that helps. > > I was hoping to not have to parametrize Value as there is a fair bit > of code to change, and it cascades down through the data structures > (maybe a forall a . Value a will help here?) > > I will have a go at this approach. In case anyone is interested the > code is at http://github.com/KMahoney > > > 2009/7/13 Chris Eidhof : >> Hey Kev, >> >> The types are "thrown away" during compile time. Therefore, if you >> have a >> constructor "VWrapper :: a -> Value" nothing is known about that >> "a" when >> you scrutinize it. >> >> What you could do, however, is something like this: >> >>> data Value a where >>> VInt :: Integer -> Value Integer >>> ... >>> VWrapper :: a -> Value a >> >> And then you can write a function doSomething: >> >>> doSomething :: Value String -> String >>> doSomething (VWrapper s) = s >> >> HTH, >> >> -chris >> >> On 13 jul 2009, at 12:41, Kev Mahoney wrote: >> >>> Hi there, >>> >>> I'm currently writing an interpreter that I would like to be able to >>> use with other haskell programs. I would like to be able to pass >>> along >>> arbitrary types though the interpreter. I've seen hints that GADTs >>> can >>> do this, but I am having trouble understanding them. >>> >>> So far, I've learnt you can do this: >>> >>> data Value where >>> VInt :: Integer -> Value >>> ... >>> VWrapper :: a -> Value >>> >>> which can let you encode arbitrary 'dynamic' types into Value. I was >>> hoping to be able to pattern match to get the value out again e.g. >>> >>> doSomething :: Value -> .... >>> doSomething (VWrapper String s) = ..... >>> >>> Also, anything that can help me out with GADTs in general will be >>> much >>> appreciated. >>> >>> Thanks, >>> Kevin. >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> From robgreayer at gmail.com Mon Jul 13 12:11:57 2009 From: robgreayer at gmail.com (Robert Greayer) Date: Mon Jul 13 11:53:54 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <200907101044.52078.g9ks157k@acme.softbase.org> References: <200907101044.52078.g9ks157k@acme.softbase.org> Message-ID: <4ec472cb0907130911p47b0d98y3dca41145b842bfa@mail.gmail.com> > It?s tempting to say, we should > use the original English, which is British English. Some suggest the original English remained in Britain when the North American colonies were founded; others claim it was brought to the Americas by the British settlers, leaving a pale imitation back in Britain. The truth is much stranger: the original English was actually smuggled out of Britain to the West Indies in a wardrobe belonging to General Sir Ralph Abercromby, where it ended up on the island of Trinidad after Sir Ralph took possession of that territory in the name of the British Crown. It came to be used and modified freely by the various immigrants to Trinidad (and later Tobago) and their descendants (largely African, Indian, British, Portuguese, German, Spanish, and Chinese). Many of these peoples then emigrated, bringing the original English to North America and back to Britain. A copy of it has fallen into my hands, and so I can, without bias, make the following call: both color and colour shall be acceptable in Haskell programming. 'Kerb' and 'gaol' are right out, however. Cheers, Robert (who's grandfather is from London and grandmother from Trinidad; but is nevertheless American) From maillist at kevinmahoney.co.uk Mon Jul 13 12:18:05 2009 From: maillist at kevinmahoney.co.uk (Kev Mahoney) Date: Mon Jul 13 12:00:01 2009 Subject: [Haskell-cafe] Are GADTs what I need? In-Reply-To: References: Message-ID: Oops, wrong mail account for my last email. Apologies. What I'm trying to accomplish is being able to write haskell libraries for the interpreter that don't use the interpreter's predefined Value types, without having to edit the Value type itself and add a new constructor (i.e. it's abstracted away). I believe the concept is called 'userdata' in Lua, for example. In C interpreters it is usually accomplished by throwing away type information and casting to 'void*' and then casting back to the type to get it out again. That said, I think I may defer this until I understand the ins and outs of Haskell's type system a little better. I think a parametrized type will be the only way to do it. The only reason I thought GADTs may be able to do this is because I read some literature that suggested GADTs could be used as a kind of typecase construct (I think it was 'Fun with Phantom Types'?) but I could have very easily misunderstood it. 2009/7/13 Chris Eidhof : > Then you could add a specific constructor for String. The main point is: the > case construct only works for values, not for types. There is no typecase > construct. If you want to have certain restrictions on the 'a', such as the > Show class, you could also do something like this: > >> data Value where >> ? VWrapper :: (Show a) => a -> Value > > If you could elaborate a bit on what you're trying to accomplish (from a > higher viewpoint) then maybe we can help you ? some more. > > -chris > > On 13 jul 2009, at 17:42, Kev Mahoney wrote: > >> Thanks, that helps. >> >> I was hoping to not have to parametrize Value as there is a fair bit >> of code to change, and it cascades down through the data structures >> (maybe a forall a . Value a will help here?) >> >> I will have a go at this approach. In case anyone is interested the >> code is at http://github.com/KMahoney >> >> >> 2009/7/13 Chris Eidhof : >>> >>> Hey Kev, >>> >>> The types are "thrown away" during compile time. Therefore, if you have a >>> constructor "VWrapper :: a -> Value" nothing is known about that "a" when >>> you scrutinize it. >>> >>> What you could do, however, is something like this: >>> >>>> data Value a where >>>> ?VInt :: Integer -> Value Integer >>>> ?... >>>> ?VWrapper :: a -> Value a >>> >>> And then you can write a function doSomething: >>> >>>> doSomething :: Value String -> String >>>> doSomething (VWrapper s) = s >>> >>> HTH, >>> >>> -chris >>> >>> On 13 jul 2009, at 12:41, Kev Mahoney wrote: >>> >>>> Hi there, >>>> >>>> I'm currently writing an interpreter that I would like to be able to >>>> use with other haskell programs. I would like to be able to pass along >>>> arbitrary types though the interpreter. I've seen hints that GADTs can >>>> do this, but I am having trouble understanding them. >>>> >>>> So far, I've learnt you can do this: >>>> >>>> data Value where >>>> VInt :: Integer -> Value >>>> ... >>>> VWrapper :: a -> Value >>>> >>>> which can let you encode arbitrary 'dynamic' types into Value. I was >>>> hoping to be able to pattern match to get the value out again e.g. >>>> >>>> doSomething :: Value -> .... >>>> doSomething (VWrapper String s) = ..... >>>> >>>> Also, anything that can help me out with GADTs in general will be much >>>> appreciated. >>>> >>>> Thanks, >>>> Kevin. >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> > > From chaddai.fouche at gmail.com Mon Jul 13 12:20:53 2009 From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=) Date: Mon Jul 13 12:02:50 2009 Subject: [Haskell-cafe] Are GADTs what I need? In-Reply-To: References: Message-ID: On Mon, Jul 13, 2009 at 12:41 PM, Kev Mahoney wrote: > So far, I've learnt you can do this: > > data Value where > VInt :: Integer -> Value > ... > VWrapper :: a -> Value > > which can let you encode arbitrary 'dynamic' types into Value. I was > hoping to be able to pattern match to get the value out again e.g. As such this type is pretty useless, since you don't know anything about a, you can't do anything with it... Which is why you add typeclass constraints, so you can use this value. Data.Dynamic adds a Typeable constraint, which allows you to do safe coercing, so you can have a "typecase", if not like you tried to do it. -- Jeda? From matt at mattelder.org Mon Jul 13 12:31:06 2009 From: matt at mattelder.org (Matthew Elder) Date: Mon Jul 13 12:13:23 2009 Subject: [Haskell-cafe] Questions about haskell CPP macros Message-ID: <987d172d0907130931i5465a3a6m918a221165b9049a@mail.gmail.com> Hello Cafe, I am trying to improve the error reporting in my sendfile library, and I know I can find out the current file name and line number with something like this: {-# LANGUAGE CPP #-} main = putStrLn (__FILE__ ++ ":" ++ show __LINE__) This outputs: test.hs:2 Unfortunately, if your file is in a hierarchy of folders, this flat file name doesn't give much context. Is there a macro to find out the current module? IE if I had a module Foo.Bar.Car.MyModule, I would like to be able to output something like this on error: Foo.Bar.Car.MyModule:2 Any help is appreciated! Thanks, Matt -- Need somewhere to put your code? http://patch-tag.com Want to build a webapp? http://happstack.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090713/4ec211c6/attachment.html From maillist at kevinmahoney.co.uk Mon Jul 13 12:35:38 2009 From: maillist at kevinmahoney.co.uk (Kev Mahoney) Date: Mon Jul 13 12:17:35 2009 Subject: [Haskell-cafe] Are GADTs what I need? In-Reply-To: References: Message-ID: Thanks, I hadn't noticed Data.Dynamic. It never even occurred to me that something like this would be in the standard libraries. It looks like it's precisely what I was looking for, after a brief scan of the documentation. I will report back if I bump into any problems with it 2009/7/13 Chadda? Fouch? : > On Mon, Jul 13, 2009 at 12:41 PM, Kev > Mahoney wrote: >> So far, I've learnt you can do this: >> >> data Value where >> VInt :: Integer -> Value >> ... >> VWrapper :: a -> Value >> >> which can let you encode arbitrary 'dynamic' types into Value. I was >> hoping to be able to pattern match to get the value out again e.g. > > As such this type is pretty useless, since you don't know anything > about a, you can't do anything with it... Which is why you add > typeclass constraints, so you can use this value. Data.Dynamic adds a > Typeable constraint, which allows you to do safe coercing, so you can > have a "typecase", if not like you tried to do it. > > -- > Jeda? > From ryani.spam at gmail.com Mon Jul 13 12:41:39 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jul 13 12:23:35 2009 Subject: [Haskell-cafe] Are GADTs what I need? In-Reply-To: References: Message-ID: <2f9b2d30907130941j55360380j45239d97acbb2c@mail.gmail.com> On Mon, Jul 13, 2009 at 9:18 AM, Kev Mahoney wrote: > That said, I think I may defer this until I understand the ins and > outs of Haskell's type system a little better. I think a parametrized > type will be the only way to do it. The only reason I thought GADTs > may be able to do this is because I read some literature that > suggested GADTs could be used as a kind of typecase construct (I think > it was 'Fun with Phantom Types'?) but I could have very easily > misunderstood it. The big problem is that you haven't parametrized your Value type at all, so there's no information about the value inside. Try this: > data Value a where > VPrim :: Type a -> a -> Value a > VAbs :: Type a -> (Value a -> Value b) -> Value (a -> b) > VApp :: Value (a -> b) -> Value a -> Value b > data Type a where > TInt :: Type Int > TBool :: Type Bool > TChar :: Type Char > TList :: Type a -> Type [a] > TFun :: Type a -> Type b -> Type (a -> b) data SomeType = forall a. SomeType (Type a) data SomeValue = forall a. SomeValue (Value a) Now you can do: > interpret :: Value a -> a > interpret (VPrim _ x) = x > interpret (VAbs t f) = \x -> f (VPrim t x) > interpret (VApp f x) = interpret f $ interpret x And: > typeOf :: Value a -> Type a > typeOf (VPrim t _) = t > typeOf (VAbs t f) = typeOf (f $ VPrim t (representative t)) > typeOf (VApp f _) = case typeOf f of (TFun _ b) -> b > > representative :: Type a -> a > representative TInt = 0 > representative TBool = False > representative TChar = 'a' > representative (TList _) = [] > representative (TFun _ b) = \_ -> representative b Your compiler will generally have type (String -> Maybe SomeValue), or (String -> Type a -> Maybe (Value a)). -- ryan From claus.reinke at talk21.com Mon Jul 13 13:12:45 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Jul 13 12:55:12 2009 Subject: [Haskell-cafe] Questions about haskell CPP macros References: <987d172d0907130931i5465a3a6m918a221165b9049a@mail.gmail.com> Message-ID: > I am trying to improve the error reporting in my sendfile library, and I > know I can find out the current file name and line number with something > like this: > > {-# LANGUAGE CPP #-} > main = putStrLn (__FILE__ ++ ":" ++ show __LINE__) > > This outputs: > test.hs:2 > > Unfortunately, if your file is in a hierarchy of folders, this flat file > name doesn't give much context. Is there a macro to find out the current > module? IE if I had a module Foo.Bar.Car.MyModule, I would like to be able > to output something like this on error: > Foo.Bar.Car.MyModule:2 Sounds like a job for cabal or ghc, to define appropriate macros for package and module when compiling the source? > Any help is appreciated! For actually making use of such information, see http://hackage.haskell.org/trac/ghc/wiki/ExplicitCallStack http://hackage.haskell.org/trac/ghc/wiki/ExplicitCallStack/StackTraceExperience and also the recent thread on how to improve the quality of "+RTS -xc" output via mapException (hmm, can't reach the archive at the moment, one subject was "Should exhaustiveness testing be on by default?", about May; http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ). If you really mean "any help", you could also use Template Haskell:-) {-# LANGUAGE TemplateHaskell #-} module Oh.Hi where import Language.Haskell.TH main = print $( location >>= \(Loc f p m s e)-> stringE (f++":"++p++":"++m++":"++show s++":"++show e)) Claus From deduktionstheorem at web.de Mon Jul 13 13:27:31 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Mon Jul 13 13:11:44 2009 Subject: [Haskell-cafe] Questions about haskell CPP macros In-Reply-To: <987d172d0907130931i5465a3a6m918a221165b9049a@mail.gmail.com> References: <987d172d0907130931i5465a3a6m918a221165b9049a@mail.gmail.com> Message-ID: <4A5B6E83.7080103@web.de> Matthew Elder wrote: > {-# LANGUAGE CPP #-} > main = putStrLn (__FILE__ ++ ":" ++ show __LINE__) > > This outputs: > test.hs:2 > > Unfortunately, if your file is in a hierarchy of folders, this flat file > name doesn't give much context. Is there a macro to find out the current > module? IE if I had a module Foo.Bar.Car.MyModule, I would like to be > able to output something like this on error: > Foo.Bar.Car.MyModule:2 As mentioned by Claus, template-haskell offers a solution. But in some cases, this is an overkill; consider using Control.Exception.assert, it will provide module and line information without having to use CPP: myHead :: [a] -> a myHead (x:_) = x myHead [] = assert False undefined > > [...] //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From malcolm.wallace at cs.york.ac.uk Mon Jul 13 13:34:36 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Jul 13 13:16:33 2009 Subject: [Haskell-cafe] Questions about haskell CPP macros In-Reply-To: <987d172d0907130931i5465a3a6m918a221165b9049a@mail.gmail.com> References: <987d172d0907130931i5465a3a6m918a221165b9049a@mail.gmail.com> Message-ID: <140BF35B-27BA-43F4-8253-1A2873FC63BB@cs.york.ac.uk> > {-# LANGUAGE CPP #-} > main = putStrLn (__FILE__ ++ ":" ++ show __LINE__) > > This outputs: > test.hs:2 > if I had a module Foo.Bar.Car.MyModule, I would like to be able to > output something like this on error: > Foo.Bar.Car.MyModule:2 It works for me. If you place that text in Try/Me.hs and call ghc -E Try/Me.hs you get Try/Me.hs:2 If you just want to turn slashes into dots, and remove the suffix, that is a simple exercise in Haskell itself main = putStrLn (mangle __FILE__) where mangle ('/':cs) = '.': mangle cs mangle ..... Regards, Malcolm From lrpalmer at gmail.com Mon Jul 13 16:25:38 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jul 13 16:07:34 2009 Subject: [Haskell-cafe] Are GADTs what I need? In-Reply-To: References: Message-ID: <7ca3f0160907131325v2e3624dcy1af2bbdaffa99065@mail.gmail.com> On Mon, Jul 13, 2009 at 6:09 AM, Chris Eidhof wrote: > Hey Kev, > > The types are "thrown away" during compile time. Therefore, if you have a > constructor "VWrapper :: a -> Value" nothing is known about that "a" when > you scrutinize it. > > What you could do, however, is something like this: > > data Value a where >> VInt :: Integer -> Value Integer >> ... >> VWrapper :: a -> Value a >> > > And then you can write a function doSomething: > > doSomething :: Value String -> String >> doSomething (VWrapper s) = s > > I would like to put in a thumbs up on this approach. I'm currently experimenting with interpreters, and have found that parameterizing over the value type works quite smoothly. Specifically, this is my usual starting point for the values: data Value a = VFun (Value a -> Value a) | VPrim a Then I use a typeclass to endow the primitives with the structure they need: class ValueType a where apply :: a -> a -> a Here's a simple interpreter for terms in De Bruijn notation: data Term a = TLit a | TApp (Term a) (Term a) | TLam (Term a) | TVar Int eval :: (ValueType a) => Term a -> [Value a] -> Value a eval (TLit x) = const (VPrim x) eval (TApp x y) = let x' = eval x y' = eval y in \env -> x' env % y' env eval (TLam body) = let body' = eval body in \env -> VFun (\x -> body (x:env)) eval (TVar z) = \env -> env !! z (%) :: (ValueType a) => Value a -> Value a -> Value a VFun f % x = f x VPrim x % VFun _ = error "Apply primitive to function not supported" VPrim x % VPrim y = VLit (x `apply` y) And an example ValueType: data Prim = PInt Int | PSucc instance ValueType Prim where apply PSucc (PInt z) = PInt $! z+1 apply _ _ = error "Type error" This approach has been very nice and modular for experimenting with dynamically typed interpreters. You could support application of literals to functions with some more support from the type class, but it wasn't worth it to me (and would limit the interpretation strategies that I would be able to use). The decision about what suite of primitives to include and how they combine with each other is pushed out to the user, and the interpreter just focuses on the important things: functions. You could even write a little primitive combinator library (perhaps made more composable by switching to dictionary passing for ValueType instead of typeclass), so that users can easily specify any suite of primitives. Anyway, those were just some thoughts for you. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090713/e45c566f/attachment.html From lemming at henning-thielemann.de Mon Jul 13 16:47:55 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Jul 13 16:29:26 2009 Subject: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor) In-Reply-To: <6d942a4a0907071603p6eeb24b0lc8049e6dfe76225a@mail.gmail.com> References: <6d942a4a0907071603p6eeb24b0lc8049e6dfe76225a@mail.gmail.com> Message-ID: <4A5B9D7B.4040105@henning-thielemann.de> George Pollard schrieb: > Ok, so I have a small idea I'm trying to work on; call it a > Prelude-rewrite if you want. For this I want to be able to have the > hierarchy Functor ? Applicative ? Monad. > > For Functor, I would like to be able to implement it for a wider > variety of types, as there are types which have aren't polymorphic > which would also benefit from having an instance. > My running example for this set of types is ByteString; the module > contains the method: > > map ? (Word8 ? Word8) ? ByteString ? ByteString > > However, we cannot use this for Functor because ByteString isn't > polymorphic. To get around this, I devised the following: > > Introduce a type family which represents ?points? inside the type: > > type family Point f ? ? > > For ByteString we have: > > type instance Point ByteString = Word8 > > For a polymorphic example (lists) we have: > > type instance Point [a] = a I had the same in mind for Data.Set with Ord constraint for elements, StorableVector with Storable constraint for the elements, and Control.Monad.Excepetion.Asynchronous monad with Monoid constraint for the monadic result. I tried to come up with a class hierarchy: http://code.haskell.org/~thielema/category-constrained/src/Control/Constrained/ but I encountered the same problem with the Applicative class. Different from what I tried in Applicative.hs I think that the most flexible approach is to convert the ByteString (or Data.Set or StorableVector) to an interim data structure first where you do, say 'liftA3' aka 'zipWith3', then convert back to the real data structure, here ByteString. The interim data structure can be stream-fusion:Data.Stream, i.e. not a real data structure but an algorithm to read from the ByteString. From deduktionstheorem at web.de Mon Jul 13 17:02:07 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Mon Jul 13 16:44:07 2009 Subject: [Haskell-cafe] Questions about haskell CPP macros In-Reply-To: <140BF35B-27BA-43F4-8253-1A2873FC63BB@cs.york.ac.uk> References: <987d172d0907130931i5465a3a6m918a221165b9049a@mail.gmail.com> <140BF35B-27BA-43F4-8253-1A2873FC63BB@cs.york.ac.uk> Message-ID: <4A5BA0CF.6050208@web.de> Malcolm Wallace wrote: > > {-# LANGUAGE CPP #-} >> main = putStrLn (__FILE__ ++ ":" ++ show __LINE__) >> >> This outputs: >> test.hs:2 > >> if I had a module Foo.Bar.Car.MyModule, I would like to be able to >> output something like this on error: >> Foo.Bar.Car.MyModule:2 > > It works for me. If you place that text in Try/Me.hs and call > ghc -E Try/Me.hs > you get > Try/Me.hs:2 > > If you just want to turn slashes into dots, and remove the suffix, that > is a simple exercise in Haskell itself > > main = putStrLn (mangle __FILE__) > where mangle ('/':cs) = '.': mangle cs > mangle ..... Careful, '/' might be '\\' on another OS, the file might end with .hsc instead of .hs, the line numbers might not fit in the .hsc case... -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From Torsten.Kemps-Benedix at sks-ub.de Mon Jul 13 17:56:52 2009 From: Torsten.Kemps-Benedix at sks-ub.de (Kemps-Benedix Torsten) Date: Mon Jul 13 17:57:30 2009 Subject: [Haskell-cafe] Example for formatted show in HStringTemplate Message-ID: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8DB0@SKS-WI-W08-SR07.sks-ub.de> Hello, is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: $day;format="%d.%b.%Y"$ But I only get "toModifiedJulianDay: [54960]" as the result which corresponds to the unformatted show. Regards, Torsten From porges at porg.es Mon Jul 13 20:05:09 2009 From: porges at porg.es (George Pollard) Date: Mon Jul 13 19:47:05 2009 Subject: [Haskell-cafe] Removing polymorphism from type classes (viz. Functor) In-Reply-To: <4A5B9D7B.4040105@henning-thielemann.de> References: <6d942a4a0907071603p6eeb24b0lc8049e6dfe76225a@mail.gmail.com> <4A5B9D7B.4040105@henning-thielemann.de> Message-ID: <6d942a4a0907131705y5bcc7fm736955845493929f@mail.gmail.com> It does seem that having quantified contexts would make this *much* easier... From magicloud.magiclouds at gmail.com Tue Jul 14 01:49:01 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Jul 14 01:30:55 2009 Subject: [Haskell-cafe] How to "Read" this? Message-ID: <3bd412d40907132249x391f836dk7b909c6c7a8c447c@mail.gmail.com> Hi, I have a data structure, which shows like this: AttrBgColor {bgColor = Color 0 0 0} And the following is my Read code. But it failed parsing.... 31 instance Read Attribute where 32 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) <- lex str 33 , (color, rest) <- if (isPrefixOf " {bgColor = " rest1) 34 || (isPrefixOf " {fgColor = " rest1) 35 then case reads $ drop 12 rest1 of 36 [(color_, rest_)] -> [(color_, rest_)] 37 _ -> [(Color 0 0 0, rest1)] 38 else [(Color 0 0 0, rest1)] ] 39 where mkAttr "AttrFgColor" color = AttrFgColor color 40 mkAttr "AttrBgColor" color = AttrBgColor color 41 mkAttr "AttrInverse" _ = AttrInverse 42 mkAttr "AttrWeak" _ = AttrWeak 43 mkAttr "AttrUnderline" _ = AttrUnderline -- ??????? ??????? From ashley at semantic.org Tue Jul 14 01:52:26 2009 From: ashley at semantic.org (Ashley Yakeley) Date: Tue Jul 14 01:34:22 2009 Subject: [Haskell-cafe] Re: Are GADTs what I need? In-Reply-To: <2f9b2d30907130941j55360380j45239d97acbb2c@mail.gmail.com> References: <2f9b2d30907130941j55360380j45239d97acbb2c@mail.gmail.com> Message-ID: <4A5C1D1A.80500@semantic.org> Ryan Ingram wrote: >> data Type a where >> TInt :: Type Int >> TBool :: Type Bool >> TChar :: Type Char >> TList :: Type a -> Type [a] >> TFun :: Type a -> Type b -> Type (a -> b) "Type" here is what I call a simple type witness. Simple type witnesses are useful because they can be compared by value, and if they have the same value, then they have the same type. So you can write this: data EqualType a b where MkEqualType :: EqualType t t matchWitness :: Type a -> Type b -> Maybe (EqualType a b) matchWitness TInt TInt = Just MkEqualType matchWitness TBool TBool = Just MkEqualType matchWitness TChar TChar = Just MkEqualType matchWitness (TList w1) (TList w2) = do MkEqualType <- matchWitness w1 w2 return MkEqualType matchWitness (TFun wa1 wb1) (TFun wa2 wb2) = do MkEqualType <- matchWitness wa1 wa2 MkEqualType <- matchWitness wb1 wb2 return MkEqualType matchWitness _ _ = Nothing Now whenever you match some value with MkEqualType, the compiler will infer the identity of the two types. See my "witness" package: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/witness -- Ashley Yakeley From dagit at codersbase.com Tue Jul 14 02:20:33 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue Jul 14 02:02:29 2009 Subject: [Haskell-cafe] Re: Are GADTs what I need? In-Reply-To: <4A5C1D1A.80500@semantic.org> References: <2f9b2d30907130941j55360380j45239d97acbb2c@mail.gmail.com> <4A5C1D1A.80500@semantic.org> Message-ID: On Mon, Jul 13, 2009 at 10:52 PM, Ashley Yakeley wrote: > Ryan Ingram wrote: > > data Type a where >>> TInt :: Type Int >>> TBool :: Type Bool >>> TChar :: Type Char >>> TList :: Type a -> Type [a] >>> TFun :: Type a -> Type b -> Type (a -> b) >>> >> > "Type" here is what I call a simple type witness. Simple type witnesses are > useful because they can be compared by value, and if they have the same > value, then they have the same type. > > So you can write this: > > data EqualType a b where > MkEqualType :: EqualType t t Is there any reason to prefer this over: data EqualType a b where MkEqualType :: EqualType a a In the darcs source code we use a definition similar to the one I just gave. I never thought about making the definition like you gave. I wonder if it would have changed things, but I'm not sure what. Your example type checks the same with both versions of EqualType and a type signature is required for matchWitness with both definitions. Playing with the two, I don't really see any way in which they are different. Certainly, both versions of MkEqualType have the same type, but I'm just surprised you don't have to involve a or b in the type of MkEqualType. After playing with both definitions for a bit, I think I see why they have the same type and behave the same way. Initially I was thinking t was an existential type, but because of where it appears it is actually universally quantifed, like the type variable 'a' in my version, so they end up being equivalent. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090714/91430642/attachment.html From fiddlosopher at gmail.com Tue Jul 14 02:20:10 2009 From: fiddlosopher at gmail.com (John MacFarlane) Date: Tue Jul 14 02:02:44 2009 Subject: [Haskell-cafe] Re: Example for formatted show in HStringTemplate In-Reply-To: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8DB0@SKS-WI-W08-SR07.sks-ub.de> References: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8DB0@SKS-WI-W08-SR07.sks-ub.de> Message-ID: <20090714062009.GC21391@protagoras.phil.berkeley.edu> +++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]: > Hello, > > is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: > > $day;format="%d.%b.%Y"$ > > But I only get "toModifiedJulianDay: [54960]" as the result which corresponds to the unformatted show. You probably need to define a StringTemplateShows instance for Data.Time.Day, and then use stShowsToSE to define a ToSElem instance. Something like instance StringTemplateShows Day where stringTemplateFormattedShow formatString = formatTime defaultTimeLocale formatString {- or whatever -- I'm not sure what the correct time-formatting function is -} instance ToSElem Day where toSElem = stShowsToSE John From ashley at semantic.org Tue Jul 14 02:33:16 2009 From: ashley at semantic.org (Ashley Yakeley) Date: Tue Jul 14 02:15:11 2009 Subject: [Haskell-cafe] Re: Are GADTs what I need? In-Reply-To: References: <2f9b2d30907130941j55360380j45239d97acbb2c@mail.gmail.com> <4A5C1D1A.80500@semantic.org> Message-ID: <1247553196.11330.1.camel@glastonbury> On Mon, 2009-07-13 at 23:20 -0700, Jason Dagit wrote: > data EqualType a b where > MkEqualType :: EqualType t t > > Is there any reason to prefer this over: > data EqualType a b where > MkEqualType :: EqualType a a They're exactly the same. Yours just looks a bit "left-biased", that's all. -- Ashley Yakeley From lrpalmer at gmail.com Tue Jul 14 02:38:51 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Jul 14 02:20:45 2009 Subject: [Haskell-cafe] Re: Are GADTs what I need? In-Reply-To: <1247553196.11330.1.camel@glastonbury> References: <2f9b2d30907130941j55360380j45239d97acbb2c@mail.gmail.com> <4A5C1D1A.80500@semantic.org> <1247553196.11330.1.camel@glastonbury> Message-ID: <7ca3f0160907132338ne87bad3i630699f28148cd88@mail.gmail.com> On Mon, Jul 13, 2009 at 10:33 PM, Ashley Yakeley wrote: > On Mon, 2009-07-13 at 23:20 -0700, Jason Dagit wrote: > > data EqualType a b where > > MkEqualType :: EqualType t t > > > > Is there any reason to prefer this over: > > data EqualType a b where > > MkEqualType :: EqualType a a > > They're exactly the same. Yours just looks a bit "left-biased", that's > all. For GADTs I prefer the kind color: data EqualType :: * -> * -> * where MkEqualType :: EqualType a a Except I don't usually use it, because I mostly use GADT syntax pedagogically, as introduction to algebraic data types, and introducing kinds just seems to confuse things further. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090714/bae5e360/attachment.html From sargrigory at ya.ru Tue Jul 14 04:37:19 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Tue Jul 14 04:19:18 2009 Subject: [Haskell-cafe] Program with profiling runs faster than without Message-ID: <142921247560639@webmail43.yandex.ru> Hello! I can't understand why the following happens. ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run -prof -auto-all and time ./Run TestSim seems to be much faster (I got ~4 times faster indeed) than just ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run and time ./Run TestSim with ghc 6.8.2 on pentium 4 2.4 GHz under Ubuntu I was on my way to optimize the program when I've discovered this. The program is rather complicated and badly optimized but still I think it is quite strange to the profiled version to run faster. All necessary files I send with this letter (Tann.7z). -------------- next part -------------- A non-text attachment was scrubbed... Name: Tann.7z Type: application/x-7z-compressed Size: 54150 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090714/f027695d/Tann-0001.bin From simonpj at microsoft.com Tue Jul 14 04:59:33 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Jul 14 04:43:45 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <4A59097D.4070605@googlemail.com> References: <4A59097D.4070605@googlemail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) S | -----Original Message----- | From: Charles Turner [mailto:charlie.h.turner@googlemail.com] | Sent: 11 July 2009 22:52 | To: Simon Peyton-Jones | Subject: Haskell as a first language? | | I'll make this short! Do you think Haskell is a good language to start | with? I am brand new to programming and have been using Scheme, some of | my peers suggest I should use Haskell. It seems "professional" to me. | Has features that a beginner should not worry about. What would you | suggest. (I'm not worried about bias) | | Thank you very much for your time. | | Charles Turner. From Andrew.Butterfield at cs.tcd.ie Tue Jul 14 05:08:53 2009 From: Andrew.Butterfield at cs.tcd.ie (Andrew Butterfield) Date: Tue Jul 14 04:50:52 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <4A5C4B25.4070309@cs.tcd.ie> Simon Peyton-Jones wrote: > Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) > > S > > | -----Original Message----- > | From: Charles Turner [mailto:charlie.h.turner@googlemail.com] > | Sent: 11 July 2009 22:52 > | To: Simon Peyton-Jones > | Subject: Haskell as a first language? > | > | I'll make this short! Do you think Haskell is a good language to start > | with? I am brand new to programming and have been using Scheme, some of > | my peers suggest I should use Haskell. It seems "professional" to me. > | Has features that a beginner should not worry about. What would you > | suggest. (I'm not worried about bias) > The biggest probelm with full Haskell for beginners is that many type error messages require some familiarity with the class system, which is not a beginner topic.. However, a good starting point perhaps is Helium - a stripped down version of Haskell designed for teaching, with special care gvien to producing useful helpful error messages... http://www.cs.uu.nl/wiki/Helium Then full Haskell could be introduced in semester 2/ year2 / whatever timeline suits (Anything is better than Java...... sigh ;-) > | > | Thank you very much for your time. > | > | Charles Turner. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- -------------------------------------------------------------------- Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204 Foundations and Methods Research Group Director. School of Computer Science and Statistics, Room F.13, O'Reilly Institute, Trinity College, University of Dublin http://www.cs.tcd.ie/Andrew.Butterfield/ -------------------------------------------------------------------- From jfredett at gmail.com Tue Jul 14 05:57:58 2009 From: jfredett at gmail.com (Joe Fredette) Date: Tue Jul 14 05:39:49 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <4A5C56A6.3010300@gmail.com> If only for the fact that our little Haskell community is composed of about the nicest set of people ever -- I mean, try asking a newbie question on #c sometime -- then Haskell is a great language to learn early. Not only is it great because of it's community, but it's also full of resources -- there are plenty of fun and interesting tutorials to learn with, among the best are Real World Haskell -- it's actually a print book, but you can read it in it's entirety online, give it a google. There's also a nice tutorial called, "Learn you a Haskell for Great Good" (or something like that), I've heard good things about it. By far the best things you can do are subscribe to the Haskell-Cafe mailing list, and get yourself in the #haskell chatroom on freenode. I believe it was Mrs. Frizzle who said it best, "Ask Questions, Make Mistakes, get Haskell-y!!!" /Joe Simon Peyton-Jones wrote: > Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) > > S > > | -----Original Message----- > | From: Charles Turner [mailto:charlie.h.turner@googlemail.com] > | Sent: 11 July 2009 22:52 > | To: Simon Peyton-Jones > | Subject: Haskell as a first language? > | > | I'll make this short! Do you think Haskell is a good language to start > | with? I am brand new to programming and have been using Scheme, some of > | my peers suggest I should use Haskell. It seems "professional" to me. > | Has features that a beginner should not worry about. What would you > | suggest. (I'm not worried about bias) > | > | Thank you very much for your time. > | > | Charles Turner. > > _______________________________________________ > 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/20090714/976577b7/jfredett.vcf From mvanier42 at gmail.com Tue Jul 14 06:01:44 2009 From: mvanier42 at gmail.com (Michael Vanier) Date: Tue Jul 14 05:43:41 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <4A5C5788.9030802@cs.caltech.edu> Simon Peyton-Jones wrote: > Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) > > S > > | -----Original Message----- > | From: Charles Turner [mailto:charlie.h.turner@googlemail.com] > | Sent: 11 July 2009 22:52 > | To: Simon Peyton-Jones > | Subject: Haskell as a first language? > | > | I'll make this short! Do you think Haskell is a good language to start > | with? I am brand new to programming and have been using Scheme, some of > | my peers suggest I should use Haskell. It seems "professional" to me. > | Has features that a beginner should not worry about. What would you > | suggest. (I'm not worried about bias) > | > | Thank you very much for your time. > | > | Charles Turner. > > Charles, Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. My path into Haskell was roughly C -> Python -> Scheme -> Ocaml -> Haskell, and I think that this has a lot going for it (though for a beginner I would recommend Python over Haskell, and Scheme is suitable for beginners with the right textbooks, e.g. How To Design Programs and/or Structure and Interpretation of Computer Programs). If you're willing to work really hard, and don't mind that it may take you quite a bit longer before you are creating real applications in Haskell than it would in e.g. Python, you can start with Haskell (check out the book Real World Haskell: http://realworldhaskell.org). But if you get frustrated, feel free to shift down the list I gave. Scheme or Ocaml are good languages to learn the basics of functional programming, and then you just have to add on the Haskell-specific material (of which there is a lot). Haskell is kind of like a point in the language space that programmers evolve towards. Mike From sargrigory at ya.ru Tue Jul 14 06:09:50 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Tue Jul 14 05:51:47 2009 Subject: [Haskell-cafe] Program with profiling runs faster than without In-Reply-To: <142921247560639@webmail43.yandex.ru> References: <142921247560639@webmail43.yandex.ru> Message-ID: <1541247566190@webmail116.yandex.ru> 14.07.09, 12:37, "Grigory Sarnitskiy" : > Hello! I can't understand why the following happens. > ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run -prof -auto-all > and > time ./Run TestSim > seems to be much faster (I got ~4 times faster indeed) than just > ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run > and > time ./Run TestSim > with ghc 6.8.2 on pentium 4 2.4 GHz under Ubuntu > I was on my way to optimize the program when I've discovered this. The program is rather complicated and badly optimized but still I think it is quite strange to the profiled version to run faster. All necessary files I send with this letter (Tann.7z). Well, I've tested the code with ghc 6.10.3 under Windows --- the result is quite the same, however with the native binary compilier (not via C) the redult is even more drastic. I'm really interested how to obtain the same speed withput profiling compilation. From miguelimo38 at yandex.ru Tue Jul 14 06:11:35 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Jul 14 05:54:38 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <4A5C5788.9030802@cs.caltech.edu> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> Message-ID: <4A5C59D7.3010807@yandex.ru> I disagree. It was easy enough for me. OK, I do have some Category Theory background and it certainly helps a lot. Still, I think that for a beginner (without any experience with C or anything like that) Haskell would be relatively easy. It doesn't involve (at least at the start) an ugly notion of assignment. Michael Vanier wrote: > Simon Peyton-Jones wrote: >> Haskell is a great language! Check out haskell.org. I'm ccing the >> Haskell Cafe which is read by many people better qualified to answer >> your question than me. (Since I've been working on Haskell for many >> years, I am not well qualified to say how it seems to a beginner.) >> >> S >> >> | -----Original Message----- >> | From: Charles Turner [mailto:charlie.h.turner@googlemail.com] >> | Sent: 11 July 2009 22:52 >> | To: Simon Peyton-Jones >> | Subject: Haskell as a first language? >> | | I'll make this short! Do you think Haskell is a good language to >> start >> | with? I am brand new to programming and have been using Scheme, some of >> | my peers suggest I should use Haskell. It seems "professional" to me. >> | Has features that a beginner should not worry about. What would you >> | suggest. (I'm not worried about bias) >> | | Thank you very much for your time. >> | | Charles Turner. >> >> > Charles, > > Haskell is a wonderful language (my favorite language by far) but it is > pretty difficult for a beginner. In fact, it is pretty difficult for > anyone to learn in my experience, because it has so many advanced > concepts that simply don't exist in other languages, and trying to > absorb them all at once will likely be overwhelming. My path into > Haskell was roughly C -> Python -> Scheme -> Ocaml -> Haskell, and I > think that this has a lot going for it (though for a beginner I would > recommend Python over Haskell, and Scheme is suitable for beginners with > the right textbooks, e.g. How To Design Programs and/or Structure and > Interpretation of Computer Programs). If you're willing to work really > hard, and don't mind that it may take you quite a bit longer before you > are creating real applications in Haskell than it would in e.g. Python, > you can start with Haskell (check out the book Real World Haskell: > http://realworldhaskell.org). But if you get frustrated, feel free to > shift down the list I gave. Scheme or Ocaml are good languages to learn > the basics of functional programming, and then you just have to add on > the Haskell-specific material (of which there is a lot). Haskell is > kind of like a point in the language space that programmers evolve towards. > > Mike > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bulat.ziganshin at gmail.com Tue Jul 14 06:22:29 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jul 14 06:04:53 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <4A5C5788.9030802@cs.caltech.edu> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> Message-ID: <782701557.20090714142229@gmail.com> Hello Michael, Tuesday, July 14, 2009, 2:01:44 PM, you wrote: > Haskell is a wonderful language (my favorite language by far) but it is > pretty difficult for a beginner. i believe that Haskell is hard for intermediate programmers already knowing any imperative language, but for beginners it should be ideal -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ketil at malde.org Tue Jul 14 06:36:02 2009 From: ketil at malde.org (Ketil Malde) Date: Tue Jul 14 06:17:56 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago In-Reply-To: <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> (Benjamin L. Russell's message of "Tue\, 14 Jul 2009 19\:23\:11 +0900") References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> Message-ID: <871vojk0vh.fsf@malde.org> [redirected from haskell@] Benjamin L.Russell writes: >> One often amusing outgrowth of this is that FP (OOP) fanatics anthropomorphize >> their functions (objects). Well, I don't think we do. Functions are just mappings of values to values, they may be opaque, but they're predictable, unchanging, and just...too boring to be antropomorphized. Objects contain all kinds of hidden state and dependencies, and the sheer unpredicatability of it all is the reason for the anthropomorphics - it a symptom of a disease, not a desirable quality. -k -- If I haven't seen further, it is by standing in the footprints of giants From Torsten.Kemps-Benedix at sks-ub.de Tue Jul 14 06:20:19 2009 From: Torsten.Kemps-Benedix at sks-ub.de (Kemps-Benedix Torsten) Date: Tue Jul 14 06:21:10 2009 Subject: [Haskell-cafe] AW: Example for formatted show in HStringTemplate In-Reply-To: <20090714062009.GC21391@protagoras.phil.berkeley.edu> References: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8DB0@SKS-WI-W08-SR07.sks-ub.de> <20090714062009.GC21391@protagoras.phil.berkeley.edu> Message-ID: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8E75@SKS-WI-W08-SR07.sks-ub.de> John, thanks for your answer, but HStringtemplate has instance definitions for Date.Time.Day. The question is more on the script side: How do I have to write the ST calls with ";format=" embedded in HTML? regards, Torsten -----Urspr?ngliche Nachricht----- Von: John MacFarlane [mailto:fiddlosopher@gmail.com] Gesendet: Dienstag, 14. Juli 2009 08:20 An: Kemps-Benedix Torsten Cc: HAppS@googlegroups.com; haskell-cafe@haskell.org Betreff: Re: Example for formatted show in HStringTemplate +++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]: > Hello, > > is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: > > $day;format="%d.%b.%Y"$ > > But I only get "toModifiedJulianDay: [54960]" as the result which corresponds to the unformatted show. You probably need to define a StringTemplateShows instance for Data.Time.Day, and then use stShowsToSE to define a ToSElem instance. Something like instance StringTemplateShows Day where stringTemplateFormattedShow formatString = formatTime defaultTimeLocale formatString {- or whatever -- I'm not sure what the correct time-formatting function is -} instance ToSElem Day where toSElem = stShowsToSE John From malcolm.wallace at cs.york.ac.uk Tue Jul 14 07:16:42 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Jul 14 06:58:37 2009 Subject: [Haskell-cafe] Program with profiling runs faster than without In-Reply-To: <1541247566190@webmail116.yandex.ru> References: <142921247560639@webmail43.yandex.ru> <1541247566190@webmail116.yandex.ru> Message-ID: <8101493D-60C8-467F-95A7-E84DF0022BCE@cs.york.ac.uk> On 14 Jul 2009, at 11:09, Grigory Sarnitskiy wrote: >> I think it is quite strange to the profiled version to run faster >> I'm really interested how to obtain the same speed withput >> profiling compilation. This is only a guess, but maybe there is a context-qualified CAF-like value that is being re-evaluated multiple times in the non-profiling case, but is appropriately monomorphised in the profiling case, so it is only evaluated once? Regards, Malcolm From duncan.coutts at worc.ox.ac.uk Tue Jul 14 07:48:35 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jul 14 07:30:13 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <4A5C5788.9030802@cs.caltech.edu> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> Message-ID: <1247572115.22466.8968.camel@localhost> On Tue, 2009-07-14 at 03:01 -0700, Michael Vanier wrote: > Charles, > > Haskell is a wonderful language (my favorite language by far) but it is > pretty difficult for a beginner. In fact, it is pretty difficult for > anyone to learn in my experience, because it has so many advanced > concepts that simply don't exist in other languages, and trying to > absorb them all at once will likely be overwhelming. As a contrary data-point, at Oxford we teach functional programming (using Haskell) as the first course at the very beginning of the computer science degree. I know several other universities also use FP and Haskell very early on in their CS courses. On the Oxford course about half the students have had significant previous programming experience. There does not appear to be a significant difference in how quickly students with little previous programming experience learn FP compared to those with more programming experience (keep in mind these are young people, not mature students with years of professional programming experience). The point is, it's not at all clear that it's a harder language for beginners. Unfortunately, it rather hard to gather decent evidence about learning on which one could base decisions on the choice of language. Duncan From patai_gergely at fastmail.fm Tue Jul 14 09:30:33 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Tue Jul 14 09:12:27 2009 Subject: [Haskell-cafe] What to say about Haskell? Message-ID: <1247578233.16940.1324987381@webmail.messagingengine.com> Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? Gergely -- http://www.fastmail.fm - Same, same, but different... From tom.davie at gmail.com Tue Jul 14 09:42:44 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Tue Jul 14 09:24:42 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <1247578233.16940.1324987381@webmail.messagingengine.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> Message-ID: <975CA4CD-BBDB-432B-85C7-CC9972D14339@gmail.com> On 14 Jul 2009, at 15:30, Patai Gergely wrote: > Hello all, > > I was asked to give a one-hour 'introductory' seminar on Haskell. The > audience is a bunch of very clever people with a wider than usual > perspective on programming and mathematics, and my talk should be > rather > informational than evangelistic. Which topics do you think I should > touch by all means given the short time? Lazyness and the many funky things it lets you do -- there's tons of elegant programs that are only possible because of lazyness :) Bob From magnus at therning.org Tue Jul 14 09:50:22 2009 From: magnus at therning.org (Magnus Therning) Date: Tue Jul 14 09:32:16 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <975CA4CD-BBDB-432B-85C7-CC9972D14339@gmail.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> <975CA4CD-BBDB-432B-85C7-CC9972D14339@gmail.com> Message-ID: On Tue, Jul 14, 2009 at 2:42 PM, Thomas Davie wrote: > > On 14 Jul 2009, at 15:30, Patai Gergely wrote: > >> Hello all, >> >> I was asked to give a one-hour 'introductory' seminar on Haskell. The >> audience is a bunch of very clever people with a wider than usual >> perspective on programming and mathematics, and my talk should be rather >> informational than evangelistic. Which topics do you think I should >> touch by all means given the short time? > > Lazyness and the many funky things it lets you do -- there's tons of elegant > programs that are only possible because of lazyness :) I'd add type-classes to that. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From frodo at theshire.org Tue Jul 14 09:55:41 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Jul 14 09:37:56 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <975CA4CD-BBDB-432B-85C7-CC9972D14339@gmail.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> <975CA4CD-BBDB-432B-85C7-CC9972D14339@gmail.com> Message-ID: On Tue, Jul 14, 2009 at 3:42 PM, Thomas Davie wrote: > > On 14 Jul 2009, at 15:30, Patai Gergely wrote: > >> Hello all, >> >> I was asked to give a one-hour 'introductory' seminar on Haskell. The >> audience is a bunch of very clever people with a wider than usual >> perspective on programming and mathematics, and my talk should be rather >> informational than evangelistic. Which topics do you think I should >> touch by all means given the short time? > > Lazyness and the many funky things it lets you do -- there's tons of elegant > programs that are only possible because of lazyness :) I would like to know them. I'm looking for small snippets of code that are elegant when written in Haskell (which is lazy by default) but not in other languages supporting some form of laziness (like Python+Iterators). Can you post some? Cristiano From frodo at theshire.org Tue Jul 14 10:01:14 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Jul 14 09:43:26 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <1247578233.16940.1324987381@webmail.messagingengine.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> Message-ID: 2009/7/14 Patai Gergely : > Hello all, > > I was asked to give a one-hour 'introductory' seminar on Haskell. The > audience is a bunch of very clever people with a wider than usual > perspective on programming and mathematics, and my talk should be rather > informational than evangelistic. Which topics do you think I should > touch by all means given the short time? When you create the presentation, please consider the big picture of Haskell, not only its technological features like laziness, curryfication, HOF, monadic syntax, type inference, type classes and so on. I would concentrate on the fact that when you use Haskell, you write code that is less prone to errors and bugs. When you write a program in Haskell and it finally compiles, chances are that there are far less bugs than in a program written in another language (I'm thinking about so popular dynamic languages like Python and Ruby): hunting for "semantic" errors is a significantly shorter task. This comes directly from the technological features I mentioned above: they are in the language for a purpose. My 2 cents. Cristiano From wagner.andrew at gmail.com Tue Jul 14 10:03:03 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue Jul 14 09:44:56 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: References: <1247578233.16940.1324987381@webmail.messagingengine.com> <975CA4CD-BBDB-432B-85C7-CC9972D14339@gmail.com> Message-ID: http://www.haskell.org/haskellwiki/Tying_the_Knot would seem to be relevant. On Tue, Jul 14, 2009 at 9:55 AM, Cristiano Paris wrote: > > > I would like to know them. > > I'm looking for small snippets of code that are elegant when written > in Haskell (which is lazy by default) but not in other languages > supporting some form of laziness (like Python+Iterators). > > Can you post some? > > Cristiano > _______________________________________________ > 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/20090714/571de712/attachment.html From miguelimo38 at yandex.ru Tue Jul 14 10:05:11 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Jul 14 09:48:15 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <1247578233.16940.1324987381@webmail.messagingengine.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> Message-ID: <4A5C9097.3030303@yandex.ru> Domain theory semantics, I guess. I know, that if I (or rather a younger copy of me, not knowing a thing about Haskell) would be one of your students, and you tell me that there is such a clean and nice semantics for what we are doing, I'd be excited. Patai Gergely wrote: > Hello all, > > I was asked to give a one-hour 'introductory' seminar on Haskell. The > audience is a bunch of very clever people with a wider than usual > perspective on programming and mathematics, and my talk should be rather > informational than evangelistic. Which topics do you think I should > touch by all means given the short time? > > Gergely > From sargrigory at ya.ru Tue Jul 14 10:07:54 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Tue Jul 14 09:49:48 2009 Subject: [Haskell-cafe] Program with profiling runs faster than without Message-ID: <32971247580474@webmail62.yandex.ru> 14.07.09, 15:16, "Malcolm Wallace" : > This is only a guess, but maybe there is a context-qualified CAF-like > value that is being re-evaluated multiple times in the non-profiling > case, but is appropriately monomorphised in the profiling case, so it > is only evaluated once? > Regards, > Malcolm And I guess you are quite right. I knew there is a poorly optimized place in my program, but I didn't touch it for some ideological reasons. But this morning I get how to optimize it in an ideological friendly manner, so now without profiling the program ~ 2 times faster. The speed of profiled version hasn't changed, hence I've manually done some work the compiler does during profiling. From s.clover at gmail.com Tue Jul 14 10:33:49 2009 From: s.clover at gmail.com (Sterling Clover) Date: Tue Jul 14 10:15:43 2009 Subject: AW: [Haskell-cafe] Example for formatted show in HStringTemplate In-Reply-To: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8E75@SKS-WI-W08-SR07.sks-ub.de> References: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8DB0@SKS-WI-W08-SR07.sks-ub.de> <20090714062009.GC21391@protagoras.phil.berkeley.edu> <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8E75@SKS-WI-W08-SR07.sks-ub.de> Message-ID: <24480823.post@talk.nabble.com> What I suspect that you've encountered is an infelicity when importing GenericStandard. The ToSElem instance defaults to that provided by (Data a) context. However, there is no special handler for Data.Time types in the `extQ` chain. I could add one, but that would require relying on the Data.Time library being the latest (since Typeable isn't provided until then) or on conditional compilation and standalone deriving, which is a pain. As the new time package comes into widespread use, I'll fix up the gToSElem function with the appropriate handlers, but until then I'm afraid that standard generics won't play well with Data.Time. GenericWithClass, on the other hand, might yield better results. There is, by the way, (thanks to the efforts of Luke Plant) now an HStringTemplate page on the haskellwiki: http://www.haskell.org/haskellwiki/HStringTemplate. Edits, improvements, etc. of course welcome by all. You may want to post this question and answer there. By the way, I plan to have a new version with a real announcement and a fair share of bugfixes in the next week or so. Cheers, Sterl. Kemps-Benedix Torsten wrote: > > John, > > thanks for your answer, but HStringtemplate has instance definitions for > Date.Time.Day. The question is more on the script side: How do I have to > write the ST calls with ";format=" embedded in HTML? > > regards, > > Torsten > > > > -----Urspr?ngliche Nachricht----- > Von: John MacFarlane [mailto:fiddlosopher@gmail.com] > Gesendet: Dienstag, 14. Juli 2009 08:20 > An: Kemps-Benedix Torsten > Cc: HAppS@googlegroups.com; haskell-cafe@haskell.org > Betreff: Re: Example for formatted show in HStringTemplate > > +++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]: >> Hello, >> >> is there a working example of how to use the format clause with >> HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter >> $day$, a reasonable template might contain e.g.: >> >> $day;format="%d.%b.%Y"$ >> >> But I only get "toModifiedJulianDay: [54960]" as the result which >> corresponds to the unformatted show. > > You probably need to define a StringTemplateShows instance for > Data.Time.Day, and then use stShowsToSE to define a ToSElem instance. > Something like > > instance StringTemplateShows Day > where stringTemplateFormattedShow formatString = formatTime > defaultTimeLocale formatString > {- or whatever -- I'm not sure what the correct time-formatting > function is -} > > instance ToSElem Day > where toSElem = stShowsToSE > > John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Example-for-formatted-show-in-HStringTemplate-tp24470429p24480823.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From magnus at therning.org Tue Jul 14 10:36:42 2009 From: magnus at therning.org (Magnus Therning) Date: Tue Jul 14 10:18:53 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: References: <1247578233.16940.1324987381@webmail.messagingengine.com> Message-ID: On Tue, Jul 14, 2009 at 3:01 PM, Cristiano Paris wrote: > 2009/7/14 Patai Gergely : >> Hello all, >> >> I was asked to give a one-hour 'introductory' seminar on Haskell. The >> audience is a bunch of very clever people with a wider than usual >> perspective on programming and mathematics, and my talk should be rather >> informational than evangelistic. Which topics do you think I should >> touch by all means given the short time? > > When you create the presentation, please consider the big picture of > Haskell, not only its technological features like laziness, > curryfication, HOF, monadic syntax, type inference, type classes and > so on. > > I would concentrate on the fact that when you use Haskell, you write > code that is less prone to errors and bugs. When you write a program > in Haskell and it finally compiles, chances are that there are far > less bugs than in a program written in another language (I'm thinking > about so popular dynamic languages like Python and Ruby): hunting for > "semantic" errors is a significantly shorter task. > > This comes directly from the technological features I mentioned above: > they are in the language for a purpose. > > My 2 cents. And maybe adding that Haskell seems to make it easy to concentrate on data flow rather than control flow. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From bulat.ziganshin at gmail.com Tue Jul 14 10:46:07 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jul 14 10:28:08 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: References: <1247578233.16940.1324987381@webmail.messagingengine.com> Message-ID: <1256621761.20090714184607@gmail.com> Hello Cristiano, Tuesday, July 14, 2009, 6:01:14 PM, you wrote: > When you create the presentation, please consider the big picture of > Haskell, not only its technological features like laziness, > curryfication, HOF, monadic syntax, type inference, type classes and > so on. > I would concentrate on the fact that when you use Haskell, you write > code that is less prone to errors and bugs. When you write a program > in Haskell and it finally compiles, chances are that there are far > less bugs than in a program written in another language the question is how to justify this in 1 hour. technical people don't buy such arguments with justification. but if it will be done, it would be best presentation possible -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jefferson.r.heard at gmail.com Tue Jul 14 10:46:59 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Tue Jul 14 10:29:11 2009 Subject: [Haskell-cafe] Problem resizing widget contained in window Message-ID: <4165d3a70907140746h4c25511bwce6a3bf078eefa1b@mail.gmail.com> I created a window, like so: Gtk.windowSetTitle win name Gtk.widgetSetName win "Hieroglyph" Gtk.onDestroy win (exitWith ExitSuccess) Gtk.windowSetDefaultSize win w h Gtk.containerResizeChildren win And an GLDrawingArea like so: config ? Gtk.glConfigNew [Gtk.GLModeRGBA, Gtk.GLModeMultiSample, Gtk.GLModeDouble, Gtk.GLModeDepth, Gtk.GLModeAlpha] area ? Gtk.glDrawingAreaNew config Gtk.onRealize area ? GL.drawBuffer $= GL.BackBuffers Gtk.onExpose area (?_ ? renderOnExpose bus ? return True) and finally show it like this: Gtk.containerAdd win area Gtk.widgetShowAll win Now, if someone resizes the window, the GLArea does not appear to resize along with it. Did I screw something up? -- Jeff From frodo at theshire.org Tue Jul 14 11:12:40 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Jul 14 10:54:53 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <1256621761.20090714184607@gmail.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> <1256621761.20090714184607@gmail.com> Message-ID: On Tue, Jul 14, 2009 at 4:46 PM, Bulat Ziganshin wrote: > ... > the question is how to justify this in 1 hour. technical people don't > buy such arguments with justification. but if it will be done, it > would be best presentation possible I think it's important to elaborate on this. Why don't we create a specific Wiki page about "Haskell advocation", developing contents suitable for a presentation to be delivered to an Haskell-unware audience? That would be useful to those people "spreading the word" :) Cristiano From rmm-haskell at z.odi.ac Tue Jul 14 11:24:06 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Jul 14 11:06:04 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <782701557.20090714142229@gmail.com> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> <782701557.20090714142229@gmail.com> Message-ID: <958253FA-E3BA-4F8E-9CE8-F566FA2DB964@z.odi.ac> I agree -- I think the most major learning curve problem (for me) was not learning haskell directly, it was un-learning all those patterns and workarounds and so on from imperative/OOP languages. Of course, the only problem with learning haskell first is that one will probably be mildly annoyed by most of the more common programming languages ;-) -Ross On Jul 14, 2009, at 6:22 AM, Bulat Ziganshin wrote: > Hello Michael, > > Tuesday, July 14, 2009, 2:01:44 PM, you wrote: > >> Haskell is a wonderful language (my favorite language by far) but >> it is >> pretty difficult for a beginner. > > i believe that Haskell is hard for intermediate programmers already > knowing any imperative language, but for beginners it should be ideal > > > -- > 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 frodo at theshire.org Tue Jul 14 11:42:28 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Jul 14 11:24:42 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: References: <1247578233.16940.1324987381@webmail.messagingengine.com> <1256621761.20090714184607@gmail.com> Message-ID: On Tue, Jul 14, 2009 at 5:12 PM, Cristiano Paris wrote: > ... > Why don't we create a specific Wiki page about "Haskell advocation", http://haskell.org/haskellwiki/Advocation Cristiano From mxcantor at gmail.com Tue Jul 14 11:46:06 2009 From: mxcantor at gmail.com (Max Cantor) Date: Tue Jul 14 11:28:07 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: References: <1247578233.16940.1324987381@webmail.messagingengine.com> <1256621761.20090714184607@gmail.com> Message-ID: Any chance of renaming it to "Advocacy"? On Jul 14, 2009, at 11:42 PM, Cristiano Paris wrote: > On Tue, Jul 14, 2009 at 5:12 PM, Cristiano Paris > wrote: >> ... >> Why don't we create a specific Wiki page about "Haskell advocation", > > http://haskell.org/haskellwiki/Advocation > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From tom.davie at gmail.com Tue Jul 14 12:06:26 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Tue Jul 14 11:48:31 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <1247572115.22466.8968.camel@localhost> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> <1247572115.22466.8968.camel@localhost> Message-ID: On 14 Jul 2009, at 13:48, Duncan Coutts wrote: > On Tue, 2009-07-14 at 03:01 -0700, Michael Vanier wrote: > >> Charles, >> >> Haskell is a wonderful language (my favorite language by far) but >> it is >> pretty difficult for a beginner. In fact, it is pretty difficult for >> anyone to learn in my experience, because it has so many advanced >> concepts that simply don't exist in other languages, and trying to >> absorb them all at once will likely be overwhelming. > > As a contrary data-point, at Oxford we teach functional programming > (using Haskell) as the first course at the very beginning of the > computer science degree. I know several other universities also use FP > and Haskell very early on in their CS courses. On the Oxford course > about half the students have had significant previous programming > experience. There does not appear to be a significant difference in > how > quickly students with little previous programming experience learn FP > compared to those with more programming experience (keep in mind these > are young people, not mature students with years of professional > programming experience). > > The point is, it's not at all clear that it's a harder language for > beginners. Unfortunately, it rather hard to gather decent evidence > about > learning on which one could base decisions on the choice of language. What I'd be interested to see is how fast beginners pick up haskell compared to imperative language ? is it actually hard to learn, or do we just forget how hard it was to learn a new paradigm when we first learned imperative programming. I guess it's rather hard to establish a metric for how fast the learning occurs though. Bob From dons at galois.com Tue Jul 14 12:05:40 2009 From: dons at galois.com (Don Stewart) Date: Tue Jul 14 11:49:55 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <1247578233.16940.1324987381@webmail.messagingengine.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> Message-ID: <20090714160540.GA20564@whirlpool.galois.com> patai_gergely: > Hello all, > > I was asked to give a one-hour 'introductory' seminar on Haskell. The > audience is a bunch of very clever people with a wider than usual > perspective on programming and mathematics, and my talk should be rather > informational than evangelistic. Which topics do you think I should > touch by all means given the short time? I'd concentrate on the "getting things done" aspect. E.g. the efficient production of programs that utilize parallelism in different ways, something Haskell's particularly well suited for. Here's the talk I gave at Supercomputing 08, based on Simon and Satnam's summer tutorial: http://www.galois.com/blog/2008/11/12/beautiful-parallelism-harnessing-multicores-with-haskell/ Parallel programs, multicore programs == real dollar value. Lazy programs, cute but not easy to quantify the benefit. -- Don From patai_gergely at fastmail.fm Tue Jul 14 12:26:43 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Tue Jul 14 12:08:35 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <1256621761.20090714184607@gmail.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> <1256621761.20090714184607@gmail.com> Message-ID: <1247588803.27485.1325018005@webmail.messagingengine.com> > > I would concentrate on the fact that when you use Haskell, you write > > code that is less prone to errors and bugs. When you write a program > > in Haskell and it finally compiles, chances are that there are far > > less bugs than in a program written in another language > > the question is how to justify this in 1 hour. technical people don't > buy such arguments with justification. but if it will be done, it > would be best presentation possible That's not really the direction I'd like to take anyway, because as I said, the primary goal of this talk is not to convince these people to use Haskell, but to give them an overview that's "more helpful than reading a book", and it should definitely introduce specific language features and important patterns besides the general talk. The question is which topics are noteworthy. But here's some more context for you: My talk will be the second (there's one every week). The first one will be a comparison of Prolog and Haskell by an expert of the former (not surprisingly a rather mathematically minded fellow), and the third one will be about monads in category theory. Also, the initiator of the seminars is mostly interested in processing natural languages, so it might be a good idea to bring up at least one relevant example -- for instance, the latest post on sigfpe's blog could be nice, but it comes with too many prerequisites. Gergely -- http://www.fastmail.fm - Access your email from home and the web From jake.mcarthur at gmail.com Tue Jul 14 12:36:22 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Tue Jul 14 12:18:30 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <4A5C5788.9030802@cs.caltech.edu> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> Message-ID: <4A5CB406.4010606@gmail.com> Michael Vanier wrote: > Haskell is a wonderful language (my favorite language by far) but it is > pretty difficult for a beginner. In fact, it is pretty difficult for > anyone to learn in my experience, because it has so many advanced > concepts that simply don't exist in other languages, and trying to > absorb them all at once will likely be overwhelming. I disagree, based on seeing my wife learn some Haskell with basically no previous experience programming. It was thrilling to see her learn some concepts almost instantly that it actually took me a while to understand because I had preconceived notions of how programming should work. When I talk about how other programming languages do things she thinks it's stupid. For example, I mentioned that you can actually change the values of variables in most other programming languages, and often have to, and she asked how anything understandable gets written that way. I also noticed that when I kept emphasizing that you can pass functions as parameters to other functions she was getting bored; it seemed that it simply would not have made sense any other way. I see no reason why learning more concepts on top of this foundation should be all that hard for her. - Jake From matthias.goergens at googlemail.com Tue Jul 14 12:51:48 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Jul 14 12:33:43 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <1247588803.27485.1325018005@webmail.messagingengine.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> <1256621761.20090714184607@gmail.com> <1247588803.27485.1325018005@webmail.messagingengine.com> Message-ID: Dear Gergely, Okasaki's "Purely Functional Data Structures" is a treasure trove of interesting things to demonstrate Haskell on. Especially the data structures based on numerical representations (skew binary numbers and so on) appealed to my mathematical side. Matthias. From dons at galois.com Tue Jul 14 12:51:02 2009 From: dons at galois.com (Don Stewart) Date: Tue Jul 14 12:34:58 2009 Subject: [Haskell-cafe] What to say about Haskell? In-Reply-To: <1247588803.27485.1325018005@webmail.messagingengine.com> References: <1247578233.16940.1324987381@webmail.messagingengine.com> <1256621761.20090714184607@gmail.com> <1247588803.27485.1325018005@webmail.messagingengine.com> Message-ID: <20090714165102.GC20564@whirlpool.galois.com> patai_gergely: > > > I would concentrate on the fact that when you use Haskell, you write > > > code that is less prone to errors and bugs. When you write a program > > > in Haskell and it finally compiles, chances are that there are far > > > less bugs than in a program written in another language > > > > the question is how to justify this in 1 hour. technical people don't > > buy such arguments with justification. but if it will be done, it > > would be best presentation possible > That's not really the direction I'd like to take anyway, because as I > said, the primary goal of this talk is not to convince these people to > use Haskell, but to give them an overview that's "more helpful than > reading a book", and it should definitely introduce specific language > features and important patterns besides the general talk. The question > is which topics are noteworthy. But here's some more context for you: > > My talk will be the second (there's one every week). The first one will > be a comparison of Prolog and Haskell by an expert of the former (not > surprisingly a rather mathematically minded fellow), and the third one > will be about monads in category theory. Also, the initiator of the > seminars is mostly interested in processing natural languages, so it > might be a good idea to bring up at least one relevant example -- for > instance, the latest post on sigfpe's blog could be nice, but it comes > with too many prerequisites. See also Simon Peyton Jones' intro to Haskell, recently: http://erlang-factory.com/upload/presentations/116/SimonPeyton-Jones-ErlangFactoryLondon2009-HaskellandErlangGrowinguptogether.pdf http://www.erlang-factory.com/conference/London2009/speakers/SimonPeytonJones And one big difference from Prolog: centralized community resources. One main implementation, one distribution mechanism, one build system, one central library archive. -- Don From fiddlosopher at gmail.com Tue Jul 14 12:55:10 2009 From: fiddlosopher at gmail.com (John MacFarlane) Date: Tue Jul 14 12:37:46 2009 Subject: [Haskell-cafe] Re: AW: Example for formatted show in HStringTemplate In-Reply-To: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8E75@SKS-WI-W08-SR07.sks-ub.de> References: <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8DB0@SKS-WI-W08-SR07.sks-ub.de> <20090714062009.GC21391@protagoras.phil.berkeley.edu> <01E874EAF39B9B41831ADD8E154AB02D0AD5DA8E75@SKS-WI-W08-SR07.sks-ub.de> Message-ID: <20090714165510.GC12794@protagoras.phil.berkeley.edu> Torsten, I'm not quite sure what you're asking -- but this simple example seems to work fine: Prelude Text.StringTemplate> let (a :: StringTemplate String) = newSTMP "$day;format=\"%d.%b.%Y\"$" Prelude Text.StringTemplate Data.Time> render $ setAttribute "day" (ModifiedJulianDay 234) a "09.Jul.1859" John +++ Kemps-Benedix Torsten [Jul 14 09 12:20 ]: > John, > > thanks for your answer, but HStringtemplate has instance definitions for Date.Time.Day. The question is more on the script side: How do I have to write the ST calls with ";format=" embedded in HTML? > > regards, > > Torsten > > > > -----Urspr?ngliche Nachricht----- > Von: John MacFarlane [mailto:fiddlosopher@gmail.com] > Gesendet: Dienstag, 14. Juli 2009 08:20 > An: Kemps-Benedix Torsten > Cc: HAppS@googlegroups.com; haskell-cafe@haskell.org > Betreff: Re: Example for formatted show in HStringTemplate > > +++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]: > > Hello, > > > > is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: > > > > $day;format="%d.%b.%Y"$ > > > > But I only get "toModifiedJulianDay: [54960]" as the result which corresponds to the unformatted show. > > You probably need to define a StringTemplateShows instance for > Data.Time.Day, and then use stShowsToSE to define a ToSElem instance. > Something like > > instance StringTemplateShows Day > where stringTemplateFormattedShow formatString = formatTime defaultTimeLocale formatString > {- or whatever -- I'm not sure what the correct time-formatting function is -} > > instance ToSElem Day > where toSElem = stShowsToSE > > John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gds at doc.ic.ac.uk Tue Jul 14 13:11:45 2009 From: gds at doc.ic.ac.uk (Gareth Smith) Date: Tue Jul 14 12:53:54 2009 Subject: [Haskell-cafe] Haskell as a first language? In-Reply-To: <55AB1158A5CBC842BA71EE467913CE350B8ADE4E@icexm6.ic.ac.uk> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> <55AB1158A5CBC842BA71EE467913CE350B8ADE4E@icexm6.ic.ac.uk> Message-ID: <1247590801-sup-2727@zenit.elvum.net> > On Tue, 2009-07-14 at 03:01 -0700, Michael Vanier wrote: > > Haskell is a wonderful language (my favorite language by far) but it is > > pretty difficult for a beginner. In fact, it is pretty difficult for > > anyone to learn in my experience, because it has so many advanced > > concepts that simply don't exist in other languages, and trying to > > absorb them all at once will likely be overwhelming. Then Duncan said: > As a contrary data-point, at Oxford we teach functional programming > (using Haskell) as the first course at the very beginning of the > computer science degree. I know several other universities also use FP > and Haskell very early on in their CS courses. At Imperial College, Haskell's also the first language the undergrads touch and people seem to like it. I think it's easy to forget how reassuring it is to be surrounded by lots of other beginners when one is learning something completely new - like programming. A lot of people here seem to be suggesting that haskell is an advanced language for advanced programmers. I think it more likely that people whose first experience of haskell is online are likely to come into contact with mostly advanced programmers in here and on #haskell. This is great, because they can teach us things - but it can also be off-putting, because they can seem so far beyond us. Imagine trying to learn basic arithmetic in a university common room full of category theorists. Personally, I think that haskell is a great beginners language. Just don't feel that you have to be able to keep up with all the #haskellers. It's absolutely fine to not understand what a monad transformer is. G From jeremy at n-heptane.com Tue Jul 14 13:15:25 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Tue Jul 14 12:57:19 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <4A5C5788.9030802@cs.caltech.edu> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> Message-ID: <87fxczgp8y.wl%jeremy@n-heptane.com> At Tue, 14 Jul 2009 03:01:44 -0700, Michael Vanier wrote: > Haskell is a wonderful language (my favorite language by far) but it is > pretty difficult for a beginner. In fact, it is pretty difficult for > anyone to learn in my experience, because it has so many advanced > concepts that simply don't exist in other languages, and trying to > absorb them all at once will likely be overwhelming. I think that all programming languages are hard to learn, because it involves a new way of thinking. It maybe be that Haskell is harder to learn as your *second* language because you have to unlearn things. Especially if your first language was something like C or Python. Additionally, I suspect people forget how hard it was to learn their first language. They get used to the idea that if they know Python, they can learn Ruby with out to much difficulty. But that is only because Python and Ruby share a lot in common. When moving from Python to Haskell, there is simply more to learn (and unlearn). But, if you start by knowing nothing, then it is not clear that you have to learn more to learn Haskell than you would some other language. Also, Haskell may be easier to learn because it's concepts are more 'pricipled' and 'sensible'. Imperative languages tend to allow all sorts of silly errors. For example, letting you use unitialized variables (nearly impossible to do in Haskell). And automatic type casting has burned me so many times. (Especially automatic conversion between floating ponit numbers and integers.) I seldom get off-by-one errors in Haskell, but I do get them in imperative/OOP languages. I suspect that if you don't know any language and want to become a Haskell expert as quickly as possible, then the quickest, straigtest path is to start with Haskell. Also, it depends on what you mean by 'learn' and 'Haskell'. Just as a beginning C++ programmer is not going to learn about templates on day one, a beginner Haskell programmer probably won't be learning type families on day one. Additionally, Haskell includes numerous libraries which are not part of the language itself. Things like parser combinators, pretty printing, applicative functors, etc, are all just libraries. But each of those libraries brings a bunch of new concepts. - jeremy From kyagrd at gmail.com Tue Jul 14 13:20:03 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Tue Jul 14 13:02:29 2009 Subject: [Haskell-cafe] Re: Goldman Sachs - your home for OCaml and Erlang? In-Reply-To: References: Message-ID: Max Cantor wrote: > I know that this is a bit off topic, but thought it would interest > several readers. Apparently, GS, which. AFAIK, doesn't make a lot of > noise in the FP space compared to some other banks, does use some FP: > > http://www.zerohedge.com/article/aleynikov-code-dump-uncovered The link you gave seems controversial. But there is a more relative product based on OCaml that GS actually uses (or have used): http://www.lexifi.com/press_2002-09-02.html From kyagrd at gmail.com Tue Jul 14 13:40:51 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Tue Jul 14 13:23:19 2009 Subject: [Haskell-cafe] Re: Haskell as a first language? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: Before teaching any data structure course, one MUST learn functional languages with ADTs. It makes everything so easy to understand. So, it MUST be a first language in every institution. The biggest reason that one should learn functional languages with algebraic data type(ADT)s first is because understanding recursive definitions. If you recursion first, understanding iteration and mutable data structures are dead simple and easy: they are just alternate representation or optimization. However, when you learn while loops and for loops first, your brain gets damaged and a lot of students gets stuck when they first see the Tower of Hanoi, the notorious in-place quicksort routine written in imperative languages, you'll get to think of recursion as some stack blowing up monster that must be unrolled and managed manually. Furthermore, learning data structures in most traditional imperative language literature gives you the impression that linked list and binary trees are brain-fucking spaghetti monsters of memory pointers all the cells, which is a dead simple recursive definition in functional languages with ADTs. Personally, I never really understood what linked list was before I learned ML and Haskell, although I've used doubly linked list in a C++ standard library, which was to me a black box that meets the specification in some huge standard document, for two years. From felipe.lessa at gmail.com Tue Jul 14 14:03:09 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Jul 14 13:45:10 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: StateVar 1.0.0.0 In-Reply-To: <200907141916.41758.Sven.Panne@aedion.de> References: <200907141916.41758.Sven.Panne@aedion.de> Message-ID: <20090714180309.GA12376@kira.casa> On Tue, Jul 14, 2009 at 07:16:41PM +0200, Sven Panne wrote: > To further modularize the OpenGL/OpenAL packages, a new > StateVar package has been released to Hackage. It contains > state variables, which are references in the IO monad, like > IORefs or parts of the OpenGL state. That's just great, thanks a lot! I was just going to ask if you had any plans of releasing it in the near future. Now, do you have any plans of releasing OpenGL using OpenGLRaw in the near future :)? I'm asking only because using StateVar right now would actually give more headaches than solve them as we would have two different versions of get and ($=) in scope. Thanks for your work, -- Felipe. From matthias.goergens at googlemail.com Tue Jul 14 14:56:54 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Jul 14 14:38:47 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <87fxczgp8y.wl%jeremy@n-heptane.com> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5C5788.9030802@cs.caltech.edu> <87fxczgp8y.wl%jeremy@n-heptane.com> Message-ID: > It maybe be that Haskell is harder to learn as your *second* language > because you have to unlearn things. Especially if your first language > was something like C or Python. Python is not too bad. You can nearly use it a as a strict functional programming language. While this is not the idiomatic style to use python in, it sure eases transition to a real functional language (compared to say, C). Also Python has no pointers, but does have garbage collection. From newhoggy at gmail.com Tue Jul 14 18:27:04 2009 From: newhoggy at gmail.com (John Ky) Date: Tue Jul 14 18:08:57 2009 Subject: [Haskell-cafe] Circular pure data structures? Message-ID: Hello, Is it possible to create a circular pure data structure in Haskell? For example: a :: Data let b = getNext a let c = getNext b c == a -- Gives True Thanks, -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090714/935a68a6/attachment.html From lists at qseep.net Tue Jul 14 18:27:22 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Tue Jul 14 18:09:15 2009 Subject: [Haskell-cafe] Build 32-bit apps on 64-bit Windows? Message-ID: <670e468e0907141527v5222e999l5243860979401425@mail.gmail.com> If I am running GHC on 64-bit Windows, do I have a choice of building a 32-bit or 64-bit app? On a cursory glance through the command-line options, I didn't find anything. - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090714/29fb579c/attachment.html From allbery at ece.cmu.edu Tue Jul 14 18:30:52 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Jul 14 18:13:19 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: References: Message-ID: <2689427F-D49D-4B7D-8D85-E950ECECCB21@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/20090714/d898fa33/PGP.bin From rmm-haskell at z.odi.ac Tue Jul 14 18:32:18 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Jul 14 18:14:13 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: References: Message-ID: Yes, using lazy semantics. http://www.haskell.org/haskellwiki/Tying_the_Knot -Ross On Jul 14, 2009, at 6:27 PM, John Ky wrote: > Hello, > > Is it possible to create a circular pure data structure in Haskell? > For example: > > a :: Data > > let b = getNext a > let c = getNext b > > c == a -- Gives True > > Thanks, > > -John > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From felipe.lessa at gmail.com Tue Jul 14 18:37:50 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Jul 14 18:19:48 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: References: Message-ID: <20090714223750.GA9694@kira.casa> On Wed, Jul 15, 2009 at 08:27:04AM +1000, John Ky wrote: > a :: Data > > let b = getNext a > let c = getNext b > > c == a -- Gives True What do you mean? This works type Data = () getNext = id but I guess this is not what you meant ;). -- Felipe. From haskell at colquitt.org Tue Jul 14 18:55:18 2009 From: haskell at colquitt.org (John Dorsey) Date: Tue Jul 14 18:37:10 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: References: Message-ID: <20090714225518.GC14826@colquitt.org> John, > Is it possible to create a circular pure data structure in Haskell? For > example: Creating the data structure is easy; as other respondents have pointed out. A simple example is this... ones = 1 : ones ones' = 1 : ones' Comparing these values is harder. All of (ones), (ones'), (tail ones), and so forth are equal values. But I don't know how to compare them. My Spidey-sense tells me there's probably a simple proof that you can't, if you care about the comparison terminating. "Pointer equality" (ie. testing if the values are represented by the same bits in memory) is no good, since it's entirely up to the compiler whether ones and ones' use the same bits. (They won't, but that's not important.) In general "pointer equality" of Haskell values, such as ones and (tail ones) interferes with referential transparency, which is held in high regard around here. Although, for the record, when pointer equality is really what you want, I'm sure there's ways to Force It. For your purposes, does it matter if you can actually do the comparison? Is it enough to know that ones and (tail ones) are equal? Regards, John From gwern0 at gmail.com Tue Jul 14 20:41:21 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Jul 14 20:23:13 2009 Subject: [Haskell-cafe] How to "Read" this? In-Reply-To: <3bd412d40907132249x391f836dk7b909c6c7a8c447c@mail.gmail.com> References: <3bd412d40907132249x391f836dk7b909c6c7a8c447c@mail.gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Tue, Jul 14, 2009 at 1:49 AM, Magicloud Magiclouds wrote: > Hi, > I have a data structure, which shows like this: AttrBgColor {bgColor > = Color 0 0 0} > And the following is my Read code. But it failed parsing.... > 31 instance Read Attribute where > 32 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) 33 , (color, rest) > 34 > || (isPrefixOf " {fgColor = " rest1) > 35 > then case reads $ drop 12 rest1 of > 36 > [(color_, rest_)] -> [(color_, rest_)] > 37 > _ -> [(Color 0 0 0, rest1)] > 38 > else [(Color 0 0 0, rest1)] ] > 39 where mkAttr "AttrFgColor" color = AttrFgColor color > 40 mkAttr "AttrBgColor" color = AttrBgColor color > 41 mkAttr "AttrInverse" _ = AttrInverse > 42 mkAttr "AttrWeak" _ = AttrWeak > 43 mkAttr "AttrUnderline" _ = AttrUnderline Perhaps I am mis-understanding you, but why aren't you just deriving Read & Show? eg. data AttrBgColor = AttrBgColor { bgColor :: Color Int Int Int } deriving (Read, Show) It would certainly seem to be much easier and more reliable than hand-rolling an ad hoc parser. - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkpdJS8ACgkQvpDo5Pfl1oI/1QCfUgfHVsD/PMmgS6Z1sMMPljWt zOkAn0hQ3GBLFxHCO6ryoYyvPZ+nDJdp =qR5d -----END PGP SIGNATURE----- From tphyahoo at gmail.com Tue Jul 14 21:02:00 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Jul 14 20:43:52 2009 Subject: [Haskell-cafe] laziness blowup exercise Message-ID: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> Challenge: change one function in the following pipeline so that t doesn't blow up when executed in ghci. import qualified Data.Set as S t = last . take (10^6) . iterate f $ S.empty f s = S.delete 1 . S.insert 1 $ s Please suggest more of these types of exercises if you have them and maybe we can collect the folk wisdom into a wiki page and/or exercise page for beginners. spoiler for the above problem below :) myiterate f x = let nxt = f x in nxt `seq` x : myiterate f nxt From jwlato at gmail.com Tue Jul 14 21:13:20 2009 From: jwlato at gmail.com (John Lato) Date: Tue Jul 14 20:55:11 2009 Subject: [Haskell-cafe] Re: iteratee enumHandle (and parsing) Message-ID: <9979e72e0907141813w27218031p4a9974241bd40da4@mail.gmail.com> Hello, This explanation is entirely correct. I'm not happy with this situation, because I think it's confusing for people just starting with iteratee. However, I do want something that will be unicode (and other possible encodings) aware. Currently, I'm waiting to see how unicode support in the base libraries works out. What seems the best possibility at this time is writing codecs that could be used with mapStream or convStream to handle this appropriately, but I'd prefer to re-use core unicode support if possible. I'm open to suggestions on this issue. At the very least, I should probably include the ASCII encoding in the iteratee package. I'd like to make the common case of reading ASCII text easier than it currently is. Until then, one approach is using mapStream as suggested below. Another is using a wrapped ByteString instead of the List chunk. The ByteString chunk forces the element to be an 8-bit ASCII character instead of using the Char storable instance. If the full polymorphism of the List chunk is required, the conversion can be done with either mapStream or convStream. convStream is probably more efficient for this at the moment. Regarding using Parsec with iteratees: unfortunately I don't really do much in the way of parsing myself so I'm not much help here. I think that Oleg intended for parsers to be written directly using the iteratee primitives, in particular the "heads" function would be useful (at least he found it so). I don't see an efficient way to generate a continuation on a partial parse with Parsec, using iteratees or not. I think you could just load data into a parser with setInput, but if you don't have enough data for a complete parse you'll just need to hold onto all the data until you've loaded enough to run it. If you tell me what functions you find lacking from iteratee, I'll look into implementing them. I'd rather not re-implement all of Parsec, but the text parsers should be simple enough, as well as some of the combinators. Cheers, John Lato > From: Echo Nolan > > Hi Paolino. > > What's happening is reading [Char] uses the Storable instance for Char > which is 32-bit. Thus, you get gibberish. The below does what you want, > by reading Word8s and converting them. > > import Control.Exception > import Data.Char > import Data.Iteratee.IO > import Data.Iteratee.Base > import Data.Word > import System.IO > > main :: IO () > main = do > ? ? ? ?h <- openFile "mamma23" ReadWriteMode > ? ? ? ?hPutStr h "ciao" > ? ? ? ?hSeek h AbsoluteSeek 0 > ? ? ? ?l <- enumHandle h readString >>= run > ? ? ? ?print $ assert (l == "ciao") () > > -- This is declared on its own so I can give a type signature without making > -- any of the above lines unmanageably long. > readString :: IterateeG [] Word8 IO String > readString = joinI $ mapStream (chr . fromIntegral) stream2list > > This only works for ASCII, of course. Someone should write some > enumerators for the other encodings. > > Regards, > Echo Nolan From wren at freegeek.org Tue Jul 14 22:49:00 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Jul 14 22:31:01 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: <20090714225518.GC14826@colquitt.org> References: <20090714225518.GC14826@colquitt.org> Message-ID: <4A5D439C.3010201@freegeek.org> John Dorsey wrote: > John, > >> Is it possible to create a circular pure data structure in Haskell? For >> example: > > Creating the data structure is easy; as other respondents have pointed out. > A simple example is this... > > ones = 1 : ones > ones' = 1 : ones' > > Comparing these values is harder. All of (ones), (ones'), (tail ones), and > so forth are equal values. But I don't know how to compare them. My > Spidey-sense tells me there's probably a simple proof that you can't, if you > care about the comparison terminating. That depends on what you mean by "proof" or "comparison". Usually large proofs are constructed by induction (breaking the problem apart bit by bit), but that only works for arbitrarily large but nevertheless finite problems. If you try induction on a (possibly) infinite structure you'll get a (possibly) non-terminating proof/program. Instead, for infinite structures we must use "coinduction" to reason about them. In a sense, this changes the definition of proof from "yes this is the case" into "yes this is the case as far as you know", since in finite time we can only look at a finite portion of any structure (and conversely, differences that we can't/don't observe "don't matter"). Often this results in semidecidable properties from the inductive world becoming co-semidecidable in the coinductive world (if two infinite streams are unequal this can be discovered in finite time, but discovering that they are equal is trickier). -- Live well, ~wren From ok at cs.otago.ac.nz Tue Jul 14 23:27:26 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Jul 14 23:09:55 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <200907101044.52078.g9ks157k@acme.softbase.org> References: <200907101044.52078.g9ks157k@acme.softbase.org> Message-ID: On Jul 10, 2009, at 8:44 PM, Wolfgang Jeltsch wrote: > Am Freitag, 10. Juli 2009 05:26 schrieb roconnor@theorem.ca: >> I find it amazing that you independently chose to spell colour with >> a `u'. >> It makes me feel better about my choice. > > I have to admit that it makes me unhappy. :-( > > Why do we use English for identifiers? Because English is the > language of > computer science. What English should we use? It?s tempting to say, > we should > use the original English, which is British English. But we should > ask again > what is the language of computer science. And the language of computer > science is American English. It was possible to adopt such an attitude in the 20th century. But this is the 21st century. We have globalisation, internationalisation, localisation. We have Unicode, so that people are no longer limited to the set of characters that technicians from the USA found tolerable back in 1967. (Note that "Americans" includes French Canadians and lost of people who mainly speak Spanish.) Let's face it, by this argument we'd have to abandon the metric system when writing computer programs. There are good reasons to adopt American speling for a term or English spelling. They include the language that the author is most familiar with, the language the paying customers are most familiar with, the language of the laws that the program has to conform to, any number of things. But there is a way above this issue. Why can't we have BOTH "Colour" AND "Color"? What changes, if any, would it take for Haskell to support bidialectal naming practices (whether it is English -vs- American, insular/Brazilian Portuguese, Norwegian, Arabic dialects, or whatever)? We can create an alias for a type easily enough. We can create an alias for a defined function easily enough. We cannot create an alias for a constructor; there is no way to say data X = A | B Int constructor C = B so that C can be used for pattern matching just like B. We cannot create an alias for a module name; while we can create a module that re-exports everything from some module, there is no way to make them act the same as far as inheritance of dotted names is concerned. SML has similar limitations, but not quite the same. It lets us create alias for types and defined functions. It also lets us create aliases for modules, its structures and functors (more or less). But even SML doesn't allow the definition of aliases for constructors. > > > To my knowledge, most early developments in computer science had > their roots > in the US. One consequence of this is that reserved words of > programming > languages are typically in American English. PASCAL uses ?program?, > not ?programme?, and BASIC uses ?COLOR?, not ?COLOUR?. So, in my > opinion, > Haskell color packages should use the identifier Color, not Colour. > By the > way, I also write my papers and documentation in American English. > > Best wishes, > Wolfgang > (who is neither British nor American) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ok at cs.otago.ac.nz Wed Jul 15 00:03:13 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Jul 14 23:45:08 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> Message-ID: On Jul 10, 2009, at 6:14 PM, Thomas Davie wrote: > In my mind, the front page is for nothing more than enticing people > to use Haskell for long enough to look at a second page where all > the useful stuff is if you are a haskell programmer. I would have thought that a web page should serve its most frequent visitors best. By all means have an enticing paragraph at the top, pointing to a second page, but why make life hard for regular Haskellers visiting their site? From newhoggy at gmail.com Wed Jul 15 00:29:44 2009 From: newhoggy at gmail.com (John Ky) Date: Wed Jul 15 00:11:36 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: <20090714225518.GC14826@colquitt.org> References: <20090714225518.GC14826@colquitt.org> Message-ID: Hello, Actually, I wanted to be able to create a tree structure when I can navigate both leaf-ward and root-ward. I didn't actually care for equality. I think the tying the knot technique as mentioned by others is sufficient for this purpose. Cheers, -John On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey wrote: > John, > > > Is it possible to create a circular pure data structure in Haskell? For > > example: > > Creating the data structure is easy; as other respondents have pointed out. > A simple example is this... > > ones = 1 : ones > ones' = 1 : ones' > > Comparing these values is harder. All of (ones), (ones'), (tail ones), and > so forth are equal values. But I don't know how to compare them. My > Spidey-sense tells me there's probably a simple proof that you can't, if > you > care about the comparison terminating. > > "Pointer equality" (ie. testing if the values are represented by the same > bits in memory) is no good, since it's entirely up to the compiler whether > ones and ones' use the same bits. (They won't, but that's not important.) > In general "pointer equality" of Haskell values, such as ones and (tail > ones) interferes with referential transparency, which is held in high > regard around here. Although, for the record, when pointer equality is > really what you want, I'm sure there's ways to Force It. > > For your purposes, does it matter if you can actually do the comparison? > Is > it enough to know that ones and (tail ones) are equal? > > Regards, > John > > _______________________________________________ > 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/20090715/1fa6fb95/attachment.html From miguelimo38 at yandex.ru Wed Jul 15 00:41:34 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Jul 15 00:23:30 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: References: <20090714225518.GC14826@colquitt.org> Message-ID: <90E306F9-CC47-4AA2-9747-A72CBD993228@yandex.ru> Sufficient, but not good. Try zippers instead. On 15 Jul 2009, at 08:29, John Ky wrote: > Hello, > > Actually, I wanted to be able to create a tree structure when I can > navigate both leaf-ward and root-ward. I didn't actually care for > equality. > > I think the tying the knot technique as mentioned by others is > sufficient for this purpose. > > Cheers, > > -John > > On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey > wrote: > John, > > > Is it possible to create a circular pure data structure in > Haskell? For > > example: > > Creating the data structure is easy; as other respondents have > pointed out. > A simple example is this... > > ones = 1 : ones > ones' = 1 : ones' > > Comparing these values is harder. All of (ones), (ones'), (tail > ones), and > so forth are equal values. But I don't know how to compare them. My > Spidey-sense tells me there's probably a simple proof that you > can't, if you > care about the comparison terminating. > > "Pointer equality" (ie. testing if the values are represented by the > same > bits in memory) is no good, since it's entirely up to the compiler > whether > ones and ones' use the same bits. (They won't, but that's not > important.) > In general "pointer equality" of Haskell values, such as ones and > (tail > ones) interferes with referential transparency, which is held in high > regard around here. Although, for the record, when pointer equality > is > really what you want, I'm sure there's ways to Force It. > > For your purposes, does it matter if you can actually do the > comparison? Is > it enough to know that ones and (tail ones) are equal? > > Regards, > John > > _______________________________________________ > 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 newhoggy at gmail.com Wed Jul 15 01:03:59 2009 From: newhoggy at gmail.com (John Ky) Date: Wed Jul 15 00:45:53 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: <90E306F9-CC47-4AA2-9747-A72CBD993228@yandex.ru> References: <20090714225518.GC14826@colquitt.org> <90E306F9-CC47-4AA2-9747-A72CBD993228@yandex.ru> Message-ID: Hello, If I use zippers, do all my nodes need to be the same type? My tree doesn't have the same type for every node. For example: Modules -> Module -> Types -> Type -> Members -> Member -> Type -> ... Thanks -John On Wed, Jul 15, 2009 at 2:41 PM, Miguel Mitrofanov wrote: > Sufficient, but not good. > > Try zippers instead. > > > On 15 Jul 2009, at 08:29, John Ky wrote: > > Hello, >> >> Actually, I wanted to be able to create a tree structure when I can >> navigate both leaf-ward and root-ward. I didn't actually care for equality. >> >> I think the tying the knot technique as mentioned by others is sufficient >> for this purpose. >> >> Cheers, >> >> -John >> >> On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey >> wrote: >> John, >> >> > Is it possible to create a circular pure data structure in Haskell? For >> > example: >> >> Creating the data structure is easy; as other respondents have pointed >> out. >> A simple example is this... >> >> ones = 1 : ones >> ones' = 1 : ones' >> >> Comparing these values is harder. All of (ones), (ones'), (tail ones), >> and >> so forth are equal values. But I don't know how to compare them. My >> Spidey-sense tells me there's probably a simple proof that you can't, if >> you >> care about the comparison terminating. >> >> "Pointer equality" (ie. testing if the values are represented by the same >> bits in memory) is no good, since it's entirely up to the compiler whether >> ones and ones' use the same bits. (They won't, but that's not important.) >> In general "pointer equality" of Haskell values, such as ones and (tail >> ones) interferes with referential transparency, which is held in high >> regard around here. Although, for the record, when pointer equality is >> really what you want, I'm sure there's ways to Force It. >> >> For your purposes, does it matter if you can actually do the comparison? >> Is >> it enough to know that ones and (tail ones) are equal? >> >> Regards, >> John >> >> _______________________________________________ >> 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/20090715/b2c7a3d2/attachment-0001.html From ekirpichov at gmail.com Wed Jul 15 01:13:47 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Jul 15 00:55:39 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: References: <20090714225518.GC14826@colquitt.org> <90E306F9-CC47-4AA2-9747-A72CBD993228@yandex.ru> Message-ID: <5e0214850907142213o6864d009ke466927e9a14fa86@mail.gmail.com> Zippers come up as the "derivative" of the type; if you haven't yet encountered this trick, then first find it :) Try differentiating your datastructure. 2009/7/15 John Ky : > Hello, > > If I use zippers, do all my nodes need to be the same type?? My tree doesn't > have the same type for every node.? For example: > > Modules -> Module -> Types -> Type -> Members -> Member -> Type -> ... > > Thanks > > -John > > On Wed, Jul 15, 2009 at 2:41 PM, Miguel Mitrofanov > wrote: >> >> Sufficient, but not good. >> >> Try zippers instead. >> >> On 15 Jul 2009, at 08:29, John Ky wrote: >> >>> Hello, >>> >>> Actually, I wanted to be able to create a tree structure when I can >>> navigate both leaf-ward and root-ward. ?I didn't actually care for equality. >>> >>> I think the tying the knot technique as mentioned by others is sufficient >>> for this purpose. >>> >>> Cheers, >>> >>> -John >>> >>> On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey >>> wrote: >>> John, >>> >>> > Is it possible to create a circular pure data structure in Haskell? >>> > ?For >>> > example: >>> >>> Creating the data structure is easy; as other respondents have pointed >>> out. >>> A simple example is this... >>> >>> ones ?= 1 : ones >>> ones' = 1 : ones' >>> >>> Comparing these values is harder. ?All of (ones), (ones'), (tail ones), >>> and >>> so forth are equal values. ?But I don't know how to compare them. ?My >>> Spidey-sense tells me there's probably a simple proof that you can't, if >>> you >>> care about the comparison terminating. >>> >>> "Pointer equality" (ie. testing if the values are represented by the same >>> bits in memory) is no good, since it's entirely up to the compiler >>> whether >>> ones and ones' use the same bits. ?(They won't, but that's not >>> important.) >>> In general "pointer equality" of Haskell values, such as ones and (tail >>> ones) interferes with referential transparency, which is held in high >>> regard around here. ?Although, for the record, when pointer equality is >>> really what you want, I'm sure there's ways to Force It. >>> >>> For your purposes, does it matter if you can actually do the comparison? >>> ?Is >>> it enough to know that ones and (tail ones) are equal? >>> >>> Regards, >>> John >>> >>> _______________________________________________ >>> 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 > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From aslatter at gmail.com Wed Jul 15 01:19:38 2009 From: aslatter at gmail.com (Antoine Latter) Date: Wed Jul 15 01:01:31 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: <5e0214850907142213o6864d009ke466927e9a14fa86@mail.gmail.com> References: <20090714225518.GC14826@colquitt.org> <90E306F9-CC47-4AA2-9747-A72CBD993228@yandex.ru> <5e0214850907142213o6864d009ke466927e9a14fa86@mail.gmail.com> Message-ID: <694519c50907142219n73f9ea77v25e48dfc27a4f393@mail.gmail.com> On Wed, Jul 15, 2009 at 12:13 AM, Eugene Kirpichov wrote: > Zippers come up as the "derivative" of the type; if you haven't yet > encountered this trick, then first find it :) > > Try differentiating your datastructure. > Here's a paper with a good introduction to the concept and bibliography: http://strictlypositive.org/dfordata.pdf My take on it: A zipper is the one-hole-context of your data-type plus a focused-on payload. Data-structure differentiation is the method for deriving the one-hole-context. Antoine From DekuDekuplex at Yahoo.com Wed Jul 15 01:25:15 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Jul 15 01:07:24 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> Message-ID: <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> On Tue, 14 Jul 2009 12:36:02 +0200, Ketil Malde wrote: > >[redirected from haskell@] > >Benjamin L.Russell writes: > >>> One often amusing outgrowth of this is that FP (OOP) fanatics anthropomorphize >>> their functions (objects). > >Well, I don't think we do. > >Functions are just mappings of values to values, they may be opaque, >but they're predictable, unchanging, and just...too boring to be >antropomorphized. > >Objects contain all kinds of hidden state and dependencies, and the >sheer unpredicatability of it all is the reason for the >anthropomorphics - it a symptom of a disease, not a desirable >quality. Although I don't necessary agree with your choice of the term, I find it interesting that you should use the biological term "disease"; according to a post [1] entitled "Re: Re: Smalltalk Data Structures and Algorithms," by K. K. Subramaniam, dated "Mon, 29 Jun 2009 11:25:34 +0530," on the squeak-beginners mailing list (see http://lists.squeakfoundation.org/pipermail/beginners/2009-June/006270.html), >Concepts in Squeak [a dialect and implementation of Smalltalk] have their origins >in biology rather than in computational math.... See the reading list at >http://www.squeakland.org/resources/books/readingList.jsp >particularly "The Selfish Gene" by Richard Dawkins. It's an interesting coincidence that you should hit upon the term "disease," which also derives from biology. It's not just "the sheer unpredictability of it all" that is "the reason for the anthropomorphics"; it is the fundamental difference of the basis in biology vs. computational mathematics. Haskell (and FP) derive from the latter; Smalltalk (and OOP) derive from the former. Biological structures also contain "all kinds of hidden state and dependencies"; in that sense, objects are similar to biological structures, and are more easily anthromorphized on that account. Functional programming functions, on the other hand, are not similar to biological structures, and hence are not easily anthromorphized; instead, they are similar to mathematical functions. I wouldn't necessarily say that "anthromorphics ... [is] a symptom of a disease," though. Anthromorphics simply uses terms from biology, from which concepts in Squeak (and the OO paradigm thereof) derive. The closest counterpart for Haskell that I can think of is the puzzle game "Alligator Eggs!" [2] (see http://worrydream.com/AlligatorEggs/), by Bret Victor, which draws an analogy between various behaviors of alligators and operations in the lambda calculus--a collection of "allomorphisms," perhaps? -- Benjamin L. Russell [1] Subramaniam, K. K. "Re: Re: Smalltalk Data Structures and Algorithms." The Beginners Archives. Squeak.org. 29 June 2009. 15 July 2009. . [2] Victor, Bret. "Alligator Eggs!" _Bret Victor's website._ Bret Victor. 11 May 2007. 15 July 2009. . -- 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 stefan at cs.uu.nl Wed Jul 15 02:22:33 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Wed Jul 15 02:04:25 2009 Subject: [Haskell-cafe] Circular pure data structures? In-Reply-To: References: <20090714225518.GC14826@colquitt.org> <90E306F9-CC47-4AA2-9747-A72CBD993228@yandex.ru> Message-ID: <1D82926C-094C-4C23-B412-E23EAA61E97D@cs.uu.nl> John, > If I use zippers, do all my nodes need to be the same type? No, zippers can also be defined for mutually recursive data types. In a paper to be presented at ICFP, next September, Alexey Rodriguez, Andres L?h, Johan Jeuring, and I show how zippers for mutually recursive data types can be derived in Haskell: Alexey Rodriguez, Stefan Holdermans, Andres L?h, and Johan Jeuring. Generic programming with fixed points for mutually recursive datatypes, 2009. To appear in the proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming, ICFP 2009, Edinburgh, Scotland, August 31?September 2, 2009. http://people.cs.uu.nl/stefan/pubs/rodriguez09generic.html . An implementation is available on Hackage: http://hackage.haskell.org/package/zipper . HTH, Stefan From v.dijk.bas at gmail.com Wed Jul 15 04:16:12 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Jul 15 03:58:05 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> Message-ID: On Wed, Jul 15, 2009 at 3:02 AM, Thomas Hartman wrote: > Please suggest more of these types of exercises if you have them and > maybe we can collect the folk wisdom into a wiki page and/or exercise > page for beginners. My 'stream' library[1] also has some examples. Look at the following functions in 'Data.Stream': * mapAccum' * scan' * iterate' * unfold' There are similar examples in 'Control.Monad.StreamT'. [1] http://code.haskell.org/~basvandijk/code/stream/ (Not on Hackage) From magnus at therning.org Wed Jul 15 04:22:58 2009 From: magnus at therning.org (Magnus Therning) Date: Wed Jul 15 04:04:51 2009 Subject: [Haskell-cafe] Build 32-bit apps on 64-bit Windows? In-Reply-To: <670e468e0907141527v5222e999l5243860979401425@mail.gmail.com> References: <670e468e0907141527v5222e999l5243860979401425@mail.gmail.com> Message-ID: On Tue, Jul 14, 2009 at 11:27 PM, Lyle Kopnicky wrote: > If I am running GHC on 64-bit Windows, do I have a choice of building a > 32-bit or 64-bit app? On a cursory glance through the command-line options, > I didn't find anything. I don't think there are cross-compiling version of GHC to be downloaded out there. You might be able to install both a 64-bit and 32-bit GHC compiler on the same system though. Personally I use virtualisation for all my 32-bit needs nowadays. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From magicloud.magiclouds at gmail.com Wed Jul 15 05:57:41 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed Jul 15 05:39:34 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? Message-ID: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> Hi, I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code could not be compiled, parse error. -- ??????? ??????? From noteed at gmail.com Wed Jul 15 05:59:40 2009 From: noteed at gmail.com (minh thu) Date: Wed Jul 15 05:41:51 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> Message-ID: <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> 2009/7/15 Magicloud Magiclouds : > Hi, > I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code > could not be compiled, parse error. ++ is a function; you can't pattern-match on that. Cheers, Thu From noteed at gmail.com Wed Jul 15 06:00:39 2009 From: noteed at gmail.com (minh thu) Date: Wed Jul 15 05:42:49 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> Message-ID: <40a414c20907150300q6d52ac9em2901c4cbe2808e19@mail.gmail.com> 2009/7/15 minh thu : > 2009/7/15 Magicloud Magiclouds : >> Hi, >> I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code >> could not be compiled, parse error. > > ++ is a function; you can't pattern-match on that. But here you can match against (0:1:xs). From ekirpichov at gmail.com Wed Jul 15 06:25:25 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Jul 15 06:07:16 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> Message-ID: <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> Technically, the reason is not that (++) is a function, but that it is not a constructor of the [] type. And, not only is it not a constructor, but it also *can't* be one, because the main characteristic of pattern matching in Haskell is that it is (contrary to Prolog's unification) unambiguous (unambiguity of constructors is guaranteed by the semantics of Haskell's algebraic datatypes). If ++ could be pattern matched, what should have been the result of "let (x++y)=[1,2,3] in (x,y)"? 2009/7/15 minh thu : > 2009/7/15 Magicloud Magiclouds : >> Hi, >> ?I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code >> could not be compiled, parse error. > > ++ is a function; you can't pattern-match on that. > > Cheers, > Thu > _______________________________________________ > 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 haberg at math.su.se Wed Jul 15 07:08:31 2009 From: haberg at math.su.se (Hans Aberg) Date: Wed Jul 15 06:50:47 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> Message-ID: <14F8AEDB-8E2C-44F3-8A6B-583F9644EC39@math.su.se> On 15 Jul 2009, at 12:25, Eugene Kirpichov wrote: > If ++ could be pattern matched, what should have been the result of > "let (x++y)=[1,2,3] in (x,y)"? It will branch. In terms of unification, you get a list of substitutions. Hans From me at mornfall.net Wed Jul 15 07:18:53 2009 From: me at mornfall.net (Petr Rockai) Date: Wed Jul 15 07:00:48 2009 Subject: [Haskell-cafe] ANN: darcs 2.3 beta 4 Message-ID: <87r5wimbxe.fsf@twilight.int.mornfall.net.> Hi again! We have decided to delay the release cycle slightly for 2.3 and release another beta. The primary reason for this is our Windows support -- I would like to invite all Windows users to install darcs-beta and give it a ride. If you have a working cabal-install, all you need to do is run: $ cabal update $ cabal install darcs-beta (this works on all platforms; you may need to use -f-curl, if you don't have the cURL headers available -- this is often the case on Windows). If you do not have cabal-install, please follow the instructions near the end of this message, "Installing on Windows". In addition to using cabal-install, you can also download a tarball from http://repos.mornfall.net/darcs/darcs-2.2.98.4.tar.gz and build manually (see the build instructions in README inside the tarball). Feedback -------- To make the darcs 2.3 release a good one, we still need testing feedback: please drop a note to darcs-users@ if you have installed darcs-beta, or failed to install it. If you run into any bugs, we need to know about them. Thanks! The question of GHC 6.8 ----------------------- Using GHC 6.10.3 or newer is *strongly recommended*. You may compile darcs with GHC 6.8, but there are several caveats. If you are using 6.8.2 or older, please disable mmap support (pass -f-mmap to cabal install or runghc Setup configure below). Note that the GHC 6.8.2 that ships with Debian Lenny is not affected and it should be safe to keep mmap enabled. It is also recommended to disable use of Hackage zlib when compiling with GHC 6.8.2 (including the Debian Lenny version): pass -f-zlib to cabal. When using zlib, we have seen occasional crashes with error messages like "openBinaryFile: file locked" -- this is a known GHC 6.8.2 bug (and is fixed in GHC 6.8.3). Last, if you are using a 64-bit system, darcs may hang when you exit a pager when compiled with GHC older than 6.10.3. Although this is harmless, it is quite inconvenient. Overall, the status of GHC 6.8 is "semi-supported": for many cases, things will work just fine, especially if you take a little extra caution with compilation flags. Installing on Windows --------------------- To install darcs on Windows systems from scratch, please download the Haskell Platform and MSYS: * http://hackage.haskell.org/platform/2009.2.0.1/HaskellPlatform-2009.2.0.1-setup.exe * http://sourceforge.net/projects/mingw/files/MSYS+Base+System/MSYS-1.0.11-rc-1.exe/download After installing both, you should have an "MSYS" icon: run MSYS and in the terminal window type: $ cabal update $ cabal install darcs-beta -f-curl This should download, compile and install all required dependencies and darcs-beta itself. The resulting darcs executable will be placed into the Haskell Platform executables folder, and should be accessible from the MSYS shell (just type "darcs --version" to check). Yours, Petr. From lrpalmer at gmail.com Wed Jul 15 07:22:55 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jul 15 07:04:47 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <14F8AEDB-8E2C-44F3-8A6B-583F9644EC39@math.su.se> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> <14F8AEDB-8E2C-44F3-8A6B-583F9644EC39@math.su.se> Message-ID: <7ca3f0160907150422n2f73e067s4edbb3084d7231ca@mail.gmail.com> On Wed, Jul 15, 2009 at 3:08 AM, Hans Aberg wrote: > On 15 Jul 2009, at 12:25, Eugene Kirpichov wrote: > > If ++ could be pattern matched, what should have been the result of >> "let (x++y)=[1,2,3] in (x,y)"? >> > > It will branch. In terms of unification, you get a list of substitutions. f :: [a] -> ([a],[a]) f (x ++ y) = (x,y) If this pattern branches, it could hardly be considered a *function *which takes lists and returns pairs. It would have to return something else. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090715/9e46ee6d/attachment.html From wagner.andrew at gmail.com Wed Jul 15 08:09:37 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Wed Jul 15 07:51:31 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> Message-ID: Err, technically, aren't functions and constructors mutually exclusive? So if something is a function, it's, by definition, not a constructor? On Wed, Jul 15, 2009 at 6:25 AM, Eugene Kirpichov wrote: > Technically, the reason is not that (++) is a function, but that it is > not a constructor of the [] type. > > And, not only is it not a constructor, but it also *can't* be one, > because the main characteristic of pattern matching in Haskell is that > it is (contrary to Prolog's unification) unambiguous (unambiguity of > constructors is guaranteed by the semantics of Haskell's algebraic > datatypes). > > If ++ could be pattern matched, what should have been the result of > "let (x++y)=[1,2,3] in (x,y)"? > > 2009/7/15 minh thu : > > 2009/7/15 Magicloud Magiclouds : > >> Hi, > >> I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code > >> could not be compiled, parse error. > > > > ++ is a function; you can't pattern-match on that. > > > > Cheers, > > Thu > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > _______________________________________________ > 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/20090715/aa0b0c5f/attachment.html From miguelimo38 at yandex.ru Wed Jul 15 08:14:17 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Jul 15 07:57:19 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> Message-ID: <4A5DC819.8070307@yandex.ru> No. Most constructors are functions, e.g. Just :: a -> Maybe a - a function. On the other hand, Nothing :: Maybe a is a constructor, but not a function. Andrew Wagner wrote: > Err, technically, aren't functions and constructors mutually exclusive? > So if something is a function, it's, by definition, not a constructor? > > On Wed, Jul 15, 2009 at 6:25 AM, Eugene Kirpichov > wrote: > > Technically, the reason is not that (++) is a function, but that it is > not a constructor of the [] type. > > And, not only is it not a constructor, but it also *can't* be one, > because the main characteristic of pattern matching in Haskell is that > it is (contrary to Prolog's unification) unambiguous (unambiguity of > constructors is guaranteed by the semantics of Haskell's algebraic > datatypes). > > If ++ could be pattern matched, what should have been the result of > "let (x++y)=[1,2,3] in (x,y)"? > > 2009/7/15 minh thu >: > > 2009/7/15 Magicloud Magiclouds >: > >> Hi, > >> I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code > >> could not be compiled, parse error. > > > > ++ is a function; you can't pattern-match on that. > > > > Cheers, > > Thu > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > _______________________________________________ > 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 haberg at math.su.se Wed Jul 15 08:30:50 2009 From: haberg at math.su.se (Hans Aberg) Date: Wed Jul 15 08:13:02 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <7ca3f0160907150422n2f73e067s4edbb3084d7231ca@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> <14F8AEDB-8E2C-44F3-8A6B-583F9644EC39@math.su.se> <7ca3f0160907150422n2f73e067s4edbb3084d7231ca@mail.gmail.com> Message-ID: On 15 Jul 2009, at 13:22, Luke Palmer wrote: > If ++ could be pattern matched, what should have been the result of > "let (x++y)=[1,2,3] in (x,y)"? > > It will branch. In terms of unification, you get a list of > substitutions. > > f :: [a] -> ([a],[a]) > f (x ++ y) = (x,y) For an argument s, any pair (x, y) satisfying s = x ++ y will match. That is, if s = [s_1, ..., s_k], the solutions j = 0, ..., k, x = [s_1, ..., s_j], y = [s_(j+1), ..., s_k]. And for each one, a potentially different value could given. That is, s could produce multiple values. > If this pattern branches, it could hardly be considered a function > which takes lists and returns pairs. It would have to return > something else. So this would be a multi-valued function, which sometime is useful as a concept. But if the choices are indexed, they can be reduced to a single valued function. Like g(x,y) with the requirement that if x ++ y = x' ++ y', then g(x, y) = g(x', y'). This branching is what would happen if one tries to make a type theory based on sets. (It is possible to implement Horn clauses as unification branching.) The selection of branches correspond to a choice in the proof tree. Hans From felipe.lessa at gmail.com Wed Jul 15 08:32:14 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Jul 15 08:14:10 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> Message-ID: <20090715123214.GA2768@kira.casa> On Wed, Jul 15, 2009 at 08:09:37AM -0400, Andrew Wagner wrote: > Err, technically, aren't functions and constructors mutually exclusive? So > if something is a function, it's, by definition, not a constructor? I guess what Eugene Kirpichov meant was that not being a function (and being a constructor) isn't sufficient, it must also be a constructor of the correct type, e.g. f Nothing = ... f (x:xs) = ... isn't correct, however it pattern matches on constructors only. -- Felipe. From sjoerd at w3future.com Wed Jul 15 08:34:24 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Wed Jul 15 08:16:27 2009 Subject: [Haskell-cafe] Problems with nested Monads In-Reply-To: References: <7fb8f82f0907101209q43e45c8ne750b269aeec47f2@mail.gmail.com> Message-ID: Actually, you can make a joinInner for the State monad. However, it does not allow the inner function (h) to change the state, because how state is threaded through a monad N is different for each N. i :: (Monad n) => (a -> State s b) -> (b -> n c) -> (c -> State s d) - > (a -> State s (n d)) i f g h = joinInnerState . liftM (liftM h . g) . f joinInnerState :: Monad n => State s (n (State s a)) -> State s (n a) joinInnerState (State g) = State $ joinInnerAsReader . g where joinInnerAsReader (n, s) = (liftM (fst . ($ s) . runState) n, s) joinInner is the only one of the 3 that works, because the outer M gives you an initial state to work with. Sjoerd On Jul 10, 2009, at 11:25 PM, Job Vranish wrote: > Yeah, I think the problem with my case is that while M is a specific > monad (essentially StateT), N can be an arbitrary monad, which I > think destroys my changes of making a valid joinInner/joinOuter/ > distribute. > Maybe someday Haskell will infer valid joinInner/joinOuter for > simple cases :D > Thanks for you help. I'll definitely have to see if I can find that > paper. > > - Job Vranish > > On Fri, Jul 10, 2009 at 3:09 PM, Edward Kmett > wrote: > The problem you have is that monad composition isn't defined in > general. You would need some form of distributive law either for > your monads in general, or for your particular monads wrapped around > this particular kind of value. > > What I would look for is a function of the form of one of: > > distribute :: N (M a) -> M (N a) > joinInner :: M (N (M a)) -> M (N a) > joinOuter :: N (M (N a)) -> M (N a) > > that holds for your partiular monads M and N. > > IIRC Mark P. Jones wrote a paper or a lib back around '93 that used > these forms of distributive laws to derive monads from the > composition of a monad and a pointed endofunctor. > > -Edward Kmett > > On Fri, Jul 10, 2009 at 11:34 AM, Job Vranish > wrote: > I'm trying to make a function that uses another monadic function > inside a preexisting monad, and I'm having trouble. > Basically my problem boils down to this. I have three monadic > functions with the following types: > f :: A -> M B > g :: B -> N C > h :: C -> M D > (M and N are in the monad class) > I want a function i where > i :: A -> M (N D) > > the best I can come up with is: > i :: A -> M (N (M D)) > i a = liftM (liftM h) =<< (return . g) (f a) > > I'm starting to feel pretty sure that what I'm going for is > impossible. Is this the case? > _______________________________________________ > 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 -- Sjoerd Visscher sjoerd@w3future.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090715/398ee78b/attachment.html From briqueabraque at yahoo.com Wed Jul 15 10:09:40 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Wed Jul 15 09:51:43 2009 Subject: [Haskell-cafe] Re: Pattern matching does not work like this? In-Reply-To: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> Message-ID: > I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code > could not be compiled, parse error. Maybe a small abstract can help, as I once also got confused by that. * First, syntax without operators You can only match on constructors. So, if you have data Test = Test1 String | Test2 Integer | Test3 you can do function (Test1 s) = ... function (Test2 i) = ... function Test3 = ... * Second, syntax with operators Haskell allow constructors made of symbols, but you have to start them with ':', so this is valid: data Test = Test1 String | Integer :** String and then function (Test1 s) = ... function (i :** s) = ... * Third, special syntax Haskell has special syntax for tuples and lists (and something else I forgot?). You can ask information about a name in ghci using ':i ', see what it says about (,) and []: data (,) a b = (,) a b data [] a = [] | a : [a] As you can see, (,), [] and : are actually constructors, and you can pattern match on them: function [] = ... function (a:b) = ... function ((:) a b) = ... function (a,b) = ... function ((,) a b) = ... Best, Maur?cio From bugfact at gmail.com Wed Jul 15 11:53:52 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Jul 15 11:35:43 2009 Subject: [Haskell-cafe] Haskell Zippers on Wikibooks: teasing! :) Message-ID: After my colleague explained me about zippers and how one could derive the datatype using differential rules, I had to read about it. So I started reading http://en.wikibooks.org/wiki/Haskell/Zippers#Mechanical_Differentiation This page contains the sentence: *"For a systematic construction, we need to calculate with types. The basics of structural calculations with types are outlined in a separate chapter **Generic Programming* * and we will heavily rely on this material"* * * However, the generic programming link does not exist yet :-) So although I now have a rough idea about it, I don't understand the details yet, e.g. notation like [image: \mathit{Node}\,A = \mu X.\,\mathit{NodeF}_A\,X] doesn't make much sense to me yet, although I suspect I can read the mu as a lambda on types? Thanks, Peter * * -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090715/7c8c9847/attachment.html From ryani.spam at gmail.com Wed Jul 15 12:35:11 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jul 15 12:17:00 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> Message-ID: <2f9b2d30907150935o36b7fd6fg10bbabdb62bb72b4@mail.gmail.com> On Tue, Jul 14, 2009 at 6:02 PM, Thomas Hartman wrote: > myiterate f x = > ?let nxt = f x > ?in nxt `seq` x : myiterate f nxt iterate' f x = x `seq` x : iterate' f (f x) seems better; it doesn't evaluate list elements you don't visit. > let test = 1 : 2 : 3 : undefined in last $ take 4 $ myiterate (test !!) 0 *** Exception: Prelude.undefined > let test = 1 : 2 : 3 : undefined in last $ take 4 $ iterate' (test!!) 0 3 -- ryan From cristiano.paris at gmail.com Wed Jul 15 13:33:49 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Wed Jul 15 13:15:58 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot Message-ID: Hi, as pointed out in this list, it seems that a "tying the knot" example would be the one better explaining the power of Haskell's lazy-by-default approach against Python+Iterator's approach to laziness. So, in these days I'm trying to grasp the meaning of this "tying the knot" concept which seems to be quite hard to understand for me (at least as much as Monads and Delimited Continuations were). Specifically, I was looking for a very basic example of TTK and came up with this implementation of Fibonacci (again!) which might possibly be a TTK-flavored way for generation: fib = 1:1:fib `plus` (tail fib) where plus = zipWith (+) Of course, this was something I already encountered when exploring the Y-combinator. Anyhow, I tried to translate this implementation to Python using Iterators and this is what I wrote: def fib(): yield 1 yield 1 p = plus(fib(),tail(fib())) while True: yield p.next() def plus(x,y): while True: yield x.next() + y.next() print take(5,fib()) I've omitted the implementation for tail() and take() for brevity. Apart from the iterator machinery, this is an direct translation of the Haskell's fib implementation. More, it's quite modular because fib lives by itself and is composed with take to get the final result. The only caveat in the Python code is that it maintains an O(n^2) Iterator's states, thus making it a very poor implementation. So my considerations are: 1 - The Fibonacci generator is not an example of TTK at all and then it can be translated to Python. 2 - The Fibonacci generator is a too simple example of TTK, easy to be translated to Python. 3 - The O(n^2) state caveat is THE point making the difference between Haskell and Python, for which Haksell is much more efficient that Python while remaining very expressive and idiomatic (but that may not be the case for other TTK examples). I'm trying to implement myself the doubly linked list example from the Wikipage, which is "certified" to be a TTK example, but I'd like to have your comments on this. Thank you. Cristiano From matthias.goergens at googlemail.com Wed Jul 15 13:43:07 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Jul 15 13:24:57 2009 Subject: [Haskell-cafe] Haskell Zippers on Wikibooks: teasing! :) In-Reply-To: References: Message-ID: > doesn't make much sense to me yet, although I suspect I can read the mu as a > lambda on types? Not really. The mu has more to do with recursion. Matthias. From simon at joyful.com Wed Jul 15 13:54:00 2009 From: simon at joyful.com (Simon Michael) Date: Wed Jul 15 13:35:50 2009 Subject: [Haskell-cafe] Re: ANN: shelltestrunner 0.6 released In-Reply-To: References: Message-ID: And the urls: home - http://hackage.haskell.org/package/shelltestrunner darcs repo - http://joyful.com/repos/shelltestrunner From simon at joyful.com Wed Jul 15 14:05:16 2009 From: simon at joyful.com (Simon Michael) Date: Wed Jul 15 13:47:07 2009 Subject: [Haskell-cafe] ANN: shelltestrunner 0.6 released Message-ID: <2A41B5AD-7AE8-46CF-8F70-B6933599E637@joyful.com> (and, the original which I didn't cc to -cafe.) I'm pleased to announce the first release of shelltestrunner: a small tool for testing any command-line program by running it through "shell" tests defined with a simple file format. Each test can specify the command-line arguments, input, expected output, expected stderr output, and/or expected exit code. This was extracted from the hledger project, inspired by the tests in John Wiegley's ledger project, and uses Max Bolingbroke's test- framework. In some cases you will get a big speedup by using test- framework's parallelising feature. Example: $ shelltestrunner shelltestrunner *.test -- -j8 :args.test:1: [OK] :args.test:2: [OK] :args.test:3: [OK] :args.test:4: [OK] :early-j-option.test: [OK] :help-flag.test: [OK] etc. I hope you find it useful. Feedback, patches, or alternate packaging suggestions are welcome! Best, -Simon From jon.fairbairn at cl.cam.ac.uk Wed Jul 15 14:12:06 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Wed Jul 15 13:54:13 2009 Subject: [Haskell-cafe] Re: Haskell Zippers on Wikibooks: teasing! :) References: Message-ID: Matthias G?rgens writes: >> doesn't make much sense to me yet, although I suspect I can read the mu as a >> lambda on types? > > Not really. The mu has more to do with recursion. I'd say it's entirely to do with recursion. It's like the Y combinator (or fix) for types, though it is combined with a lambda. mu t . ----t---- is like fix (\t -> ----t----) -- 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 max.rabkin at gmail.com Wed Jul 15 14:18:03 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Wed Jul 15 14:00:13 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot In-Reply-To: References: Message-ID: On Wed, Jul 15, 2009 at 7:33 PM, Cristiano Paris wrote: > fib = 1:1:fib `plus` (tail fib) where plus = zipWith (+) > > Of course, this was something I already encountered when exploring the > Y-combinator. Anyhow, I tried to translate this implementation to > Python using Iterators and this is what I wrote: > > def fib(): > ?yield 1 > ?yield 1 > > ?p = plus(fib(),tail(fib())) > > ?while True: > ? ?yield p.next() > > def plus(x,y): > ?while True: > ? ?yield x.next() + y.next() > > print take(5,fib()) I'm not convinced that this is the "same" program as the Haskell version. No knot is tied in the Python version. To tie the knot, a data structure must contain or refer to itself. In the python version, the function which creates the data structure refers to itself, but many copies of the data structure are created. > So my considerations are: > > 1 - The Fibonacci generator is not an example of TTK at all and then > it can be translated to Python. This indicates that you think tying the knot should be impossible in Python. In my opinion this is not the case. By my definition of tying the knot, one needs *either* mutable variables or laziness (at least in simple cases). Since Python has the former, it is possible to tie the knot in Python. To me the simplest example of TTK in Python (not possible in Haskell because it has an infinite type): x = [] x.append(x) (If you try to print this list, one gets [[...]] in the standard REPL and [] in ipython) --Max From dagit at codersbase.com Wed Jul 15 17:54:17 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed Jul 15 17:36:06 2009 Subject: [Haskell-cafe] homomorphic encryption and monads? Message-ID: Hello, I have just a very vague understanding of what homomorphic encryption is, but I was wondering if homomorphic encryption behaves as a one-way monad (like IO). So for example, suppose you wrote a function that worked on encrypted email to determine if it spam, maybe it looks like this: isSpam :: Cypher String -> Cypher Bool I could be mistaken about the way this works, but it seems that isSpam can't return a plain 'Bool' because then you could know things about the encrypted data without having to decrypt it first. So that is why I think it has to return "Cypher Bool". And because it's a homomorphic encryption, you could have something like doWork: doWork :: Cypher a -> (a -> b) -> Cypher b Which we could use to implement isSpam: isSpam s = doWork s spamTest where spamTest :: String -> Bool I initially thought that doWork should be (>>=), but it seems the type of the function should either be (a -> b) or (Cypher a -> Cypher b). That is, return :: a -> Cypher a, is not available. All the data should already be encrypted. Thinking about it a bit more, since we never have to decrypt the data to work with it, it seems that (a -> b) is wrong as well, because we don't have the key or whatever to do the decrypting. So, then it seems reasonable that the only type for doWork is this: doWork :: Cypher a -> (Cypher a -> Cypher b) -> Cypher b Which doesn't really seem all that useful now. On the other hand, maybe we have an algorithm which can take a function on normal values and gives us a function on Cypher values: enCypher :: (a -> b) -> Cypher a -> Cypher b Or perhaps, it should be: enCypher :: (a -> b) -> Cypher (a -> b) Which would match the type of return. If that is the type of return, then we probably want: (>>=) :: Cypher (a -> b) -> ((a -> b) -> Cypher (c -> d)) -> Cypher (c -> d) At this point, I'm not actually sure if the second type for enCypher makes any sense. But, if it does, then I think it says the purpose of the monad is to act on the transformations and not the data. That is, instead of focusing on the data as being held in the cypher, we are thinking of the functions as being transformed into a cypher space. Has anyone else been thinking about this? Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090715/a7403f48/attachment.html From fernanbolando at mailc.net Wed Jul 15 18:07:40 2009 From: fernanbolando at mailc.net (Fernan Bolando) Date: Wed Jul 15 17:49:31 2009 Subject: [Haskell-cafe] Debugging methods for haskell Message-ID: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Hi all I recently used 2 hours of work looking for a bug that was causing Program error: Prelude.!!: index too large This is not very informative. It did not give me a hint which function was causing this. In C adding a few printf would have helped me, but in haskell I was not sure how to do that. Can anybody point me to some debuggin method everyone uses. After 2 hours I did find the bug eventually. The code can be viewed here. Maybe some reformatting of the code would make finding bugs easier? http://plan9.bell-labs.com/sources/contrib/fernan/escomma/ fernan -- http://www.fernski.com From dons at galois.com Wed Jul 15 18:13:33 2009 From: dons at galois.com (Don Stewart) Date: Wed Jul 15 17:57:22 2009 Subject: [Haskell-cafe] Debugging methods for haskell In-Reply-To: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Message-ID: <20090715221333.GJ25885@whirlpool.galois.com> fernanbolando: > Hi all > > I recently used 2 hours of work looking for a bug that was causing > > Program error: Prelude.!!: index too large > > This is not very informative. It did not give me a hint which function > was causing this. In C adding a few printf would have helped me, but > in haskell I was not sure how to do that. Can anybody point me to some > debuggin method everyone uses. You could: * use Debug.Trace.trace (equivalent of printf debugging) * use asserts: the 'assert' function * use the GHCi debugger to construct a stack trace * use profiling to construct a stack trace. * use the GHC head branch for first class stack traces, described in, "Finding the needle: Stack Traces for GHC" http://pubs.doc.ic.ac.uk/finding-the-needle/finding-the-needle.pdf -- Don From max.rabkin at gmail.com Wed Jul 15 18:42:52 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Wed Jul 15 18:25:03 2009 Subject: [Haskell-cafe] homomorphic encryption and monads? In-Reply-To: References: Message-ID: On Wed, Jul 15, 2009 at 11:54 PM, Jason Dagit wrote: > Hello, > > I have just a very vague understanding of what homomorphic encryption is, > but I was wondering if homomorphic encryption behaves as a one-way monad > (like IO). An interesting idea. Let's see where this leads. > I could be mistaken about the way this works, but it seems that isSpam can't > return a plain 'Bool' because then you could know things about the encrypted > data without having to decrypt it first.? So that is why I think it has to > return "Cypher Bool". Yes, this is the idea behind homomorphic encryption: you can do some work on an encrypted input, and get an encrypted output. Your categorical spidey-sense should be tingling right now, and indeed it did, but you interpreted it wrong (but it's a common trap) > And because it's a homomorphic encryption, you could have something like > doWork: > doWork :: Cypher a -> (a -> b) -> Cypher b Looks good. This type should send your spidey-sense into the red. > Which we could use to implement isSpam: > > isSpam s = doWork s spamTest > ? where spamTest :: String -> Bool > > Thinking about it a bit more, since we never have to decrypt the > data to work with it, it seems that (a -> b) is wrong as well, because we > don't have the key or whatever to do the decrypting. (a -> b) is not wrong. Homomorphic encryption gives you exactly this *magic* function that takes an ordinary f :: a -> b, and applies it to a Cypher a, giving you a Cypher b. No deciphering happens. The function get lifted/mapped into Cypher. > So, then it seems reasonable that the only type for doWork is this: > doWork :: Cypher a -> (Cypher a -> Cypher b) -> Cypher b > > Which doesn't really seem all that useful now. Indeed. That is just (a restricted version of) the type of 'flip ($)', a rather uninteresting (though not useless) function. > On the other hand, maybe we have an algorithm which can take a function on > normal values and gives us a function on Cypher values: > > enCypher :: (a -> b) -> Cypher a -> Cypher b This is exactly what you have. This is just the flipped version of your first doWork. And this function is better known as fmap. Cypher is a Functor. Because they have special syntax, are widely used in IO, and have a scary name (and perhaps for other, better reasons too), Monads seem to attract special attention. Functor and Applicative get much less love, but both are valuable and interesting typeclasses (they form a hierarchy: every monad is an applicative functor, and ever applicative functor is a functor). And hopefully your spidey-sense now has a Functor-detector :) I was planning to show that Cypher can't be a monad or an applicative functor, but their seems to be a hole in my thinking. Hopefully I can fix it, and hopefully everything I've said up to now has been correct. --Max From yairchu at gmail.com Wed Jul 15 19:12:48 2009 From: yairchu at gmail.com (Yair Chuchem) Date: Wed Jul 15 18:54:42 2009 Subject: [Haskell-cafe] ANNOUNCE: generator Message-ID: <14310193-6089-4294-8D64-2EB97647F7D6@gmail.com> A new "generator" package has been uploaded to Hackage. It implements an alternative list monad transformer, a list class, and related functions. The difference from mtl/transformers's ListT is that mtl is a monadic action that returns a list: newtype ListT m a = ListT { runListT :: m [a] } generator's is a monadic list: data ListItem l a = Nil | Cons { headL :: a, tailL :: l a } newtype ListT m a = ListT { runListT :: m (ListItem (ListT m) a) } A short example program which reads numbers from the user and interactively sums them up: import Control.Monad.ListT (ListT) import Data.List.Class (execute, joinM, repeat, scanl, takeWhile) import Prelude hiding (repeat, scanl, takeWhile) main = execute . joinM . fmap print . scanl (+) 0 . fmap (fst . head) . takeWhile (not . null) . fmap reads . joinM $ (repeat getLine :: ListT IO (IO String)) I also wrote an example/blog-post about using ListT to add an undo option to the classic game of "hamurabi": http://mashebali.blogspot.com/2009/07/charlemagne-disraeli-and-jefferson.html Another interesting observation is that "ListT [] a" is a tree of "a"s. The module Data.List.Tree includes functions to prune and search such trees (dfs, bfs, bestFirstSearchOn, etc). This can be useful for modularizing code that uses the list monad for combinatoric search by decoupling tree creation from processing and pruning. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090715/1cbc38ed/attachment.html From marco-oweber at gmx.de Wed Jul 15 19:34:22 2009 From: marco-oweber at gmx.de (Marc Weber) Date: Wed Jul 15 19:16:21 2009 Subject: [Haskell-cafe] Debugging methods for haskell In-Reply-To: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Message-ID: <1247699850-sup-516@nixos> Of course !! is only one cause for this kind of errror. Another is ghci> head [] *** Exception: Prelude.head: empty list Unfortunately this kind of bug is very hard to debug due to the lazy nature of haskell. You don't have a stack trace as in Java, PHP, .. Example: data D = D String a,b :: [String] a = head [] b = head [] main = do let first = a second = b print first -- both will cause the same error but a different head caused the exception print second One solution is using interlude from hackage. I'm not sure wether it supports !! Also try this haskell-cafe search (you may have to up to page 20 or so) http://search.gmane.org/?query=empty+list+head&author=&group=gmane.comp.lang.haskell.cafe&sort=relevance&DEFAULTOP=and&xP=Zempti%09Zlist&xFILTERS=Gcomp.lang.haskell.cafe---A This reveals this thread for example: http://article.gmane.org/gmane.comp.lang.haskell.cafe/14921/match=empty+list+head http://article.gmane.org/gmane.comp.lang.haskell.cafe/6719/match=empty+list+head I recall there was another method. Yeah, I even found it (using ghci and set -fbreak-on-exception) http://donsbot.wordpress.com/2007/11/14/no-more-exceptions-debugging-haskell-code-with-ghci/ HTH Marc Weber From westondan at imageworks.com Wed Jul 15 19:56:38 2009 From: westondan at imageworks.com (Dan Weston) Date: Wed Jul 15 19:38:32 2009 Subject: [Haskell-cafe] homomorphic encryption and monads? In-Reply-To: References: Message-ID: <4A5E6CB6.4020602@imageworks.com> I think there may be a problem here. "Homomorphic encryption is a form of encryption where one can perform a specific algebraic operation on the plaintext by performing a (possibly different) algebraic operation on the ciphertext. " The word "specific" means that the functor is discrete, not continuous. Only Integer can be encoded. Also, the arrow mapping is partial: fmap does not accept arbitrary any (a -> b) but only a natural transformation pair (in,out). That would make Encryption an indexed arrow, something like class Arrow a => In a b where in :: a b Integer class Arrow a => Out a c where out :: a Integer c instance (In a b, Out a c) => Arrow a b c where arr f = in >>> f >>> out Dan Max Rabkin wrote: > On Wed, Jul 15, 2009 at 11:54 PM, Jason Dagit wrote: >> Hello, >> >> I have just a very vague understanding of what homomorphic encryption is, >> but I was wondering if homomorphic encryption behaves as a one-way monad >> (like IO). > > An interesting idea. Let's see where this leads. > >> I could be mistaken about the way this works, but it seems that isSpam can't >> return a plain 'Bool' because then you could know things about the encrypted >> data without having to decrypt it first. So that is why I think it has to >> return "Cypher Bool". > > Yes, this is the idea behind homomorphic encryption: you can do some > work on an encrypted input, and get an encrypted output. > > Your categorical spidey-sense should be tingling right now, and indeed > it did, but you interpreted it wrong (but it's a common trap) > >> And because it's a homomorphic encryption, you could have something like >> doWork: >> doWork :: Cypher a -> (a -> b) -> Cypher b > > Looks good. This type should send your spidey-sense into the red. > >> Which we could use to implement isSpam: >> >> isSpam s = doWork s spamTest >> where spamTest :: String -> Bool >> >> Thinking about it a bit more, since we never have to decrypt the >> data to work with it, it seems that (a -> b) is wrong as well, because we >> don't have the key or whatever to do the decrypting. > > (a -> b) is not wrong. Homomorphic encryption gives you exactly this > *magic* function that takes an ordinary f :: a -> b, and applies it to > a Cypher a, giving you a Cypher b. No deciphering happens. The > function get lifted/mapped into Cypher. > >> So, then it seems reasonable that the only type for doWork is this: >> doWork :: Cypher a -> (Cypher a -> Cypher b) -> Cypher b >> >> Which doesn't really seem all that useful now. > > Indeed. That is just (a restricted version of) the type of 'flip ($)', > a rather uninteresting (though not useless) function. > >> On the other hand, maybe we have an algorithm which can take a function on >> normal values and gives us a function on Cypher values: >> >> enCypher :: (a -> b) -> Cypher a -> Cypher b > > This is exactly what you have. This is just the flipped version of > your first doWork. > > And this function is better known as fmap. Cypher is a Functor. > > Because they have special syntax, are widely used in IO, and have a > scary name (and perhaps for other, better reasons too), Monads seem to > attract special attention. > > Functor and Applicative get much less love, but both are valuable and > interesting typeclasses (they form a hierarchy: every monad is an > applicative functor, and ever applicative functor is a functor). And > hopefully your spidey-sense now has a Functor-detector :) > > I was planning to show that Cypher can't be a monad or an applicative > functor, but their seems to be a hole in my thinking. Hopefully I can > fix it, and hopefully everything I've said up to now has been correct. > > --Max > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From anton at appsolutions.com Wed Jul 15 19:59:36 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Wed Jul 15 19:41:25 2009 Subject: [Haskell-cafe] Debugging methods for haskell In-Reply-To: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Message-ID: <4A5E6D68.6030901@appsolutions.com> Fernan Bolando wrote: > Program error: Prelude.!!: index too large > > This is not very informative. It did not give me a hint which function > was causing this. In addition to the debugging methods that have been mentioned, the "Safe" library provides a way to write the code more robustly and/or informatively: http://hackage.haskell.org/package/safe http://community.haskell.org/~ndm/safe/ Among other things, it provides replacements for the (!!) operator which would have likely have helped in this case. Anton From jwlato at gmail.com Wed Jul 15 20:05:39 2009 From: jwlato at gmail.com (John Lato) Date: Wed Jul 15 19:47:29 2009 Subject: [Haskell-cafe] Re: Problems with nested Monads Message-ID: <9979e72e0907151705v65b37c50n242acccb27fe7773@mail.gmail.com> If M is a monad transformer (e.g. StateT) and able to be parameterised over an arbitrary monad, you can do something related, which may actually be more useful to you. Given the definition of StateT from mtl: newtype StateT s m a = StateT { runStateT :: s -> m (a, s) } you could define this join-like function: join2 :: (Monad n) => n (StateT s n a) -> StateT s n a join2 m = StateT (\state -> m >>= flip runStateT state) (I don't know a good name for this function; it's called "joinIM" in iteratee) Perhaps this would apply to your situation? Cheers, John Lato > > Message: 18 > Date: Fri, 10 Jul 2009 17:25:55 -0400 > From: Job Vranish > Subject: Re: [Haskell-cafe] Problems with nested Monads > To: Edward Kmett > Cc: Haskell Cafe mailing list > Message-ID: > ? ? ? ? > Content-Type: text/plain; charset="iso-8859-1" > > Yeah, I think the problem with my case is that while M is a specific monad > (essentially StateT), N can be an arbitrary monad, which I think destroys my > changes of making a valid joinInner/joinOuter/distribute. > Maybe someday Haskell will infer valid joinInner/joinOuter for simple cases > :D > Thanks for you help. I'll definitely have to see if I can find that paper. > > - Job Vranish > > On Fri, Jul 10, 2009 at 3:09 PM, Edward Kmett wrote: > >> The problem you have is that monad composition isn't defined in general. >> You would need some form of distributive law either for your monads in >> general, or for your particular monads wrapped around this particular kind >> of value. >> >> What I would look for is a function of the form of one of: >> >> distribute :: N (M a) -> M (N a) >> joinInner :: M (N (M a)) -> M (N a) >> joinOuter :: N (M (N a)) -> M (N a) >> >> that holds for your partiular monads M and N. >> >> IIRC Mark P. Jones wrote a paper or a lib back around '93 that used these >> forms of distributive laws to derive monads from the composition of a monad >> and a pointed endofunctor. >> >> -Edward Kmett >> >> On Fri, Jul 10, 2009 at 11:34 AM, Job Vranish wrote: >> >>> I'm trying to make a function that uses another monadic function inside a >>> preexisting monad, and I'm having trouble. >>> Basically my problem boils down to this. I have three monadic functions >>> with the following types: >>> f :: A -> M B >>> g :: B -> N C >>> h :: C -> M D >>> (M and N are in the monad class) >>> I want a function i where >>> i :: A -> M (N D) >>> >>> the best I can come up with is: >>> i :: A -> M (N (M D)) >>> i a = liftM (liftM h) =<< (return . g) (f a) >>> >>> I'm starting to feel pretty sure that what I'm going for is impossible. Is >>> this the case? >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> From briqueabraque at yahoo.com Wed Jul 15 20:09:28 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Wed Jul 15 19:51:34 2009 Subject: [Haskell-cafe] Re: Mixing C and Haskell code in the same file In-Reply-To: <212312311.20090712222652@gmail.com> References: <212312311.20090712222652@gmail.com> Message-ID: > #def inline int signof(int x) {return x<0?-1:x>0?1:0;} > foreign import ccall safe "" > signof :: CInt -> CInt Is it possible to get that #def as a result of a macro? Say, something like this: --- (WARNING: invalid code) #define ret(name,value,type) \ #def inline type name (void) {return value;} --- Thanks, Maur?cio From ok at cs.otago.ac.nz Wed Jul 15 21:38:14 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Jul 15 21:20:05 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago In-Reply-To: <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> Message-ID: <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> On Jul 15, 2009, at 5:25 PM, Benjamin L.Russell wrote: > it interesting that you should use the biological term "disease"; > according to a post [1] entitled "Re: Re: Smalltalk Data Structures > and Algorithms," by K. K. Subramaniam, dated "Mon, 29 Jun 2009 > 11:25:34 +0530," on the squeak-beginners mailing list (see > http://lists.squeakfoundation.org/pipermail/beginners/2009-June/006270.html) > , >> Concepts in Squeak [a dialect and implementation of Smalltalk] have > their origins >> in biology rather than in computational math.... That posting is wrong. Smalltalk's roots are very firmly planted in Lisp, with perhaps a touch of Logo (which also had its roots in Lisp). The classic Smalltalk-76 paper even contains a meta-circular interpreter, which I found reminiscent of the old Lisp one. The "biological" metaphor in Smalltalk is actually a SOCIAL metaphor: sending and receiving messages, and a "social" model of agents with memory exchanging messages naturally leads to anthropomorphisms. The other classic OO language, which inspired C++, which inspired Java, which inspired C#, is Simula 67, which has its roots in Algol 60. While Simula 67 was sometimes used for simulating biological processes, the main background was discrete event systems like factories and shops; there are no biological metaphors in Simula. From ok at cs.otago.ac.nz Wed Jul 15 21:45:21 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Jul 15 21:27:15 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> Message-ID: On Jul 15, 2009, at 9:59 PM, minh thu wrote: > 2009/7/15 Magicloud Magiclouds : >> Hi, >> I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code >> could not be compiled, parse error. > > ++ is a function; you can't pattern-match on that. Doesn't matter, it's not trying to. Part of Erlang syntax is that in a pattern [c1,...,cn] ++ P is equivalent to [c1,...,cn|P] For example, wee(X) -> F = fun ([0,1] ++ L) -> L end, F(X). is perfectly legal. The problem might be the "xs", or it might be the "=". Presumably it should be fun ([0,1] ++ Xs) -> ... From ok at cs.otago.ac.nz Wed Jul 15 21:56:07 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Jul 15 21:38:00 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> Message-ID: On Jul 15, 2009, at 9:57 PM, Magicloud Magiclouds wrote: > Hi, > I do not notice this before. "fun ([0, 1] ++ xs) = .." in my code > could not be compiled, parse error. I apologise to everyone for my previous message in this thread. There was a Haskell message in amongst some Erlang messages, and I thought this was an Erlang problem. There are some programming languages, including Erlang, in which ++ IS accepted as a . Haskell is not one of them. It could be, and there would be no ambiguity in elementary cases, and it would no more involve matching against ++ than n+1 involves matching against +. Since the pattern on the left of the ++ is required to be an explicit list, there is no the slightest question of backtracking or anything more general than ordinary pattern matching. Consider [a,b,c]++xs a:b:c:xs The second is in general shorter (though less clear; it is a real pity that Haskell syntax doesn't include something like Clean's [head:tail], the inconsistency is irritating). It's not the general case that this syntax was invented for, but the case where the list is a string. "abc"++xs 'a':'b':'c':xs One of the arguments advanced against n+k patterns is "which scope should + be looked up in? what if the + in the standard prelude is not in scope?" The same question can be asked about list++tail patterns; what should it mean if the prelude's ++ was not in scope? Programmers who have met "abc"++Xs sometimes turn around and ask for Xs++"abc". Perhaps it is better to keep the camel's nose out of the tent. From robgreayer at gmail.com Wed Jul 15 22:35:43 2009 From: robgreayer at gmail.com (Robert Greayer) Date: Wed Jul 15 22:17:31 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot In-Reply-To: References: Message-ID: <4ec472cb0907151935s586a7e2eqb3f82fba760e58cf@mail.gmail.com> On Wed, Jul 15, 2009 at 2:18 PM, Max Rabkin wrote: > On Wed, Jul 15, 2009 at 7:33 PM, Cristiano > Paris wrote: >> fib = 1:1:fib `plus` (tail fib) where plus = zipWith (+) > ... > ... > This indicates that you think tying the knot should be impossible in > Python. In my opinion this is not the case. By my definition of tying > the knot, one needs *either* mutable variables or laziness (at least > in simple cases). Since Python has the former, it is possible to tie > the knot in Python. Isn't tying the knot (in the way 'fib' does) straightforward with closures a la Python/Ruby/Smalltalk (without mutation)? Even in a syntactically clumsy language like Java, a tying-the-knot implementation equivalent to the canonical Haskell one is not difficult, e.g. static L fibs = new L() { public int head() { return 1; } public L tail() { return new L() { public int head() { return 1; } public L tail() { return new L() { public int head() { return fibs.head() + fibs.tail().head(); } public L tail() { return zip(fibs.tail(), fibs.tail().tail()); } }; } }; } }; Given a definition of list L and zip... interface L { int head(); L tail(); } static L zip(final L l0, final L l1) { return new L() { public int head() { return l0.head() + l1.head(); } public L tail() { return zip(l0.tail(), l1.tail()); } }; } From matthew at brecknell.net Thu Jul 16 01:27:40 2009 From: matthew at brecknell.net (Matthew Brecknell) Date: Thu Jul 16 01:10:07 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot In-Reply-To: <4ec472cb0907151935s586a7e2eqb3f82fba760e58cf@mail.gmail.com> References: <4ec472cb0907151935s586a7e2eqb3f82fba760e58cf@mail.gmail.com> Message-ID: <1247722060.8533.71.camel@localhost> Robert Greayer wrote: > Isn't tying the knot (in the way 'fib' does) straightforward with closures > a la Python/Ruby/Smalltalk (without mutation)? > Even in a syntactically clumsy language like Java, a > tying-the-knot implementation equivalent to the canonical Haskell one is > not difficult, e.g. > > static L fibs = new L() { > public int head() { return 1; } > public L tail() { > return new L() { > public int head() { return 1; } > public L tail() { > return new L() { > public int head() { return fibs.head() + > fibs.tail().head(); } > public L tail() { return zip(fibs.tail(), > fibs.tail().tail()); } > }; > } > }; > } > }; > > Given a definition of list L and zip... > > interface L { int head(); L tail(); } > static L zip(final L l0, final L l1) { > return new L() { > public int head() { return l0.head() + l1.head(); } > public L tail() { return zip(l0.tail(), l1.tail()); } > }; > } Are you sure there's not a super-linear time complexity hidden in there? Unless Java compilers are clever enough to memoize this kind of code, I think each subsequent call to the head() will just recurse all the way down to the bottom an exponentially increasing number of times. To simulate laziness, I think you would need to actually store fibs *as data* somewhere, and you'd presumably need to simulate the process of replacing a thunk with its value on its first evaluation. In python, for example: class value: def __init__(self, *value): self.value = value def __call__(self): return self.value class thunk: def __init__(self, susp): self.susp = susp def __call__(self): try: return self.result except: self.result = self.susp() del self.susp return self.result def tail(xs): x,r = xs() return r def zipWithPlus(xs,ys): x,xr = xs() y,yr = ys() return x+y, thunk(lambda: zipWithPlus(xr,yr)) fibs = value(0, value(1, thunk(lambda: zipWithPlus(fibs, tail(fibs))))) def fibgen(): g = fibs while True: x,g = g() yield x Needless to say: I prefer the Haskell! From sebf at informatik.uni-kiel.de Thu Jul 16 03:21:10 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Jul 16 03:03:02 2009 Subject: [Haskell-cafe] Pattern matching does not work like this? In-Reply-To: References: <3bd412d40907150257v5caadea8k9e4d7b1868e77fc3@mail.gmail.com> <40a414c20907150259q5782bae5xeb741783ec5c8aa8@mail.gmail.com> <5e0214850907150325g58d11e8dkda780407c30fdb98@mail.gmail.com> <14F8AEDB-8E2C-44F3-8A6B-583F9644EC39@math.su.se> <7ca3f0160907150422n2f73e067s4edbb3084d7231ca@mail.gmail.com> Message-ID: On Jul 15, 2009, at 2:30 PM, Hans Aberg wrote: >> If ++ could be pattern matched, what should have been the result of >> "let (x++y)=[1,2,3] in (x,y)"? >> >> It will branch. In terms of unification, you get a list of >> substitutions. >> >> f :: [a] -> ([a],[a]) >> f (x ++ y) = (x,y) > > For an argument s, any pair (x, y) satisfying s = x ++ y will match. > That is, if s = [s_1, ..., s_k], the solutions j = 0, ..., k, x = > [s_1, ..., s_j], y = [s_(j+1), ..., s_k]. And for each one, a > potentially different value could given. That is, s could produce > multiple values. Curry (a Haskell extension with non-determinism) supports exactly that. Sergio Antoy and Michael Hanus: Declarative Programming with Function Patterns available at: -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From v.dijk.bas at gmail.com Thu Jul 16 03:57:25 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Jul 16 03:39:12 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: <2f9b2d30907150935o36b7fd6fg10bbabdb62bb72b4@mail.gmail.com> References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> <2f9b2d30907150935o36b7fd6fg10bbabdb62bb72b4@mail.gmail.com> Message-ID: On Wed, Jul 15, 2009 at 6:35 PM, Ryan Ingram wrote: > iterate' f x = x `seq` x : iterate' f (f x) > seems better; it doesn't evaluate list elements you don't visit. iterate'' f x = x : (iterate'' f $! f x) ...seems the most lazy strict iterate. (Bas wishes for a type system that can express the different strictness properties of these functions...) From jon.fairbairn at cl.cam.ac.uk Thu Jul 16 04:10:22 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Thu Jul 16 03:52:24 2009 Subject: [Haskell-cafe] Re: Debugging methods for haskell References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Message-ID: Fernan Bolando writes: > Hi all > > I recently used 2 hours of work looking for a bug that was causing > > Program error: Prelude.!!: index too large > > This is not very informative. It did not give me a hint which function > was causing this. In C adding a few printf would have helped me, but > in haskell I was not sure how to do that. Can anybody point me to some > debuggin method everyone uses. > > After 2 hours I did find the bug eventually. The code can be viewed here. > Maybe some reformatting of the code would make finding bugs easier? > http://plan9.bell-labs.com/sources/contrib/fernan/escomma/ I wonder if your code has to use !! at all? I took a look at a random module from the above link, and (without making much attempt at understanding it), I'd guess that using accumArray and friends would be more appropriate. Mostly you don't want to be doing indexing on lists. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From nominolo at googlemail.com Thu Jul 16 04:56:20 2009 From: nominolo at googlemail.com (Thomas Schilling) Date: Thu Jul 16 04:38:09 2009 Subject: [Haskell-cafe] Debugging methods for haskell In-Reply-To: <1247699850-sup-516@nixos> References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> <1247699850-sup-516@nixos> Message-ID: <916b84820907160156p2eb0963arfa646dd1a8e9de91@mail.gmail.com> 2009/7/16 Marc Weber > > > I recall there was another method. Yeah, I even found it (using ghci and > set -fbreak-on-exception) > > http://donsbot.wordpress.com/2007/11/14/no-more-exceptions-debugging-haskell-code-with-ghci/ Careful, better use -fbreak-on-error rather than -fbreak-on-exception. Some functions, e.g. 'doesFileExist', use exceptions internally and you might end up stopping at an exception that is benign. (Identifying the exception has become a little harder since we got extensible exceptions.) -- Push the envelope. Watch it bend. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090716/01a13e7c/attachment.html From matthias.goergens at googlemail.com Thu Jul 16 06:38:53 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Jul 16 06:20:42 2009 Subject: [Haskell-cafe] Debugging methods for haskell In-Reply-To: <20090715221333.GJ25885@whirlpool.galois.com> References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> <20090715221333.GJ25885@whirlpool.galois.com> Message-ID: By the way, does Hat - the Haskell Tracer? From matthias.goergens at googlemail.com Thu Jul 16 06:39:24 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Jul 16 06:21:13 2009 Subject: [Haskell-cafe] Debugging methods for haskell In-Reply-To: References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> <20090715221333.GJ25885@whirlpool.galois.com> Message-ID: > By the way, does Hat - the Haskell Tracer? Please append: "still work". From fernanbolando at mailc.net Thu Jul 16 06:59:04 2009 From: fernanbolando at mailc.net (Fernan Bolando) Date: Thu Jul 16 06:40:52 2009 Subject: [Haskell-cafe] Re: Debugging methods for haskell In-Reply-To: References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Message-ID: <1d5d51400907160359t25b688a3reab94e34962a1b85@mail.gmail.com> On Thu, Jul 16, 2009 at 4:10 PM, Jon Fairbairn wrote: > I wonder if your code has to use !! at all? I took a look at a random > module from the above link, and (without making much attempt at > understanding it), I'd guess that using accumArray and friends would be > more appropriate. Mostly you don't want to be doing indexing on lists. > > -- > J?n Fairbairn ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Jon.Fairbairn@cl.cam.ac.uk Thanks for everyone's suggestion. Don Stewarts tools seems to be most appropriate for me. Most of the !! are used to access a list of parameters similar to accessing structures in C. I am not particularly sure how to apply accumArray for something like that? I will go through the accumArray documentation and see how I might apply them. thanks again. fernan -- http://www.fernski.com From apfelmus at quantentunnel.de Thu Jul 16 07:11:17 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Jul 16 06:53:07 2009 Subject: [Haskell-cafe] Re: Haskell Zippers on Wikibooks: teasing! :) In-Reply-To: References: Message-ID: Peter Verswyvelen wrote: > After my colleague explained me about zippers and how one could derive the > datatype using differential rules, I had to read about it. > > So I started reading > http://en.wikibooks.org/wiki/Haskell/Zippers#Mechanical_Differentiation > > This page contains the sentence: *"For a systematic construction, we need > to calculate with types. The basics of structural calculations with types > are outlined in a separate chapter **Generic > Programming* > * and we will heavily rely on this material"* > * > * > However, the generic programming link does not exist yet :-) A clear case of laziness on the author's part... wait, that would be me. :-O In any case, contributions to the wikibook would be most welcome. ;-) For now, I'd recommend Generic Programming: An introduction http://www.cse.chalmers.se/~patrikj/poly/afp98/ It's a bit verbose at times, but you only need the first few chapters to get an idea about polynomial functors (sums and pairs) and mu . Regards, apfelmus -- http://apfelmus.nfshost.com From ifl2009 at shu.edu Thu Jul 16 10:21:30 2009 From: ifl2009 at shu.edu (IFL 2009) Date: Thu Jul 16 10:03:24 2009 Subject: [Haskell-cafe] IFL 2009: Third Call for Papers Message-ID: An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090716/02ea3f3c/attachment-0001.html From jon.fairbairn at cl.cam.ac.uk Thu Jul 16 10:49:07 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Thu Jul 16 10:31:09 2009 Subject: [Haskell-cafe] Re: Debugging methods for haskell References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> <1d5d51400907160359t25b688a3reab94e34962a1b85@mail.gmail.com> Message-ID: Fernan Bolando writes: > On Thu, Jul 16, 2009 at 4:10 PM, Jon > Fairbairn wrote: > >> I wonder if your code has to use !! at all? I took a look at a random >> module from the above link, and (without making much attempt at >> understanding it), I'd guess that using accumArray and friends would be >> more appropriate. Mostly you don't want to be doing indexing on lists. > > Most of the !! are used to access a list of parameters similar to > accessing structures in C. Ah. I wondered why so many of them were x!!0. list!!constant is almost always something that could be done better. > I am not particularly sure how to apply accumArray for something like > that? You [probably] don't. My apologies for not looking more carefully (I really did just glance at it), but the remark about not using !! still stands. I've been trying to look at your source again, but the link doesn't respond to requests at the moment, so I can't be much help. Haskell has much richer mechanisms for doing structure-like things than C. Tuples and data types being the most obvious. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From magnus at therning.org Thu Jul 16 10:56:51 2009 From: magnus at therning.org (Magnus Therning) Date: Thu Jul 16 10:38:41 2009 Subject: [Haskell-cafe] Debugging methods for haskell In-Reply-To: <20090715221333.GJ25885@whirlpool.galois.com> References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> <20090715221333.GJ25885@whirlpool.galois.com> Message-ID: On Wed, Jul 15, 2009 at 11:13 PM, Don Stewart wrote: > fernanbolando: >> Hi all >> >> I recently used 2 hours of work looking for a bug that was causing >> >> Program error: Prelude.!!: index too large >> >> This is not very informative. It did not give me a hint which function >> was causing this. In C adding a few printf would have helped me, but >> in haskell I was not sure how to do that. Can anybody point me to some >> debuggin method everyone uses. > > You could: > > ? ?* use Debug.Trace.trace ?(equivalent of printf debugging) > ? ?* use asserts: the 'assert' function > ? ?* use the GHCi debugger to construct a stack trace > ? ?* use profiling to construct a stack trace. > ? ?* use the GHC head branch for first class stack traces, described > ? ? ? ? ?in, "Finding the needle: Stack Traces for GHC" > ? ? ? ? ? ? ? ?http://pubs.doc.ic.ac.uk/finding-the-needle/finding-the-needle.pdf Another option would be to use Safe.atMay[1] instead of !!. [1]: http://hackage.haskell.org/packages/archive/safe/0.2/doc/html/Safe.html#v%3Aat -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From ithika at gmail.com Thu Jul 16 11:47:26 2009 From: ithika at gmail.com (Dougal Stanton) Date: Thu Jul 16 11:29:14 2009 Subject: [Haskell-cafe] Re: Haskell Zippers on Wikibooks: teasing! :) In-Reply-To: References: Message-ID: <2d3641330907160847h1e0bd1bcjccd5237c59c3c2c8@mail.gmail.com> On Thu, Jul 16, 2009 at 12:11 PM, Heinrich Apfelmus wrote: > > ? Generic Programming: An introduction > ? http://www.cse.chalmers.se/~patrikj/poly/afp98/ > > It's a bit verbose at times, but you only need the first few chapters to > get an idea about polynomial functors (sums and pairs) and ?mu . Thanks, that's a really nice introduction, which seems to be at just my level for the moment! :-) D From gale at sefer.org Thu Jul 16 12:07:31 2009 From: gale at sefer.org (Yitzchak Gale) Date: Thu Jul 16 11:49:43 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <20090709165848.GF28909@whirlpool.galois.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <20090709163317.GB28909@whirlpool.galois.com> <111343925.20090709205648@gmail.com> <20090709165848.GF28909@whirlpool.galois.com> Message-ID: <2608b8a80907160907x5481cdfcqacb9c0f3a3f1f9f2@mail.gmail.com> Don Stewart wrote: > ?Newbies: > ? ?http://haskell.org > > ?Everything regular users need at fingertips > ? ?http://dashboard.haskell.org/ That's fine. But please, no matter how minimalist the newbie page, make sure that there is a clear and prominent link there to the advanced page. Otherwise, if I happen to be somewhere without my bookmarks, it will take me a lot of fumbling in the dark to find it. Thanks, Yitz From roy.lowrance at gmail.com Thu Jul 16 12:25:01 2009 From: roy.lowrance at gmail.com (Roy Lowrance) Date: Thu Jul 16 12:06:47 2009 Subject: [Haskell-cafe] Parsec for C or C++ Message-ID: <162be4f00907160925s32248697sa5f890043e281724@mail.gmail.com> I am working on a research language that is a variant of C. I'd like to use Parsec as the parser. Is there an existing Parsec parser for C or C++ (or Java) that could serve as a starting point? Thanks, Roy From rick.richardson at gmail.com Thu Jul 16 12:29:31 2009 From: rick.richardson at gmail.com (Rick R) Date: Thu Jul 16 12:11:23 2009 Subject: [Haskell-cafe] Parsec for C or C++ In-Reply-To: <162be4f00907160925s32248697sa5f890043e281724@mail.gmail.com> References: <162be4f00907160925s32248697sa5f890043e281724@mail.gmail.com> Message-ID: <9810b81b0907160929g101815a6t36b99a96f39b14eb@mail.gmail.com> There is language.c http://www.sivity.net/projects/language.c/ http://hackage.haskell.org/package/language-c >From a parsing standpoint, C++ is a massive departure from C. Good luck though. On Thu, Jul 16, 2009 at 12:25 PM, Roy Lowrance wrote: > I am working on a research language that is a variant of C. I'd like > to use Parsec as the parser. > > Is there an existing Parsec parser for C or C++ (or Java) that could > serve as a starting point? > > Thanks, Roy > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- "The greatest obstacle to discovering the shape of the earth, the continents, and the oceans was not ignorance but the illusion of knowledge." - Daniel J. Boorstin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090716/6eab5a80/attachment.html From rick.richardson at gmail.com Thu Jul 16 12:39:48 2009 From: rick.richardson at gmail.com (Rick R) Date: Thu Jul 16 12:21:37 2009 Subject: [Haskell-cafe] Parsec for C or C++ In-Reply-To: <9810b81b0907160929g101815a6t36b99a96f39b14eb@mail.gmail.com> References: <162be4f00907160925s32248697sa5f890043e281724@mail.gmail.com> <9810b81b0907160929g101815a6t36b99a96f39b14eb@mail.gmail.com> Message-ID: <9810b81b0907160939g8d40d3ehf8087aff3ededb71@mail.gmail.com> I too have a looming spectre of a C++ analysis project, one of the goals of the project is to be able to efficiently process huge volumes (read GBs) of code. Given the current benchmarks of language.c compared to the g++ front end. I was thinking of using an existing C++ parser written in C++, probably Elsa[1]. Then use haskell to analyze the resulting AST. [1] http://74.125.95.132/search?q=cache:7z7wl7oiy70J:www.eecs.berkeley.edu/~smcpeak/elkhound/sources/elsa/+elsa+c%2B%2B&cd=1&hl=en&ct=clnk&gl=us&client=firefox-a The link seems to be dead at the moment. On Thu, Jul 16, 2009 at 12:29 PM, Rick R wrote: > There is language.c > > http://www.sivity.net/projects/language.c/ > http://hackage.haskell.org/package/language-c > > > From a parsing standpoint, C++ is a massive departure from C. Good luck > though. > > > On Thu, Jul 16, 2009 at 12:25 PM, Roy Lowrance wrote: > >> I am working on a research language that is a variant of C. I'd like >> to use Parsec as the parser. >> >> Is there an existing Parsec parser for C or C++ (or Java) that could >> serve as a starting point? >> >> Thanks, Roy >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > "The greatest obstacle to discovering the shape of the earth, the > continents, and the oceans was not ignorance but the illusion of knowledge." > > - Daniel J. Boorstin > > -- "The greatest obstacle to discovering the shape of the earth, the continents, and the oceans was not ignorance but the illusion of knowledge." - Daniel J. Boorstin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090716/8e4b59a3/attachment.html From roy.lowrance at gmail.com Thu Jul 16 12:43:20 2009 From: roy.lowrance at gmail.com (Roy Lowrance) Date: Thu Jul 16 12:25:07 2009 Subject: [Haskell-cafe] Parsec for C or C++ In-Reply-To: <9810b81b0907160929g101815a6t36b99a96f39b14eb@mail.gmail.com> References: <162be4f00907160925s32248697sa5f890043e281724@mail.gmail.com> <9810b81b0907160929g101815a6t36b99a96f39b14eb@mail.gmail.com> Message-ID: <162be4f00907160943y3f53d8c1m6667f01dfd5ac412@mail.gmail.com> Thanks Rick. A perfect tip! - Roy On Thu, Jul 16, 2009 at 12:29 PM, Rick R wrote: > There is language.c > > http://www.sivity.net/projects/language.c/ > http://hackage.haskell.org/package/language-c > > > From a parsing standpoint, C++ is a massive departure from C. Good luck > though. > > > On Thu, Jul 16, 2009 at 12:25 PM, Roy Lowrance > wrote: >> >> I am working on a research language that is a variant of C. I'd like >> to use Parsec as the parser. >> >> Is there an existing Parsec parser for C or C++ (or Java) that could >> serve as a starting point? >> >> Thanks, Roy >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > "The greatest obstacle to discovering the shape of the earth, the > continents, and the oceans was not ignorance but the illusion of knowledge." > - Daniel J. Boorstin > > -- Roy Lowrance home: 212 674 9777 mobile: 347 255 2544 From tom.davie at gmail.com Thu Jul 16 12:56:46 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Jul 16 12:38:51 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> Message-ID: <5122A850-0E0F-4E05-A38B-3B83333E485D@gmail.com> On 15 Jul 2009, at 06:03, Richard O'Keefe wrote: > > On Jul 10, 2009, at 6:14 PM, Thomas Davie wrote: >> In my mind, the front page is for nothing more than enticing people >> to use Haskell for long enough to look at a second page where all >> the useful stuff is if you are a haskell programmer. > > I would have thought that a web page should serve its > most frequent visitors best. By all means have an enticing > paragraph at the top, pointing to a second page, but why > make life hard for regular Haskellers visiting their site? Because regular haskellers are perfectly capable of bookmarking http://haskell.org/usefullstuff.html , while newbies will only get what google tells them -- the front page. Bob From roy.lowrance at gmail.com Thu Jul 16 13:40:35 2009 From: roy.lowrance at gmail.com (Roy Lowrance) Date: Thu Jul 16 13:22:21 2009 Subject: [Haskell-cafe] Parsec for C or C++ In-Reply-To: <162be4f00907160943y3f53d8c1m6667f01dfd5ac412@mail.gmail.com> References: <162be4f00907160925s32248697sa5f890043e281724@mail.gmail.com> <9810b81b0907160929g101815a6t36b99a96f39b14eb@mail.gmail.com> <162be4f00907160943y3f53d8c1m6667f01dfd5ac412@mail.gmail.com> Message-ID: <162be4f00907161040t1131d740j4fd826e777567a1d@mail.gmail.com> Turns out that Language.C uses alex and happy. I'm looking to use Parsec. So back to the original question: Does anyone know of a C or java parser written using Parsec? - Roy On Thu, Jul 16, 2009 at 12:43 PM, Roy Lowrance wrote: > Thanks Rick. A perfect tip! - Roy > > On Thu, Jul 16, 2009 at 12:29 PM, Rick R wrote: >> There is language.c >> >> http://www.sivity.net/projects/language.c/ >> http://hackage.haskell.org/package/language-c >> >> >> From a parsing standpoint, C++ is a massive departure from C. Good luck >> though. >> >> >> On Thu, Jul 16, 2009 at 12:25 PM, Roy Lowrance >> wrote: >>> >>> I am working on a research language that is a variant of C. I'd like >>> to use Parsec as the parser. >>> >>> Is there an existing Parsec parser for C or C++ (or Java) that could >>> serve as a starting point? >>> >>> Thanks, Roy >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> >> -- >> "The greatest obstacle to discovering the shape of the earth, the >> continents, and the oceans was not ignorance but the illusion of knowledge." >> - Daniel J. Boorstin >> >> > > > > -- > Roy Lowrance > home: 212 674 9777 > mobile: 347 255 2544 > -- Roy Lowrance home: 212 674 9777 mobile: 347 255 2544 From tphyahoo at gmail.com Thu Jul 16 13:45:23 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Jul 16 13:27:09 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> Message-ID: <910ddf450907161045i3aaf3047q992260694a2f5233@mail.gmail.com> the strict functions seem very nice, will they eventually make their way into http://hackage.haskell.org/packages/archive/Stream/0.3.2/doc/html/Data-Stream.html ? where is Control.Monad.StreamT? couldn't find it. 2009/7/15 Bas van Dijk : > On Wed, Jul 15, 2009 at 3:02 AM, Thomas Hartman wrote: >> Please suggest more of these types of exercises if you have them and >> maybe we can collect the folk wisdom into a wiki page and/or exercise >> page for beginners. > > My 'stream' library[1] also has some examples. Look at the following > functions in 'Data.Stream': > > * mapAccum' > * scan' > * iterate' > * unfold' > > There are similar examples in 'Control.Monad.StreamT'. > > [1] http://code.haskell.org/~basvandijk/code/stream/ ?(Not on Hackage) > From tphyahoo at gmail.com Thu Jul 16 14:22:19 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Jul 16 14:04:07 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> <2f9b2d30907150935o36b7fd6fg10bbabdb62bb72b4@mail.gmail.com> Message-ID: <910ddf450907161122i7e610166q7a39d4a65cd91ca0@mail.gmail.com> I played with this a bit, and ok, it seems the difference between iterate' and iterate'' is h _ = 2 tit' = head . drop 1 . iterate' h $ undefined tit'' = head . drop 1 . iterate'' h $ undefined > (Bas wishes for a type system that can express the different strictness properties of these functions...) Is this being worked on? Could you give some example of type systems that can express differences between functions of along dimension x? Off the top of my head, I guess (?) with dependent types can tell the difference between total and partial functions... partials won't even compile, right? Are there others? Pointers appreciated. > ...seems the most lazy strict iterate. could you expand on what you mean by this? 2009/7/16 Bas van Dijk : > On Wed, Jul 15, 2009 at 6:35 PM, Ryan Ingram wrote: >> iterate' f x = x `seq` x : iterate' f (f x) >> seems better; it doesn't evaluate list elements you don't visit. > > iterate'' f x = x : (iterate'' f $! f x) > > ...seems the most lazy strict iterate. > > (Bas wishes for a type system that can express the different > strictness properties of these functions...) > From andrewcoppin at btinternet.com Thu Jul 16 14:34:18 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Jul 16 14:15:54 2009 Subject: [Haskell-cafe] A voyage of undiscovery Message-ID: <4A5F72AA.9060402@btinternet.com> I've been working hard this week, and I'm stumbled upon something which is probably of absolutely no surprise to anybody but me. Consider the following expression: (foo True, foo 'x') Is this expression well-typed? Astonishingly, the answer depends on where "foo" is defined. If "foo" is a local variable, then the above expression is guaranteed to be ill-typed. However, if we have (for example) foo :: x -> x as a top-level function, then the above expression becomes well-typed. I had never ever noticed this fact before. I'm still trying to bend my mind around exactly why it happens. As best as I can tell, top-level functions (and value constructors, for that matter) seem to get a "new" set of type variables each time they're used, but local variables each get a single type variable, so every mention of a local variable must be of the exact same type. Could this be what GHC's weird "forall" syntax is about? Does "forall x." mean that "x" gets replaced with a unique type variable each time? It's an interesting hypothesis... Anyway, not that anybody is likely to care, but I've just spent an entire week writing a program which can type-check simple Haskell expressions. As in, you type in an expression and give types to any free variables it involves (including value constructor functions), and it tells you the type of the expression and all its subexpressions. (Or tells you that it's ill-typed.) It turns out that this is radically less trivial than you'd imagine. (The ramblings above being just one of the issues I blundered into. Others include the subtleties of writing an expression parser, building a pretty-printer with bracketing that works correctly, and the fact that expression processing malfunctions horribly if you don't make all the variable names unique first...) Other issues were mostly related to the difficulty of constantly refactoring code because you're not quite sure what you're trying to do or how you're trying to do it. (And obscure type checker warnings about GADTs...) Well there we are. I don't suppose anybody will be overly impressed, but I'm glad to have finally got it to work. Now, if it could parse more than 10% of Haskell's syntax sugar, it might even be useful for something... From chrisdone at googlemail.com Thu Jul 16 14:40:01 2009 From: chrisdone at googlemail.com (Christopher Done) Date: Thu Jul 16 14:21:48 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <7f55268a0907161140t3dc9dd96j9f26a5e9d51f63a4@mail.gmail.com> I believe that from Scheme to Haskell is a natural transition, as I made the same transition myself. If you grasp the fundamental concepts of Scheme, Haskell seems like a step up. I will describe Haskell in terms of Scheme: # Haskell programs are more correct from the ground up Scheme will let you write (+ 2 "2") and only tell you that it's wrong when it tries to run it ("You can't add a number and a string!"), whereas Haskell won't even let you run it until the types are correct. What some find difficult is ``1'' has type Num a => a, which means "for all types a that are Numbers, a" (or just "all Number types"), e.g. Integer, Double, Rational, etc. But this concept is found Scheme -- in Scheme you have all sorts of number types; ``+'' means "add two numbers". In Haskell, we specify that notion explicitly. # Haskell is half wordy as Scheme Indeed, that is what drew me to Haskell away from Scheme. ## Problem 1 Consider the problem ``Double all the numbers in a list." In Scheme we might solve this problem like so: (map (lambda (n) (* n 2)) '(1 2 3 4) and the result would be (2 4 6). In Haskell, we can write the same: map (\n -> n * 2) [1,2,3,4] and the result would be [2,4,6]. But we take it one step further: map (*2) [1,2,3,4] This means the same as the previous Haskell example. But the formal parameter ``x'' has been tripped away because it is redundant. ## Problem 2 Another problem, ``Given a list of lists, reverse all the lists and double each number in them.'' So in Scheme, we might solve this like so: (map (lambda (list) (reverse (map (lambda (n) (* n 2)) list))) '(1 2 3 4 5)) In Haskell, the same solution is rendered thusly: map (reverse . map (*2)) [1,2,3,4] The ``foo . bar'' is equivalent to (\x -> foo (bar x)), or, in Scheme (lambda (x) (foo (bar x))). It's just that we have stripped the redundant formal parameters. ## Problem 3 Suppose our problem is ``Multiply the first three items of a list''. Our Scheme solution might be: (define (first-three-sum list) (* (car list) (cadr list) (caddr list))) In Haskell, we may write (admittedly, a better way to render this might be: firstThreeSum = sum . take 3): firstThreeSum (x:y:z:_) = x * y * z Here I have demonstrated pattern matching, a powerful and oft-used feature of Haskell for deconstructing a data structure, like a list or a tuple, based on a pattern. I'll abruptly stop here before I write a whole article. I'll summarize by saying that Haskell is the next step, a natural progression where things that you know all too well from Scheme become easier, and safer. The stuff described here is just the tip of the ice burg, of course. I wish that I had learned Haskell as my first programming language! Haskell takes a lot of effort to learn, but gives back in equal amounts. It is a rough ride to learn any programming language. If you think otherwise, you are not learning, or are learning wrongly. 2009/7/14 Simon Peyton-Jones > > Haskell is a great language! ?Check out haskell.org. ? I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. ? (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) > > S > > | -----Original Message----- > | From: Charles Turner [mailto:charlie.h.turner@googlemail.com] > | Sent: 11 July 2009 22:52 > | To: Simon Peyton-Jones > | Subject: Haskell as a first language? > | > | I'll make this short! Do you think Haskell is a good language to start > | with? I am brand new to programming and have been using Scheme, some of > | my peers suggest I should use Haskell. It seems "professional" to me. > | Has features that a beginner should not worry about. What would you > | suggest. (I'm not worried about bias) > | > | Thank you very much for your time. > | > | Charles Turner. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From miguelimo38 at yandex.ru Thu Jul 16 14:40:27 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Jul 16 14:22:16 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A5F72AA.9060402@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> Message-ID: > Consider the following expression: > > (foo True, foo 'x') > > Is this expression well-typed? > > Astonishingly, the answer depends on where "foo" is defined. If > "foo" is a local variable, then the above expression is guaranteed > to be ill-typed. However, if we have (for example) That's not true: main = let foo x = x in print (foo True, foo 'x') works like a charm. From robgreayer at gmail.com Thu Jul 16 14:58:15 2009 From: robgreayer at gmail.com (Robert Greayer) Date: Thu Jul 16 14:40:03 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A5F72AA.9060402@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> Message-ID: <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> On Thu, Jul 16, 2009 at 2:34 PM, Andrew Coppin wrote: > I've been working hard this week, and I'm stumbled upon something which is > probably of absolutely no surprise to anybody but me. > > Consider the following expression: > > ?(foo True, foo 'x') > > Is this expression well-typed? > > Astonishingly, the answer depends on where "foo" is defined. If "foo" is a > local variable, then the above expression is guaranteed to be ill-typed. This isn't completely accurate: f0 _ = (foo True, foo 'x') where foo = id is well-typed. whereas f1 foo = (foo True, foo 'x') requires 'foo' to be polymorphic in its first argument. This does require a higher rank type, which can't be inferred: You could type f1 as f1 :: (forall a . a -> a) -> (Bool, Char) and apply it to 'id'. Or you could type it as something like: f1 :: (forall a . a -> ()) -> ((),()) and apply it to 'const ()' From v.dijk.bas at gmail.com Thu Jul 16 15:17:31 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Jul 16 14:59:18 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: <910ddf450907161045i3aaf3047q992260694a2f5233@mail.gmail.com> References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> <910ddf450907161045i3aaf3047q992260694a2f5233@mail.gmail.com> Message-ID: On Thu, Jul 16, 2009 at 7:45 PM, Thomas Hartman wrote: > the strict functions seem very nice, will they eventually make their way into > http://hackage.haskell.org/packages/archive/Stream/0.3.2/doc/html/Data-Stream.html Note that there are two stream packages: * 'Stream' by Wouter Swierstra (including some patches by me) which can be found on hackage. * 'stream' (with a lower case 'l') by me which isn't (yet) on hackage. My stream package started as a set of patches against Stream. However the goal Wouter had with Stream was to create a small education-friendly package focusing on simplicity. This is fine. The goal of stream however is to create an industrial-strength package, focusing on functionality and efficiency. Maybe I upload 'stream' to hackage if there's demand for it... > where is Control.Monad.StreamT? couldn't find it. http://code.haskell.org/~basvandijk/code/stream/Control/Monad/StreamT.hs regards, Bas From v.dijk.bas at gmail.com Thu Jul 16 15:35:35 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Jul 16 15:17:22 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: <910ddf450907161122i7e610166q7a39d4a65cd91ca0@mail.gmail.com> References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> <2f9b2d30907150935o36b7fd6fg10bbabdb62bb72b4@mail.gmail.com> <910ddf450907161122i7e610166q7a39d4a65cd91ca0@mail.gmail.com> Message-ID: On Thu, Jul 16, 2009 at 8:22 PM, Thomas Hartman wrote: > I played with this a bit, and ok, it seems the difference between > iterate' and iterate'' is > > h _ = 2 > > tit' = head . drop 1 . iterate' h $ undefined > tit'' = head . drop 1 . iterate'' h $ undefined Exactly, iterate' first evaluates 'undefined' which is undefined. iterate'' returns 'undefined : iterate'' h 2'. Which then evaluates to: 'undefined : 2 : iterate'' h 2'. So both iterates are strict in their accumulator. They differ in when they force it. The former is more strict in that it forces its accumulator on entry while the latter is more lazy by first returning the accumulator and later forcing it. >> (Bas wishes for a type system that can express the different > strictness properties of these functions...) > > Is this being worked on? I have no idea. regards, Bas From andrewcoppin at btinternet.com Thu Jul 16 15:40:14 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Jul 16 15:21:49 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> Message-ID: <4A5F821E.6000402@btinternet.com> Robert Greayer wrote: > f0 _ = (foo True, foo 'x') where foo = id > > is well-typed. > Really? That actually works? How interesting... This suggests to me that where-clauses also do strange things to the type system. > whereas > > f1 foo = (foo True, foo 'x') > > requires 'foo' to be polymorphic in its first argument. This does > require a higher rank type, which can't be inferred: > > You could type f1 as > f1 :: (forall a . a -> a) -> (Bool, Char) > > and apply it to 'id'. > > Or you could type it as something like: > f1 :: (forall a . a -> ()) -> ((),()) > > and apply it to 'const ()' ...all of which is beyond Haskell-98, which is what I am limiting myself to at present. (Actually, even that is a lie. I don't have type-classes yet...) From dvde at gmx.net Thu Jul 16 15:42:58 2009 From: dvde at gmx.net (Daniel van den Eijkel) Date: Thu Jul 16 15:24:46 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <4A5F82C2.9050603@gmx.net> In an ideal world, Haskell would be a perfect first programming language. But consider: If someone without any programming background learns Haskell as first language, she or he might have big problems using any other language after that. Unlearning what you can do with Haskell is much harder than unlearning imperative thinking. (I had to learn PHP after I was used to write in Haskell, and it was no fun) I don't want to miss the great experience of learning Haskell *after* Scheme (and Scheme after C), and I would not like to deprieve anybody of such an experience. Or what should they have for dessert? I don't know if that's a good argument. Best regards, Daniel From rmm-haskell at z.odi.ac Thu Jul 16 15:42:56 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Thu Jul 16 15:24:52 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A5F821E.6000402@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> Message-ID: <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> It's not where -- let also works let { foo Prelude> let { foo x = x } in (foo 1, foo True) (1,True) Can you send the code you're trying that doesn't work? -Ross On Jul 16, 2009, at 3:40 PM, Andrew Coppin wrote: > Robert Greayer wrote: >> f0 _ = (foo True, foo 'x') where foo = id >> >> is well-typed. >> > > Really? That actually works? How interesting... This suggests to me > that where-clauses also do strange things to the type system. > >> whereas >> >> f1 foo = (foo True, foo 'x') >> >> requires 'foo' to be polymorphic in its first argument. This does >> require a higher rank type, which can't be inferred: >> >> You could type f1 as >> f1 :: (forall a . a -> a) -> (Bool, Char) >> >> and apply it to 'id'. >> >> Or you could type it as something like: >> f1 :: (forall a . a -> ()) -> ((),()) >> >> and apply it to 'const ()' > > ...all of which is beyond Haskell-98, which is what I am limiting > myself to at present. > > (Actually, even that is a lie. I don't have type-classes yet...) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dagit at codersbase.com Thu Jul 16 15:50:06 2009 From: dagit at codersbase.com (Jason Dagit) Date: Thu Jul 16 15:31:53 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A5F821E.6000402@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> Message-ID: On Thu, Jul 16, 2009 at 12:40 PM, Andrew Coppin wrote: > Robert Greayer wrote: > >> f0 _ = (foo True, foo 'x') where foo = id >> >> is well-typed. >> >> > > Really? That actually works? How interesting... This suggests to me that > where-clauses also do strange things to the type system. You could think of it that way. You mentioned GADTs in your OP. Well, it turns out GADTs often do not play nicely with where/let and it happens to all be related. As I understand it, functions bind their parameters monomorphically and let/where bind things polymorphically. And then we have the misfeature known as the monomorphism restriction which adds special cases. > > whereas >> >> f1 foo = (foo True, foo 'x') >> >> requires 'foo' to be polymorphic in its first argument. This does >> require a higher rank type, which can't be inferred: >> >> You could type f1 as >> f1 :: (forall a . a -> a) -> (Bool, Char) >> >> and apply it to 'id'. >> >> Or you could type it as something like: >> f1 :: (forall a . a -> ()) -> ((),()) >> >> and apply it to 'const ()' >> > > ...all of which is beyond Haskell-98, which is what I am limiting myself to > at present. > > (Actually, even that is a lie. I don't have type-classes yet...) Congrats on the type inference engine you're writing. It's on my list of things to do, and I was even reading up on TaPL a month or two back, but I put it down and haven't picked it up again yet. I think writing one would help flush out my understand of all this stuff. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090716/597c34ae/attachment.html From andrewcoppin at btinternet.com Thu Jul 16 15:52:40 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Jul 16 15:34:14 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> Message-ID: <4A5F8508.3040403@btinternet.com> Ross Mellgren wrote: > It's not where -- let also works > > Prelude> let { foo x = x } in (foo 1, foo True) > (1,True) Awesome. So by attempting to implement Haskell's type system, I have discovered that I actually don't understand Haskell's type system. Who'd have thought it? Clearly I must go consult the Report and check precisely what the rules are... From ryani.spam at gmail.com Thu Jul 16 15:57:47 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Jul 16 15:39:35 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> <2f9b2d30907150935o36b7fd6fg10bbabdb62bb72b4@mail.gmail.com> <910ddf450907161122i7e610166q7a39d4a65cd91ca0@mail.gmail.com> Message-ID: <2f9b2d30907161257i3eb9a4e2ja2199d0d1d02a6e6@mail.gmail.com> > On Thu, Jul 16, 2009 at 8:22 PM, Thomas Hartman wrote: >> Is this being worked on? On Thu, Jul 16, 2009 at 12:35 PM, Bas van Dijk wrote: > I have no idea. Yes. Bolingbroke, Peyton-Jones. "Types are calling conventions" http://lambda-the-ultimate.org/node/3319 -- ryan From dons at galois.com Thu Jul 16 16:03:31 2009 From: dons at galois.com (Don Stewart) Date: Thu Jul 16 15:47:23 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <4A5F82C2.9050603@gmx.net> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5F82C2.9050603@gmx.net> Message-ID: <20090716200331.GH30256@whirlpool.galois.com> dvde: > In an ideal world, Haskell would be a perfect first programming language. > > But consider: If someone without any programming background learns > Haskell as first language, she or he might have big problems using any > other language after that. Unlearning what you can do with Haskell is > much harder than unlearning imperative thinking. (I had to learn PHP > after I was used to write in Haskell, and it was no fun) I don't want to > miss the great experience of learning Haskell *after* Scheme (and Scheme > after C), and I would not like to deprieve anybody of such an > experience. Or what should they have for dessert? FWIW, thousands of students from UNSW in Sydney learned Haskell as their first language throughout the 90s, before taking courses in C, Java, some scripting languages etc. Doesn't seem to have done any harm :) And you come away with a deeper appreciation of data structures and types. -- Don From chrisdone at googlemail.com Thu Jul 16 16:09:10 2009 From: chrisdone at googlemail.com (Christopher Done) Date: Thu Jul 16 15:50:56 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <4A5F82C2.9050603@gmx.net> References: <4A59097D.4070605@googlemail.com> <638ABD0A29C8884A91BC5FB5C349B1C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com> <4A5F82C2.9050603@gmx.net> Message-ID: <7f55268a0907161309x7b5a5375w7461842d85cc8a12@mail.gmail.com> 2009/7/16 Daniel van den Eijkel : > In an ideal world, Haskell would be a perfect first programming language. > > But consider: If someone without any programming background learns Haskell > as first language, she or he might have big problems using any other > language after that. Unlearning what you can do with Haskell is much harder > than unlearning imperative thinking. (I had to learn PHP after I was used to > write in Haskell, and it was no fun) I don't want to miss the great > experience of learning Haskell *after* Scheme (and Scheme after C), and I > would not like to deprieve anybody of such an experience. Or what should > they have for dessert? I think the transition from one paradigm to another is always hard, whatever the direction. That's why it's a paradigm. From andrewcoppin at btinternet.com Thu Jul 16 16:29:46 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Jul 16 16:11:22 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A5F8508.3040403@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> <4A5F8508.3040403@btinternet.com> Message-ID: <4A5F8DBA.6010908@btinternet.com> Andrew Coppin wrote: > Awesome. So by attempting to implement Haskell's type system, I have > discovered that I actually don't understand Haskell's type system. > Who'd have thought it? > > Clearly I must go consult the Report and check precisely what the > rules are... I just read section 4.5 of the Haskell 98 Report. Ouch! >_< I knew I'd be sorry I asked... Time for bed, I think! From szekeres at iii.hu Thu Jul 16 17:15:20 2009 From: szekeres at iii.hu (=?UTF-8?Q?Szekeres_Istv=C3=A1n?=) Date: Thu Jul 16 16:57:07 2009 Subject: [Haskell-cafe] Applying different functions to different types for lists Message-ID: Hi, I want to build a framework to apply different functions to different types of lists and I want to generalize the solution as much as possible but my Haskell knowledge is not really enough to do this (I'm a haskell novice). The problem has two dimensions: 1. Lets say I have two functions: r13, ul : Char -> Char where r13 returns the rot13ed character, and ul converts upper case chars to lower case and vice versa. Later I want a rot13 function that can operate on different types of lists and an uxl function that can also operate on different types of lists. 2. Lets say I have two kinds of lists to handle: String and Data.ByteString.Lazy as L. For Strings I want the updater function to be used for each character and for L I want all items to be converted to Char, the updater function to be updated and the result to be converted back to the original item type. Therefore I define a common class for handling these lists: class ListUpdater a where updateFn :: Char -> Char update :: a -> a so I can define the update function for the different types of lists: instance ListUpdater String where update = map updateFn instance ListUpdater L.ByteString where update = L.pack . (map updateFn) . L.unpack But now how should I glue these 2 dimensions together? How to say that I want a rot13 function that applies to any data type instantiated from ListUpdater and that is using the r13 function to do the update? And also that I want an uxl function that also applies to any data type instantiated from ListUpdater and that is using the ul function to do the update? Thanks, Istvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090716/9152fc1b/attachment.html From ryani.spam at gmail.com Thu Jul 16 17:31:13 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Jul 16 17:13:00 2009 Subject: [Haskell-cafe] Applying different functions to different types for lists In-Reply-To: References: Message-ID: <2f9b2d30907161431n6284417cked56a1403a7ab8c8@mail.gmail.com> 2009/7/16 Szekeres Istv?n : > class ListUpdater a where > ??? updateFn :: Char -> Char > ??? update :: a -> a > > so I can define the update function for the different types of lists: > > instance ListUpdater String where > ??? update = map updateFn > > instance ListUpdater L.ByteString where > ??? update = L.pack . (map updateFn) . L.unpack So, as written, these functions both give an error, because updateFn isn't defined. Perhaps you want something like this: > class CharMap a where > charMap :: (Char -> Char) -> (a -> a) > instance CharMap Char where > charMap f = f > instance CharMap a => CharMap [a] where > charMap f = map (charMap f) > instance CharMap L.ByteString where > charMap f = L.pack . map f . L.unpack Now you can write > genericRot13, genericUL :: CharMap a => a -> a > genericRot13 = charMap rot13 > genericUL = charMap ul -- ryan From jvranish at gmail.com Thu Jul 16 17:56:39 2009 From: jvranish at gmail.com (Job Vranish) Date: Thu Jul 16 17:38:26 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? Message-ID: I was needing a way to zip generic data structures together today and was very annoyed to find that there is no Zippable class, or variant there of. So I made my own: class (Foldable f, Functor f) => Zippable f where fmaps :: (Foldable g) => g (a -> b) -> f a -> f b fmaps' :: [a -> b] -> f a -> f b -- to save a step on instance implementation zipWith :: (a -> b -> c) -> f a -> f b -> f c zip :: f a -> f b -> f (a, b) unzip :: f (a, b) -> (f a, f b) fmaps fs a = fmaps' (toList fs) a fmaps' fs a = fmaps fs a zipWith f a b = fmaps (fmap f a) b zip = zipWith (,) unzip a = (fmap fst a, fmap snd a) instance Zippable [] where fmaps' (fx:fs) (x:xs) = fx x : fmaps' fs xs fmaps' _ _ = [] --The fmaps function is also quite handy as a replacment for zipWith3, zipWith4, etc... --For example: x = [1, 3, 5, 7, 3] y = [6, 9, 3, 1, 4] z = [2, 4, 0, 8, 2] test = fmap (,,) x `fmaps` y `fmaps` z -- > [(1,6,2),(3,9,4),(5,3,0),(7,1,8),(3,4,2)] --you can also throw in a functor instance to remove the dependency on the Functor class, but it -- might not be worth it: instance (Zippable f) => Functor f where fmap f a = fmaps (repeat f) a Is there any good reason that there isn't something like this in the standard libraries? Or, as far as I can tell, on hackage? If not, then maybe I'll stick it on hackage. - Job Vranish -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090716/8459e25b/attachment.html From jake.mcarthur at gmail.com Thu Jul 16 17:59:09 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Thu Jul 16 17:41:06 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: References: Message-ID: <4A5FA2AD.1040701@gmail.com> I think there are some basic equivalents in the TypeCompose and category-extras packages, for the record, but a standalone version wouldn't hurt either! - Jake From jefferson.r.heard at gmail.com Thu Jul 16 18:02:58 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Jul 16 17:45:04 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: References: Message-ID: <4165d3a70907161502i32b29140ydc34c9fb1b51d2af@mail.gmail.com> Beautiful. Can we have a version on hackage? On Thu, Jul 16, 2009 at 5:56 PM, Job Vranish wrote: > I was needing a way to zip generic data structures together today and was > very annoyed to find that there is no Zippable class, or variant there of. > > So I made my own: > > class (Foldable f, Functor f) => Zippable f where > ? fmaps :: (Foldable g) => g (a -> b) -> f a -> f b > ? fmaps' :: [a -> b] -> f a -> f b -- to save a step on instance > implementation > ? zipWith :: (a -> b -> c) -> f a -> f b -> f c > ? zip ::? f a -> f b -> f (a, b) > ? unzip :: f (a, b) -> (f a, f b) > > ? fmaps fs a = fmaps' (toList fs) a > ? fmaps' fs a = fmaps fs a > ? zipWith f a b = fmaps (fmap f a) b > ? zip = zipWith (,) > ? unzip a = (fmap fst a, fmap snd a) > > instance Zippable [] where > ? fmaps' (fx:fs) (x:xs) = fx x : fmaps' fs xs > ? fmaps' _?????? _????? = [] > > --The fmaps function is also quite handy as a replacment for zipWith3, > zipWith4, etc... > --For example: > > x = [1, 3, 5, 7, 3] > y = [6, 9, 3, 1, 4] > z = [2, 4, 0, 8, 2] > test = fmap (,,) x `fmaps` y `fmaps` z > -- > [(1,6,2),(3,9,4),(5,3,0),(7,1,8),(3,4,2)] > > --you can also throw in a functor instance to remove the dependency on the > Functor class, but it > --? might not be worth it: > instance (Zippable f) => Functor f where > ? fmap f a = fmaps (repeat f) a > > > Is there any good reason that there isn't something like this in the > standard libraries? Or, as far as I can tell, on hackage? > If not, then maybe I'll stick it on hackage. > > - Job Vranish > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From derek.a.elkins at gmail.com Thu Jul 16 18:38:14 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Jul 16 18:20:00 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A5F8508.3040403@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> <4A5F8508.3040403@btinternet.com> Message-ID: <61f84eff0907161538u2ae15974g6c303d8206da7c71@mail.gmail.com> On Thu, Jul 16, 2009 at 2:52 PM, Andrew Coppin wrote: > Ross Mellgren wrote: >> >> It's not where -- let also works >> >> Prelude> let { foo x = x } in (foo 1, foo True) >> (1,True) > > Awesome. So by attempting to implement Haskell's type system, I have > discovered that I actually don't understand Haskell's type system. Who'd > have thought it? > > Clearly I must go consult the Report and check precisely what the rules > are... The answer to your questions are on the back of this T-shirt. http://www.cafepress.com/skicalc.6225368 From ok at cs.otago.ac.nz Thu Jul 16 18:39:55 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Jul 16 18:21:47 2009 Subject: [Haskell-cafe] Leaner Haskell.org frontpage In-Reply-To: <5122A850-0E0F-4E05-A38B-3B83333E485D@gmail.com> References: <32837903.1400421247154781662.JavaMail.servlet@kundenserver> <5122A850-0E0F-4E05-A38B-3B83333E485D@gmail.com> Message-ID: <589277A2-433C-4CDB-8D35-3175A7558DCE@cs.otago.ac.nz> I asked "why make life for regular Haskellers", and On Jul 17, 2009, at 4:56 AM, Thomas Davie replied: > Because regular haskellers are perfectly capable of bookmarking http://haskell.org/usefullstuff.html > , while newbies will only get what google tells them -- the front > page. Sorry, but (1) I have a couple of hundred bookmarks; I may be a regular Haskeller, but it's better human interfacing for me to type www.haskell.org than to look things up in bookmarks. (2) Who says Google will only tell them the front page? PageRank means that Google will offer them first the page that is (to a first approximation) most linked to, and eventually that will be www.haskell.org/usefullstuff. (3) Right now, if you actually try it, Googling for "Haskell" gives you Haskell Introduction - HaskellWiki as the *second* link it offers. Are you really saying that there are lots of newbies who are smart enough to appreciate Haskell when they see it, but so excruciatingly dumb that they won't try "Haskell Introduction"? What might be a good thing would be if someone touched the introduction page from time to time. At the moment, it's about a year older than the main page, which makes it less inviting. From rmm-haskell at z.odi.ac Thu Jul 16 18:40:49 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Thu Jul 16 18:22:37 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <61f84eff0907161538u2ae15974g6c303d8206da7c71@mail.gmail.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> <4A5F8508.3040403@btinternet.com> <61f84eff0907161538u2ae15974g6c303d8206da7c71@mail.gmail.com> Message-ID: Is "everything" an acceptable answer? -Ross On Jul 16, 2009, at 6:38 PM, Derek Elkins wrote: > On Thu, Jul 16, 2009 at 2:52 PM, Andrew > Coppin wrote: >> Ross Mellgren wrote: >>> >>> It's not where -- let also works >>> >>> Prelude> let { foo x = x } in (foo 1, foo True) >>> (1,True) >> >> Awesome. So by attempting to implement Haskell's type system, I have >> discovered that I actually don't understand Haskell's type system. >> Who'd >> have thought it? >> >> Clearly I must go consult the Report and check precisely what the >> rules >> are... > > The answer to your questions are on the back of this T-shirt. > http://www.cafepress.com/skicalc.6225368 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From westondan at imageworks.com Thu Jul 16 19:10:48 2009 From: westondan at imageworks.com (Dan Weston) Date: Thu Jul 16 18:52:40 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: References: Message-ID: <4A5FB378.1060404@imageworks.com> After rereading page 2 of McBride and Paterson's Functional Pearl, "Applicative programming with effects", I think you are just reinventing Control.Applicative. The problem is that the default Applicative instance for [] is wrong, being a direct product rather than a direct sum. If [] were not already an instance of Applicative, you could easily define it as: import Control.Applicative data MyList a = Nil | (:::) a (MyList a) deriving (Read,Show,Eq,Ord) infixr 5 ::: -- same as [] instance Functor MyList where fmap f Nil = Nil fmap f (x ::: xs) = f x ::: fmap f xs -- different from [], sum rather than product instance Applicative MyList where pure x = x ::: Nil (<*>) (f ::: fs) (x ::: xs) = f x ::: (fs <*> xs) (<*>) _ _ = Nil x = (1::Int) ::: 3 ::: 5 ::: 7 ::: 3 ::: Nil y = (6::Int) ::: 9 ::: 3 ::: 1 ::: 4 ::: Nil z = (2::Int) ::: 4 ::: 0 ::: 8 ::: 2 ::: Nil test = (,,) <$> x <*> y <*> z > test (:::) (1,6,2) ((:::) (3,9,4) ((:::) (5,3,0) ((:::) (7,1,8) ((:::) (3,4,2) Nil)))) Alternately, you could write a newtype for [] and give it the zippy instance for Applicative. Job Vranish wrote: > I was needing a way to zip generic data structures together today and > was very annoyed to find that there is no Zippable class, or variant > there of. > > So I made my own: > > class (Foldable f, Functor f) => Zippable f where > fmaps :: (Foldable g) => g (a -> b) -> f a -> f b > fmaps' :: [a -> b] -> f a -> f b -- to save a step on instance > implementation > zipWith :: (a -> b -> c) -> f a -> f b -> f c > zip :: f a -> f b -> f (a, b) > unzip :: f (a, b) -> (f a, f b) > > fmaps fs a = fmaps' (toList fs) a > fmaps' fs a = fmaps fs a > zipWith f a b = fmaps (fmap f a) b > zip = zipWith (,) > unzip a = (fmap fst a, fmap snd a) > > instance Zippable [] where > fmaps' (fx:fs) (x:xs) = fx x : fmaps' fs xs > fmaps' _ _ = [] > > --The fmaps function is also quite handy as a replacment for zipWith3, > zipWith4, etc... > --For example: > > x = [1, 3, 5, 7, 3] > y = [6, 9, 3, 1, 4] > z = [2, 4, 0, 8, 2] > test = fmap (,,) x `fmaps` y `fmaps` z > -- > [(1,6,2),(3,9,4),(5,3,0),(7,1,8),(3,4,2)] > > --you can also throw in a functor instance to remove the dependency on > the Functor class, but it > -- might not be worth it: > instance (Zippable f) => Functor f where > fmap f a = fmaps (repeat f) a > > > Is there any good reason that there isn't something like this in the > standard libraries? Or, as far as I can tell, on hackage? > If not, then maybe I'll stick it on hackage. > > - Job Vranish > > From john at repetae.net Thu Jul 16 20:05:32 2009 From: john at repetae.net (John Meacham) Date: Thu Jul 16 19:47:19 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A5F8508.3040403@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> <4A5F8508.3040403@btinternet.com> Message-ID: <20090717000531.GB21698@sliver.repetae.net> On Thu, Jul 16, 2009 at 08:52:40PM +0100, Andrew Coppin wrote: > Ross Mellgren wrote: >> It's not where -- let also works >> >> Prelude> let { foo x = x } in (foo 1, foo True) >> (1,True) > > Awesome. So by attempting to implement Haskell's type system, I have > discovered that I actually don't understand Haskell's type system. Who'd > have thought it? > > Clearly I must go consult the Report and check precisely what the rules > are... actually, the rules are pretty straightforward. It doesn't matter where something is bound, just _how_ it is bound. Let-bound names (which includes 'where' and top-level definitions) can be polymorphic. lambda-bound or case-bound names (names bound as an argument to a function or that appear in a pattern) can only be monomorphic. And that's all there is to it. (the monomorphism restriction complicates it a little, but we don't need to worry about that for now) As an extension, ghc and jhc allow arguments and case bound variables to be polymorphic but only when explicitly declared so by a user supplied type annotation. (the exact rules for what 'explicitly declared' means can be a little complicated when formalized, but they match up enough with intuition that it isn't a problem in practice). They will never infer such a type on their own. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From tphyahoo at gmail.com Thu Jul 16 20:10:39 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Jul 16 19:52:24 2009 Subject: [Haskell-cafe] another laziness blowup (this one unsolved) Message-ID: <910ddf450907161710q2b188b5br583eedce5c1a8ac0@mail.gmail.com> Is it possible to fix alternate' (the second version), or otherwise define a fast stepwise alternate that doesn't blow up on long lists? alternate just breaks up [1,2,3,4,5] into ([1,3,5],[2,4]) Thanks! {-# LANGUAGE BangPatterns #-} import Data.List import Control.Arrow import Control.Parallel.Strategies t = (last *** last) $! alternate $ [1..(10^6)] t' = (last *** last) $! alternate' $ [1..(10^6)] t'' = (last *** last) $! alternate'' $ [1..(10^6)] -- finishes reasonably fast, but does a separate computation for the list and its tail rather than just rip through it alternate x = (skip1 x,(skip1 $ tail x)) skip1 = skip 1 skip n xs = let (a,b) = splitAt (n+1) xs in case a of [] -> [] x:_ -> x : skip n b -- this one overflows on million element list, even after fiddling with strictness on input args. can this be fixed? alternate' xs = let f3 :: Int -> (([Int],[Int]),Int) -> (([Int],[Int]),Int) f3 x ((a,b),n) = -- rnf (x,((a,b),n)) `seq` let nxtn = n+1 in if n `mod` 2 == 0 then ((x:a,b),nxtn) else ((a,x:b),nxtn) in fst . foldr f3 (([],[]),0) $ xs -- no overflow, goes through the list stepwise, but it's actually slightly slower than the first alternate because of the reverses alternate'' xs = let f3 ((a,b),n) x = (let nxtn = n+1 in if n `mod` 2 == 0 then ((x:a,b),nxtn) else ((a,x:b),nxtn) ) in (reverse *** reverse) . fst . foldl' f3 (([],[]),0) $ xs From thomas.dubuisson at gmail.com Thu Jul 16 20:14:49 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Jul 16 19:56:35 2009 Subject: [Haskell-cafe] Atom resources Message-ID: <4c44d90b0907161714k3e80a988ua791d1ef68ac3f1e@mail.gmail.com> The wiki [1] where Atom [2] once lived has been gone for some time now. The only resources I know for Atom are a couple blog posts, the haddock docs, and the Atom source on patchtag. Is anyone aware of other resources? Tom [1] http://funhdl.org/wiki/doku.php [2] http://hackage.haskell.org/package/atom From tphyahoo at gmail.com Thu Jul 16 20:25:35 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Jul 16 20:07:21 2009 Subject: [Haskell-cafe] Re: another laziness blowup (this one unsolved) In-Reply-To: <910ddf450907161710q2b188b5br583eedce5c1a8ac0@mail.gmail.com> References: <910ddf450907161710q2b188b5br583eedce5c1a8ac0@mail.gmail.com> Message-ID: <910ddf450907161725v50f675cg2266d3f1c51399e3@mail.gmail.com> solved. see the haskell wiki for spoiler: http://haskell.org/haskellwiki/Blow_your_mind 2009/7/16 Thomas Hartman : > Is it possible to fix alternate' (the second version), or otherwise > define a fast stepwise alternate that doesn't blow up on long lists? > > alternate just breaks up [1,2,3,4,5] into ([1,3,5],[2,4]) > > Thanks! > > {-# LANGUAGE BangPatterns #-} > import Data.List > import Control.Arrow > import Control.Parallel.Strategies > > t = (last *** last) $! alternate $ [1..(10^6)] > t' = (last *** last) $! alternate' $ [1..(10^6)] > t'' = (last *** last) $! alternate'' $ [1..(10^6)] > > > -- finishes reasonably fast, but does a separate computation for the > list and its tail rather than just rip through it > alternate x = (skip1 x,(skip1 $ tail x)) > skip1 = skip 1 > skip n xs = > ?let (a,b) = splitAt (n+1) xs > ?in case a of > ? ? [] -> [] > ? ? x:_ -> x : skip n b > > > > -- this one overflows on million element list, even after fiddling > with strictness on input args. can this be fixed? > alternate' xs = > ?let f3 :: Int -> (([Int],[Int]),Int) -> (([Int],[Int]),Int) > ? ? ?f3 x ((a,b),n) = -- rnf (x,((a,b),n)) `seq` > ? ? ? ?let nxtn = n+1 > ? ? ? ?in if n `mod` 2 == 0 > ? ? ? ? ? ?then ((x:a,b),nxtn) > ? ? ? ? ? ?else ((a,x:b),nxtn) > ?in fst . foldr f3 (([],[]),0) $ xs > > -- no overflow, goes through the list stepwise, but it's actually > slightly slower than the first alternate because of the reverses > alternate'' xs = > ?let f3 ((a,b),n) x = > ? ? ? ?(let nxtn = n+1 > ? ? ? ?in if n `mod` 2 == 0 > ? ? ? ? ? ?then ((x:a,b),nxtn) > ? ? ? ? ? ?else ((a,x:b),nxtn) ) > ?in (reverse *** reverse) . fst . foldl' f3 (([],[]),0) $ xs > From ryani.spam at gmail.com Thu Jul 16 20:40:05 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Jul 16 20:21:51 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: <4A5FB378.1060404@imageworks.com> References: <4A5FB378.1060404@imageworks.com> Message-ID: <2f9b2d30907161740r7bdf1720tb6f71e8ed826edcc@mail.gmail.com> (I'm going to play fast and loose with constructors for this post, treating MyList and ZipList as if they were []) On Thu, Jul 16, 2009 at 4:10 PM, Dan Weston wrote: > -- different from [], sum rather than product > instance Applicative MyList where > ?pure x = x ::: Nil > ?(<*>) (f ::: fs) (x ::: xs) = f x ::: (fs <*> xs) > ?(<*>) _ _ = Nil Unfortunately, this instance doesn't fulfill this Applicative law: pure id <*> f = f pure id <*> [1,2,3] = [id] <*> [1,2,3] = [id 1] = [1] Fortunately, the solution already exists in Control.Applicative: > -- | Lists, but with an 'Applicative' functor based on zipping, so that > -- > -- @f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsn = 'ZipList' (zipWithn f xs1 ... xsn)@ > -- > newtype ZipList a = ZipList { getZipList :: [a] } > > instance Functor ZipList where > fmap f (ZipList xs) = ZipList (map f xs) > > instance Applicative ZipList where > pure x = ZipList (repeat x) > ZipList fs <*> ZipList xs = ZipList (zipWith id fs xs) In this case: pure id <*> [1,2,3] = [id, id, ...] <*> [1,2,3] = [id 1, id 2, id 3] = [1,2,3] -- ryan From westondan at imageworks.com Thu Jul 16 21:01:33 2009 From: westondan at imageworks.com (Dan Weston) Date: Thu Jul 16 20:43:22 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: <2f9b2d30907161740r7bdf1720tb6f71e8ed826edcc@mail.gmail.com> References: <4A5FB378.1060404@imageworks.com> <2f9b2d30907161740r7bdf1720tb6f71e8ed826edcc@mail.gmail.com> Message-ID: <4A5FCD6D.9000708@imageworks.com> Way cool. I have gained newfound respect for what I don't know. :) Can there ever be more than one (observably different) valid definition of pure for a given <*> that obeys all the laws? I would imagine that there could be at most one. Dan Ryan Ingram wrote: > (I'm going to play fast and loose with constructors for this post, > treating MyList and ZipList as if they were []) > > On Thu, Jul 16, 2009 at 4:10 PM, Dan Weston wrote: >> -- different from [], sum rather than product >> instance Applicative MyList where >> pure x = x ::: Nil >> (<*>) (f ::: fs) (x ::: xs) = f x ::: (fs <*> xs) >> (<*>) _ _ = Nil > > Unfortunately, this instance doesn't fulfill this Applicative law: > pure id <*> f = f > > pure id <*> [1,2,3] > = [id] <*> [1,2,3] > = [id 1] > = [1] > > Fortunately, the solution already exists in Control.Applicative: > >> -- | Lists, but with an 'Applicative' functor based on zipping, so that >> -- >> -- @f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsn = 'ZipList' (zipWithn f xs1 ... xsn)@ >> -- >> newtype ZipList a = ZipList { getZipList :: [a] } >> >> instance Functor ZipList where >> fmap f (ZipList xs) = ZipList (map f xs) >> >> instance Applicative ZipList where >> pure x = ZipList (repeat x) >> ZipList fs <*> ZipList xs = ZipList (zipWith id fs xs) > > In this case: > > pure id <*> [1,2,3] > = [id, id, ...] <*> [1,2,3] > = [id 1, id 2, id 3] > = [1,2,3] > > -- ryan > > From s.clover at gmail.com Thu Jul 16 21:58:40 2009 From: s.clover at gmail.com (Sterling Clover) Date: Thu Jul 16 21:38:04 2009 Subject: [Haskell-cafe] Parsec for C or C++ In-Reply-To: <162be4f00907161040t1131d740j4fd826e777567a1d@mail.gmail.com> References: <162be4f00907160925s32248697sa5f890043e281724@mail.gmail.com> <9810b81b0907160929g101815a6t36b99a96f39b14eb@mail.gmail.com> <162be4f00907160943y3f53d8c1m6667f01dfd5ac412@mail.gmail.com> <162be4f00907161040t1131d740j4fd826e777567a1d@mail.gmail.com> Message-ID: A parser for JavaScript (admittedly a much simpler beast) is part of Brown's WebBits: http://hackage.haskell.org/packages/archive/WebBits/0.15/doc/html/ BrownPLT-JavaScript-Parser.html Cheers, Sterl. On Jul 16, 2009, at 1:40 PM, Roy Lowrance wrote: > Turns out that Language.C uses alex and happy. > > I'm looking to use Parsec. > > So back to the original question: Does anyone know of a C or java > parser written using Parsec? > > - Roy > > On Thu, Jul 16, 2009 at 12:43 PM, Roy > Lowrance wrote: >> Thanks Rick. A perfect tip! - Roy >> >> On Thu, Jul 16, 2009 at 12:29 PM, Rick >> R wrote: >>> There is language.c >>> >>> http://www.sivity.net/projects/language.c/ >>> http://hackage.haskell.org/package/language-c >>> >>> >>> From a parsing standpoint, C++ is a massive departure from C. >>> Good luck >>> though. >>> >>> >>> On Thu, Jul 16, 2009 at 12:25 PM, Roy Lowrance >>> >>> wrote: >>>> >>>> I am working on a research language that is a variant of C. I'd >>>> like >>>> to use Parsec as the parser. >>>> >>>> Is there an existing Parsec parser for C or C++ (or Java) that >>>> could >>>> serve as a starting point? >>>> >>>> Thanks, Roy >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >>> >>> -- >>> "The greatest obstacle to discovering the shape of the earth, the >>> continents, and the oceans was not ignorance but the illusion of >>> knowledge." >>> - Daniel J. Boorstin >>> >>> >> >> >> >> -- >> Roy Lowrance >> home: 212 674 9777 >> mobile: 347 255 2544 >> > > > > -- > Roy Lowrance > home: 212 674 9777 > mobile: 347 255 2544 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vanenkj at gmail.com Thu Jul 16 22:38:44 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Jul 16 22:20:33 2009 Subject: [Haskell-cafe] Atom resources In-Reply-To: <4c44d90b0907161714k3e80a988ua791d1ef68ac3f1e@mail.gmail.com> References: <4c44d90b0907161714k3e80a988ua791d1ef68ac3f1e@mail.gmail.com> Message-ID: Are you starting a new Wiki? I'd absolutely love to have that resource. On Thu, Jul 16, 2009 at 8:14 PM, Thomas DuBuisson wrote: > The wiki [1] where Atom [2] once lived has been gone for some time > now. ?The only resources I know for Atom are a couple blog posts, the > haddock docs, and the Atom source on patchtag. ?Is anyone aware of > other resources? > > Tom > > [1] http://funhdl.org/wiki/doku.php > [2] http://hackage.haskell.org/package/atom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From thomas.dubuisson at gmail.com Thu Jul 16 22:54:38 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Jul 16 22:36:24 2009 Subject: [Haskell-cafe] Atom resources In-Reply-To: References: <4c44d90b0907161714k3e80a988ua791d1ef68ac3f1e@mail.gmail.com> Message-ID: <4c44d90b0907161954j69f0f80ey1cbeb99e760a9d60@mail.gmail.com> No, I'm not starting a new wiki (though it someone does or has then it should go on haskell.org, imo). Tom On Thu, Jul 16, 2009 at 7:38 PM, John Van Enk wrote: > Are you starting a new Wiki? I'd absolutely love to have that resource. > > On Thu, Jul 16, 2009 at 8:14 PM, Thomas > DuBuisson wrote: >> The wiki [1] where Atom [2] once lived has been gone for some time >> now. ?The only resources I know for Atom are a couple blog posts, the >> haddock docs, and the Atom source on patchtag. ?Is anyone aware of >> other resources? >> >> Tom >> >> [1] http://funhdl.org/wiki/doku.php >> [2] http://hackage.haskell.org/package/atom >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From radamajna at gmail.com Thu Jul 16 23:57:12 2009 From: radamajna at gmail.com (=?ISO-8859-1?Q?Radam=E9s_Ajna?=) Date: Thu Jul 16 23:39:17 2009 Subject: [Haskell-cafe] Atom resources In-Reply-To: <4c44d90b0907161954j69f0f80ey1cbeb99e760a9d60@mail.gmail.com> References: <4c44d90b0907161714k3e80a988ua791d1ef68ac3f1e@mail.gmail.com> <4c44d90b0907161954j69f0f80ey1cbeb99e760a9d60@mail.gmail.com> Message-ID: <17afcbce0907162057v5970e913ucc039d58b38d3e24@mail.gmail.com> That would be great. I can post some of my works on arduino , haskell and atom there. Radam?s On Thu, Jul 16, 2009 at 23:54, Thomas DuBuisson wrote: > No, I'm not starting a new wiki (though it someone does or has then it > should go on haskell.org, imo). > > Tom > > On Thu, Jul 16, 2009 at 7:38 PM, John Van Enk wrote: >> Are you starting a new Wiki? I'd absolutely love to have that resource. >> >> On Thu, Jul 16, 2009 at 8:14 PM, Thomas >> DuBuisson wrote: >>> The wiki [1] where Atom [2] once lived has been gone for some time >>> now. ?The only resources I know for Atom are a couple blog posts, the >>> haddock docs, and the Atom source on patchtag. ?Is anyone aware of >>> other resources? >>> >>> Tom >>> >>> [1] http://funhdl.org/wiki/doku.php >>> [2] http://hackage.haskell.org/package/atom >>> _______________________________________________ >>> 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 jvranish at gmail.com Thu Jul 16 23:58:42 2009 From: jvranish at gmail.com (Job Vranish) Date: Thu Jul 16 23:40:29 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: <2f9b2d30907161740r7bdf1720tb6f71e8ed826edcc@mail.gmail.com> References: <4A5FB378.1060404@imageworks.com> <2f9b2d30907161740r7bdf1720tb6f71e8ed826edcc@mail.gmail.com> Message-ID: Yeah I tried applicative, but saw that the <*> operator didn't do what I want with lists, and started looking elsewhere. I didn't even see the ZipList! Actually the other problem is that the data structure that I'm using won't support pure, so no Applicative :( Though for a generic zip, Applicative may be the better general purpose way to go. I didn't see TypeCompose and category-extras either those look pretty sweet :) Those would have worked. But I think I in my case, my version is a bit more general. Thanks for the input! It has been very enlightening. :) Hmmm I also should have pulled the zips out of the typeclass: class (Foldable f) => Zippable f where fmaps :: (Foldable g) => g (a -> b) -> f a -> f b fmaps' :: [a -> b] -> f a -> f b -- to save a step on instance implementation fmaps fs a = fmaps' (toList fs) a fmaps' fs a = fmaps fs a zipWith :: (Zippable f) => (a -> b -> c) -> f a -> f b -> f c zipWith f a b = fmaps (fmap f a) b zip :: (Zippable f) => f a -> f b -> f (a, b) zip a b = zipWith (,) a b unzip :: (Functor f) => f (a, b) -> (f a, f b) unzip a = (fmap fst a, fmap snd a) instance Zippable [] where fmaps' (fx:fs) (x:xs) = fx x : fmaps' fs xs fmaps' _ _ = [] On Thu, Jul 16, 2009 at 8:40 PM, Ryan Ingram wrote: > (I'm going to play fast and loose with constructors for this post, > treating MyList and ZipList as if they were []) > > On Thu, Jul 16, 2009 at 4:10 PM, Dan Weston > wrote: > > -- different from [], sum rather than product > > instance Applicative MyList where > > pure x = x ::: Nil > > (<*>) (f ::: fs) (x ::: xs) = f x ::: (fs <*> xs) > > (<*>) _ _ = Nil > > Unfortunately, this instance doesn't fulfill this Applicative law: > pure id <*> f = f > > pure id <*> [1,2,3] > = [id] <*> [1,2,3] > = [id 1] > = [1] > > Fortunately, the solution already exists in Control.Applicative: > > > -- | Lists, but with an 'Applicative' functor based on zipping, so that > > -- > > -- @f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsn = 'ZipList' > (zipWithn f xs1 ... xsn)@ > > -- > > newtype ZipList a = ZipList { getZipList :: [a] } > > > > instance Functor ZipList where > > fmap f (ZipList xs) = ZipList (map f xs) > > > > instance Applicative ZipList where > > pure x = ZipList (repeat x) > > ZipList fs <*> ZipList xs = ZipList (zipWith id fs xs) > > In this case: > > pure id <*> [1,2,3] > = [id, id, ...] <*> [1,2,3] > = [id 1, id 2, id 3] > = [1,2,3] > > -- ryan > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090716/75eac8ea/attachment.html From voigt at tcs.inf.tu-dresden.de Fri Jul 17 00:34:33 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Fri Jul 17 00:16:20 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: References: <4A5FB378.1060404@imageworks.com> <2f9b2d30907161740r7bdf1720tb6f71e8ed826edcc@mail.gmail.com> Message-ID: <4A5FFF59.6080503@tcs.inf.tu-dresden.de> Why is there no Zippable class? There is. You can use Data.Zippable from http://hackage.haskell.org/package/bff. It gives you a function tryZip :: Zippable k => k a -> k b -> Either String (k (a,b)) The Either in the return type is to capture an error message in case the two structures are not of the same shape. For example, for data Tree a = Leaf a | Node (Tree a) (Tree a) you would have: instance Zippable Tree where tryZip (Leaf a) (Leaf b) = Right (Leaf (a,b)) tryZip (Node a1 a2) (Node b1 b2) = do z1 <- tryZip a1 b1 z2 <- tryZip a2 b2 return (Node z1 z2) tryZip _ _ = Left "Structure mismatch." Of course, you can get an "unsafe" zip by composing tryZip with a fromRight. What's more, the mentioned package contains an automatic Template Haskell deriver for Zippable instances, so you don't have to write the above instance definition yourself. The implementation is by Joachim Breitner. Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From johanj at cs.uu.nl Fri Jul 17 01:35:15 2009 From: johanj at cs.uu.nl (Johan Jeuring) Date: Fri Jul 17 01:17:01 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: <4A5FFF59.6080503@tcs.inf.tu-dresden.de> References: <4A5FB378.1060404@imageworks.com> <2f9b2d30907161740r7bdf1720tb6f71e8ed826edcc@mail.gmail.com> <4A5FFF59.6080503@tcs.inf.tu-dresden.de> Message-ID: <081DD9F6-7DC9-4520-A1B2-6614729220F7@cs.uu.nl> > Why is there no Zippable class? There is. > > You can use Data.Zippable from http://hackage.haskell.org/package/bff. > > It gives you a function > > tryZip :: Zippable k => k a -> k b -> Either String (k (a,b)) > > The Either in the return type is to capture an error message in case > the > two structures are not of the same shape. This functionality can also be obtained from the generic programming library EMGM, with the function zip :: FRep3 ZipWith f => f a -> f b -> Maybe (f (a, b)) You can use Template Haskell to generate the necessary FRep3 instances. Once you have those you get many other generic functions for free. See http://hackage.haskell.org/package/emgm -- Johan Jeuring > For example, for > > data Tree a = Leaf a | Node (Tree a) (Tree a) > > you would have: > > instance Zippable Tree where > tryZip (Leaf a) (Leaf b) = Right (Leaf (a,b)) > tryZip (Node a1 a2) (Node b1 b2) = do z1 <- tryZip a1 b1 > z2 <- tryZip a2 b2 > return (Node z1 z2) > tryZip _ _ = Left "Structure mismatch." > > Of course, you can get an "unsafe" zip by composing tryZip with a > fromRight. > > What's more, the mentioned package contains an automatic Template > Haskell deriver for Zippable instances, so you don't have to write the > above instance definition yourself. > > The implementation is by Joachim Breitner. > > Ciao, > Janis. > > -- > Dr. Janis Voigtlaender > http://wwwtcs.inf.tu-dresden.de/~voigt/ > mailto:voigt@tcs.inf.tu-dresden.de > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From florbitous at gmail.com Fri Jul 17 02:58:36 2009 From: florbitous at gmail.com (Bernie Pope) Date: Fri Jul 17 02:40:22 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4d8ad03a0907162355t69d934adqc0e328e1d961e9aa@mail.gmail.com> References: <4A5F72AA.9060402@btinternet.com> <4d8ad03a0907162355t69d934adqc0e328e1d961e9aa@mail.gmail.com> Message-ID: <4d8ad03a0907162358o5988c23dhc758056e0d58ad2@mail.gmail.com> 2009/7/17 Andrew Coppin : > I've been working hard this week, and I'm stumbled upon something which is > probably of absolutely no surprise to anybody but me. > > Consider the following expression: > > ?(foo True, foo 'x') > > Is this expression well-typed? > > Astonishingly, the answer depends on where "foo" is defined. If "foo" is a > local variable, then the above expression is guaranteed to be ill-typed. > However, if we have (for example) > > ?foo :: x -> x > > as a top-level function, then the above expression becomes well-typed. Some useful reading material: Section 22.7 of the book "Types and Programming Languages" by Benjamin Pierce. The classic paper "Basic Polymorphic Typechecking" by Luca Cardelli: ? ? ? http://lucacardelli.name/Papers/BasicTypechecking.pdf Both of these are very readable introductions to the let-style polymorphism found in the Hindley/Milner type system. Haskell's type system is essentially an elaboration of that idea. Pierce's book shows how to achieve let-polymorphism by inlining non-recursive let bindings during type checking/inference, which is a nice way to understand what is going on. From jon at ffconsultancy.com Fri Jul 17 04:47:27 2009 From: jon at ffconsultancy.com (Jon Harrop) Date: Fri Jul 17 03:19:50 2009 Subject: [Haskell-cafe] Parallellizing array-based function Message-ID: <200907170947.27538.jon@ffconsultancy.com> Is it possible to parallelize array-based functions such as in-place quicksort in Haskell? If so, does anyone have a working implementation? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From voigt at tcs.inf.tu-dresden.de Fri Jul 17 04:39:34 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Fri Jul 17 04:21:24 2009 Subject: [Haskell-cafe] PEPM'10 - Call for Papers (Deadline: 6 Oct 09) - Invited Speakers announced Message-ID: <4A6038C6.6080509@tcs.inf.tu-dresden.de> =============================================================== CALL FOR PAPERS ACM SIGPLAN 2010 Workshop on Partial Evaluation and Program Manipulation (PEPM'10) Madrid, January 18-19, 2010 (Affiliated with POPL'10) http://www.program-transformation.org/PEPM10 =============================================================== INVITED SPEAKERS: * Lennart Augustsson (Standard Chartered Bank, UK) * Jeremy Siek (University of Colorado at Boulder, USA) IMPORTANT DATES: * Paper submission: Tue, October 6, 2009, 23:59, Apia time * Author notification: Thu, October 29, 2009 * Camera-ready papers: Mon, November 9, 2009 To facilitate smooth organization of the review process, authors are asked to submit a short abstract by October 1, 2009. SUBMISSION CATEGORIES: * Regular research papers (max. 10 pages in ACM Proceedings style) * Tool demonstration papers (max. 4 pages plus max. 6 pages appendix) TRAVEL SUPPORT: Students and other attendants in need can apply for a SIGPLAN PAC grant to help cover expenses. For details, see http://www.sigplan.org/PAC.htm. SCOPE: The PEPM Symposium/Workshop series aims to bring together researchers and practitioners working in the areas of program manipulation, partial evaluation, and program generation. PEPM focuses on techniques, theories, tools, and applications of analysis and manipulation of programs. The 2010 PEPM workshop will be based on a broad interpretation of semantics-based program manipulation in a continued effort to expand the scope of PEPM significantly beyond the traditionally covered areas of partial evaluation and specialization and include practical applications of program transformations such as refactoring tools, and practical implementation techniques such as rule-based transformation systems. In addition, it covers manipulation and transformations of program and system representations such as structural and semantic models that occur in the context of model-driven development. In order to reach out to practitioners, there is a separate category of tool demonstration papers. Topics of interest for PEPM'10 include, but are not limited to: * Program and model manipulation techniques such as transformations driven by rules, patterns, or analyses, partial evaluation, specialization, program inversion, program composition, slicing, symbolic execution, refactoring, aspect weaving, decompilation, and obfuscation. * Program analysis techniques that are used to drive program/model manipulation such as abstract interpretation, static analysis, binding-time analysis, dynamic analysis, constraint solving, type systems, automated testing and test case generation. * Analysis and transformation for programs/models with advanced features such as objects, generics, ownership types, aspects, reflection, XML type systems, component frameworks, and middleware. * Techniques that treat programs/models as data objects including meta-programming, generative programming, deep embedded domain-specific languages, program synthesis by sketching and inductive programming, staged computation, and model-driven program generation and transformation. * Application of the above techniques including experimental studies, engineering needed for scalability, and benchmarking. Examples of application domains include legacy program understanding and transformation, DSL implementations, visual languages and end-user programming, scientific computing, middleware frameworks and infrastructure needed for distributed and web-based applications, resource-limited computation, and security. We especially encourage papers that break new ground including descriptions of how program/model manipulation tools can be integrated into realistic software development processes, descriptions of robust tools capable of effectively handling realistic applications, and new areas of application such as rapidly evolving systems, distributed and web-based programming including middleware manipulation, model-driven development, and on-the-fly program adaptation driven by run-time or statistical analysis. PROCEEDINGS: There will be formal proceedings published by ACM Press. In addition to printed proceedings, accepted papers will be included in the ACM Digital Library. Selected papers may later on be invited for a journal special issue dedicated to PEPM'10. SUBMISSION GUIDELINES: Papers should be submitted electronically via the workshop web site. Regular research papers must not exceed 10 pages in ACM Proceedings style. Tool demonstration papers must not exceed 4 pages in ACM Proceedings style, and authors will be expected to present a live demonstration of the described tool at the workshop (tool papers should include an additional appendix of up to 6 extra pages giving the outline, screenshots, examples, etc. to indicate the content of the proposed live demo at the workshop). Authors using Latex to prepare their submissions should use the new improved SIGPLAN proceedings style (sigplanconf.cls). PROGRAM CO-CHAIRS: * John Gallagher (Roskilde University, Denmark, and IMDEA Software, Spain) * Janis Voigtl?nder (Technische Universit?t Dresden, Germany) PROGRAM COMMITTEE MEMBERS: * Wei-Ngan Chin (National University of Singapore, Singapore) * Michael Codish (Ben-Gurion University of the Negev, Israel) * Jim Cordy (Queen's University, Canada) * Nate Foster (University of Pennsylvania, USA) * Haifeng Guo (University of Nebraska at Omaha, USA) * Patricia Johann (University of Strathclyde, UK) * Oleg Kiselyov (FNMOC, USA) * G?nter Kniesel (University of Bonn, Germany) * Viktor Kuncak (Ecole Polytechnique F?d?rale de Lausanne, Switzerland) * Yanhong Annie Liu (State University of New York at Stony Brook, USA) * Andres L?h (Utrecht University, Netherlands) * Jan Midtgaard (Roskilde University, Denmark) * David Monniaux (National Center for Scientific Research (CNRS) and VERIMAG laboratory, France) * Akimasa Morihata (University of Tokyo, Japan) * Alberto Pettorossi (Universit? di Roma Tor Vergata, Italy) * Jo?o Saraiva (Universidade do Minho, Portugal) * Ganesh Sittampalam (Credit Suisse, UK) * Fausto Spoto (Universit? di Verona, Italy) * Harald S?ndergaard (University of Melbourne, Australia) * Walid Taha (Rice University, USA) From alp at mestan.fr Fri Jul 17 05:14:19 2009 From: alp at mestan.fr (Alp Mestan) Date: Fri Jul 17 04:56:06 2009 Subject: [Haskell-cafe] Parsec for C or C++ In-Reply-To: References: <162be4f00907160925s32248697sa5f890043e281724@mail.gmail.com> <9810b81b0907160929g101815a6t36b99a96f39b14eb@mail.gmail.com> <162be4f00907160943y3f53d8c1m6667f01dfd5ac412@mail.gmail.com> <162be4f00907161040t1131d740j4fd826e777567a1d@mail.gmail.com> Message-ID: There is a C++ parser in C++, it may be of help : http://42ndart.org/scalpel/ It's a quite advanced WIP. On Fri, Jul 17, 2009 at 3:58 AM, Sterling Clover wrote: > A parser for JavaScript (admittedly a much simpler beast) is part of > Brown's WebBits: > > http://hackage.haskell.org/packages/archive/WebBits/0.15/doc/html/ > BrownPLT-JavaScript-Parser.html > > Cheers, > Sterl. > > > On Jul 16, 2009, at 1:40 PM, Roy Lowrance wrote: > > Turns out that Language.C uses alex and happy. >> >> I'm looking to use Parsec. >> >> So back to the original question: Does anyone know of a C or java >> parser written using Parsec? >> >> - Roy >> >> On Thu, Jul 16, 2009 at 12:43 PM, Roy Lowrance >> wrote: >> >>> Thanks Rick. A perfect tip! - Roy >>> >>> On Thu, Jul 16, 2009 at 12:29 PM, Rick R >>> wrote: >>> >>>> There is language.c >>>> >>>> http://www.sivity.net/projects/language.c/ >>>> http://hackage.haskell.org/package/language-c >>>> >>>> >>>> From a parsing standpoint, C++ is a massive departure from C. Good luck >>>> though. >>>> >>>> >>>> On Thu, Jul 16, 2009 at 12:25 PM, Roy Lowrance >>>> wrote: >>>> >>>>> >>>>> I am working on a research language that is a variant of C. I'd like >>>>> to use Parsec as the parser. >>>>> >>>>> Is there an existing Parsec parser for C or C++ (or Java) that could >>>>> serve as a starting point? >>>>> >>>>> Thanks, Roy >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>> >>>> >>>> >>>> -- >>>> "The greatest obstacle to discovering the shape of the earth, the >>>> continents, and the oceans was not ignorance but the illusion of >>>> knowledge." >>>> - Daniel J. Boorstin >>>> >>>> >>>> >>> >>> >>> -- >>> Roy Lowrance >>> home: 212 674 9777 >>> mobile: 347 255 2544 >>> >>> >> >> >> -- >> Roy Lowrance >> home: 212 674 9777 >> mobile: 347 255 2544 >> _______________________________________________ >> 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 > -- Alp Mestan http://blog.mestan.fr/ http://alp.developpez.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/2bffe3fd/attachment.html From tphyahoo at gmail.com Fri Jul 17 05:35:21 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Jul 17 05:17:06 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? Message-ID: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> on haskell reddit today powerSet = filterM (const [True, False]) is said to be beautiful / mind blowing. I just don't get it. I can play with transformations until I get powerSet [] = [[]] powerSet (x:xs) = let pxs = powerSet xs in map (x:) pxs ++ pxs which is understandable to me, but no matter how long I look at the original filterM definition it just doesn't click. Is this a uniquely haskell obfu, or is there a way of reading this definition that makes sense? If anybody agrees with me, care to throw out other examples of "obfuscated haskell considered harmful"? From lrpalmer at gmail.com Fri Jul 17 05:45:03 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Jul 17 05:26:48 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> Message-ID: <7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> On Fri, Jul 17, 2009 at 1:35 AM, Thomas Hartman wrote: > on haskell reddit today > > powerSet = filterM (const [True, False]) The M is the list, i.e. *nondeterminism* monad. For each element in the list, there is one return value where it appears (True), and one where it does not (False). Basically, regular filter says that for each element in the list, we need to make a choice as to whether it occurs in the result. Here we use nondeterminism to make both choices. Luke > > > is said to be beautiful / mind blowing. I just don't get it. I can > play with transformations until I get > > powerSet [] = [[]] > powerSet (x:xs) = > let pxs = powerSet xs > in map (x:) pxs ++ pxs > > which is understandable to me, but no matter how long I look at the > original filterM definition it just doesn't click. > > Is this a uniquely haskell obfu, or is there a way of reading this > definition that makes sense? > > If anybody agrees with me, care to throw out other examples of > "obfuscated haskell considered harmful"? > _______________________________________________ > 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/20090717/2de88a7a/attachment.html From porges at porg.es Fri Jul 17 06:23:59 2009 From: porges at porg.es (George Pollard) Date: Fri Jul 17 06:05:43 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: <7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> <7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> Message-ID: <6d942a4a0907170323t53f73904u2c96c7a029b5b80d@mail.gmail.com> For each item, we ignore what the item actually is (hence `const`), and say that we both want it (True) and don't want it (False) in the output. Since we are using the list monad we are allowed to say this, and the filter function gives us a list of lists. I think there's probably a more intuitive name for `filterM`... From gleb.alexeev at gmail.com Fri Jul 17 06:36:07 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Fri Jul 17 06:18:16 2009 Subject: [Haskell-cafe] Re: powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> Message-ID: Thomas Hartman wrote: > on haskell reddit today > > powerSet = filterM (const [True, False]) > Does it help if we inline the 'const' function and rewrite [True, False] in monadic notation as (return True `mplus` return False)? powerSet = filterM (\x -> return True `mplus` return False). You can see that 'x' is ignored, both True and False are returned, hence x is preserved in one answer and not preserved in another. From frodo at theshire.org Fri Jul 17 06:41:57 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Jul 17 06:24:12 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot In-Reply-To: <1247722060.8533.71.camel@localhost> References: <4ec472cb0907151935s586a7e2eqb3f82fba760e58cf@mail.gmail.com> <1247722060.8533.71.camel@localhost> Message-ID: Thank you all for your answers and sorry for the delay I'm writing this message but before replying, I wanted to be sure to understand your arguments! Now, I'm starting to get into this "tying the knot" thing and understand why the Haskell version of fib ties the knot while my Python version does not. It seems all related to the thunk thing, i.e. in the Haskell version the subsequent calls to fib are not actual calls because they all refers to the same thunk, which is evaluated "on demand". Now, to confirm my hypothesis, I wrote a slight different version of fib, like follows: fib' n = 1:1:(fib' n) `plus` (tail $ fib' n) where plus = zipWith (+) i.e. I inserted a fictious argument n in the definition of fib'. Now, if I try "take 30 $ fib' 100", it takes significntly longer than "take 30 fib": specifically, the latter is instantaneous, while the former takes about 5 seconds to complete on my MacBook Pro. Is this an evidence that the "tying the knot" process is going on in the first version? More, I've read that a fully lazy language would memoize all functions by default: in this case, even fib' would have been tying the knot. But this is not the case of Haskell. Am I wrong? Thank you, Cristiano From tom.davie at gmail.com Fri Jul 17 06:46:34 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Jul 17 06:28:21 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot In-Reply-To: References: <4ec472cb0907151935s586a7e2eqb3f82fba760e58cf@mail.gmail.com> <1247722060.8533.71.camel@localhost> Message-ID: On 17 Jul 2009, at 12:41, Cristiano Paris wrote: > Thank you all for your answers and sorry for the delay I'm writing > this message but before replying, I wanted to be sure to understand > your arguments! > > Now, I'm starting to get into this "tying the knot" thing and > understand why the Haskell version of fib ties the knot while my > Python version does not. It seems all related to the thunk thing, i.e. > in the Haskell version the subsequent calls to fib are not actual > calls because they all refers to the same thunk, which is evaluated > "on demand". > > Now, to confirm my hypothesis, I wrote a slight different version of > fib, like follows: > > fib' n = 1:1:(fib' n) `plus` (tail $ fib' n) where plus = zipWith (+) > > i.e. I inserted a fictious argument n in the definition of fib'. > > Now, if I try "take 30 $ fib' 100", it takes significntly longer than > "take 30 fib": specifically, the latter is instantaneous, while the > former takes about 5 seconds to complete on my MacBook Pro. Is this an > evidence that the "tying the knot" process is going on in the first > version? That's correct > More, I've read that a fully lazy language would memoize all functions > by default: in this case, even fib' would have been tying the knot. > But this is not the case of Haskell. Am I wrong? Memoization is not a feature of lazyness. If you can do it in such a way that you don't waste significant amount of RAM, then it may be a nice optimisation, and an alternative evaluation strategy, but it would not be lazy. Bob From gleb.alexeev at gmail.com Fri Jul 17 07:00:40 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Fri Jul 17 06:42:39 2009 Subject: [Haskell-cafe] Re: powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> Message-ID: <4A6059D8.604@gmail.com> On Jul 17, 2009 1:40pm, Thomas Hartman wrote: > my question to all 3 (so far) respondants is, how does your > > explanation explain that the result is the power set? > > I guess you forgot to reply to the cafe. Well, to me the modified definition I posted looks like the essence of powerset, the set of all subsets. Every element x of the input list divides the powerset in 2 halves, the first one contains x, the second one doesn't. Filtering on the non-deterministic predicate (\x -> return True `mplus` return False) in the List monad does exactly that. From v.dijk.bas at gmail.com Fri Jul 17 07:16:51 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Fri Jul 17 06:58:37 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: <2f9b2d30907161257i3eb9a4e2ja2199d0d1d02a6e6@mail.gmail.com> References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> <2f9b2d30907150935o36b7fd6fg10bbabdb62bb72b4@mail.gmail.com> <910ddf450907161122i7e610166q7a39d4a65cd91ca0@mail.gmail.com> <2f9b2d30907161257i3eb9a4e2ja2199d0d1d02a6e6@mail.gmail.com> Message-ID: On Thu, Jul 16, 2009 at 9:57 PM, Ryan Ingram wrote: >> On Thu, Jul 16, 2009 at 8:22 PM, Thomas Hartman wrote: >>> Is this being worked on? > > On Thu, Jul 16, 2009 at 12:35 PM, Bas van Dijk wrote: >> I have no idea. > > Yes. > > Bolingbroke, Peyton-Jones. ?"Types are calling conventions" > http://lambda-the-ultimate.org/node/3319 Thanks for the pointer to this interesting paper! However I dont't think that the type system explained in that paper is powerful enough to differentiate between these different iterates: iterate1, iterate2, iterate3, iterate4 :: (a -> a) -> a -> [a] iterate1 f x = x : let nxt = f x in iterate1 f nxt iterate2 f x = let nxt = f x in nxt `seq` x : iterate2 f nxt iterate3 f x = x `seq` x : let nxt = f x in iterate3 f nxt iterate4 f x = x : let nxt = f x in nxt `seq` iterate4 f nxt The type system somehow has to express the growing and shrinking of the stack so that it can statically disallow: iterate1 (+ 1) 0 !! (10^6) :: Int & and allow: iterate4 (+ 1) 0 !! (10^6) :: Int & Bas From jules at jellybean.co.uk Fri Jul 17 07:26:04 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Jul 17 07:07:49 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: References: Message-ID: <4A605FCC.2050902@jellybean.co.uk> Job Vranish wrote: > I was needing a way to zip generic data structures together today and > was very annoyed to find that there is no Zippable class, or variant > there of. > Notice that you can always do this if the LHS is traversable and the RHS is Foldable (as a special case the RHS is the same as the LHS, since all foldables are traversable) : http://www.haskell.org/haskellwiki/Foldable_and_Traversable#Generalising_zipWith From frodo at theshire.org Fri Jul 17 07:45:54 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Jul 17 07:27:59 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot In-Reply-To: References: <4ec472cb0907151935s586a7e2eqb3f82fba760e58cf@mail.gmail.com> <1247722060.8533.71.camel@localhost> Message-ID: On Fri, Jul 17, 2009 at 12:46 PM, Thomas Davie wrote: > > Memoization is not a feature of lazyness. ?If you can do it in such a way > that you don't waste significant amount of RAM, then it may be a nice > optimisation, and an alternative evaluation strategy, but it would not be > lazy. Thank you for pointing out. I'd like to share this link to a useful article about "circular programming", which helped me a lot: http://www.csse.monash.edu.au/~lloyd/tildeFP/1989SPE/ Thank you again. Cristiano From porges at porg.es Fri Jul 17 07:50:04 2009 From: porges at porg.es (porges@porg.es) Date: Fri Jul 17 07:32:02 2009 Subject: [Haskell-cafe] Re: powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: <4A6059D8.604@gmail.com> Message-ID: 2009/7/17 Gleb Alexeyev : > On Jul 17, 2009 1:40pm, Thomas Hartman wrote: >> my question to all 3 (so far) respondants is, how does your >> >> explanation explain that the result is the power set? >> Because powerset(s) = 2^s? I was going to make some nice code but I ended up with this monster :D {-# LANGUAGE ScopedTypeVariables #-} import Control.Monad -- a more generic "if" gif p t f | p == maxBound = t | otherwise = f -- this is filterM, but with the generic if collect _ [] = return [] collect p (x:xs) = do flg <- p x ys <- collect p xs return (gif flg (x:ys) ys) -- just changed if -> gif -- list exponentiation -- first parameter is fake, just to get an 'a' expSet :: forall a b. (Bounded a, Enum a, Eq a) => a -> [b] -> [[b]] expSet _a = collect (\_-> values :: [a]) values :: (Bounded a, Enum a) => [a] values = enumFromTo minBound maxBound data Trool = Un | Deux | Trois deriving (Bounded, Enum, Eq, Show) trool = undefined :: Trool bool = undefined :: Bool powerset = expSet bool I feel dirty :P -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 908 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/b4966d5a/signature.bin From frodo at theshire.org Fri Jul 17 08:00:53 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Jul 17 07:42:58 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot In-Reply-To: References: <4ec472cb0907151935s586a7e2eqb3f82fba760e58cf@mail.gmail.com> <1247722060.8533.71.camel@localhost> Message-ID: On Fri, Jul 17, 2009 at 12:41 PM, Cristiano Paris wrote: > ... > Now, to confirm my hypothesis, I wrote a slight different version of > fib, like follows: > > fib' n = 1:1:(fib' n) `plus` (tail $ fib' n) where plus = zipWith (+) > > i.e. I inserted a fictious argument n in the definition of fib'. > > Now, if I try "take 30 $ fib' 100", it takes significntly longer than > "take 30 fib": specifically, the latter is instantaneous, while the > former takes about 5 seconds to complete on my MacBook Pro. Is this an > evidence that the "tying the knot" process is going on in the first > version? BTW, after a -O2 compilation, fib' is apparently as fast a fib. Cristiano From gale at sefer.org Fri Jul 17 08:29:22 2009 From: gale at sefer.org (Yitzchak Gale) Date: Fri Jul 17 08:11:27 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> Message-ID: <2608b8a80907170529t30f10f49n446ee6bcc3002b22@mail.gmail.com> Thomas Hartman wrote: > on haskell reddit today > powerSet = filterM (const [True, False]) > > is said to be beautiful / mind blowing. > Is this a uniquely haskell obfu, or is there a way of reading this > definition that makes sense? To me, these are more obvious: powerSet = map catMaybes . mapM ((mzero:).return.return) powerSet = map concat . mapM ((mzero:).return.return) They work by pretty much the same principle. Perhaps they seem simpler to me only because I use mapM a lot more than I use filterM. Regards, Yitz From ck_kashyap at yahoo.com Fri Jul 17 08:41:26 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Fri Jul 17 08:23:12 2009 Subject: [Haskell-cafe] Line drawing algorithm Message-ID: <628899.97202.qm@web112502.mail.gq1.yahoo.com> Hi All, I am working on a diagraming utility in Haskell. I started with line drawing. I am doing the basic stuff using the y = mx + c formula to draw a line between (x1,y1) and (x2,y2) Here's what I need to do - if dx > dy where dx = (x2 - x1) and dy = (y2 - y1) then I need to vary x between x1 and x2 and find the various y's however if dy > dx then I need to vary y beteen y1 and y2 and get various x's In the code below, I've only taken care of the situation where dx > dy - I was thinking if there was a better way to do it that takes care of the other condition as well without repeating the code. type Point = (Integer,Integer) line :: Point -> Point -> [Point] -- get all the points in the line line p1@(x1,y1) p2@(x2,y2) = line' start end start slope where (start,end) = reorderPoints p1 p2 slope = ((fromIntegral (y2-y1)) / (fromIntegral (x2-x1))) reorderPoints (px1,py1) (px2,py2) | px1 < px2 = (p1,p2) | otherwise = (p2,p1) line' :: Point -> Point -> Point -> Double -> [Point] line' start@(x1,y1) end@(x2,y2) point@(x3,y3) slope | x3 == x2 = [end] | otherwise = [point] ++ line' start end (newX,newY) slope where newX = x3 + 1 newY = y1 + round (slope * (fromIntegral (newX - x1))) hello = line (1,1) (10,10) Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/f0768a39/attachment.html From nccb2 at kent.ac.uk Fri Jul 17 08:50:30 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Fri Jul 17 08:32:16 2009 Subject: [Haskell-cafe] Line drawing algorithm In-Reply-To: <628899.97202.qm@web112502.mail.gq1.yahoo.com> References: <628899.97202.qm@web112502.mail.gq1.yahoo.com> Message-ID: <4A607396.7050000@kent.ac.uk> CK Kashyap wrote: > Hi All, > > I am working on a diagraming utility in Haskell. I started with line > drawing. > I am doing the basic stuff using the y = mx + c formula to draw a line > between (x1,y1) and (x2,y2) Hi, Are you doing this to learn Haskell, learn about drawing lines, or to just get it implemented? If either of the latter two, when drawing a straight line you shouldn't need to do floating point operations such as this: > newY = y1 + round (slope * (fromIntegral (newX - x1))) Bresenham's algorithm (or similar variants) allows you to draw a line without needing floating point. A Haskell implementation is here: http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell Although it may not be too understandable! Wikipedia has an explanation of the general algorithm: http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm As to how to cope with the dy > dx case in your code given the dx > dy case, you could just swap the x and y coords at the start, then swap back the x and y coords of all the output points afterwards. Odd, but effective :-) Thanks, Neil. From ck_kashyap at yahoo.com Fri Jul 17 09:04:18 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Fri Jul 17 08:46:04 2009 Subject: [Haskell-cafe] Line drawing algorithm In-Reply-To: <4A607396.7050000@kent.ac.uk> References: <628899.97202.qm@web112502.mail.gq1.yahoo.com> <4A607396.7050000@kent.ac.uk> Message-ID: <376679.35658.qm@web112520.mail.gq1.yahoo.com> Thanks Neil ... > Are you doing this to learn Haskell, learn about drawing lines, or to just get it implemented? If either of the latter two, when drawing a straight line you shouldn't need to do floating point operations such as this: Actually, my reasons are first and third. > newY = y1 + round (slope * (fromIntegral (newX - x1))) > http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell Thanks for the link. > As to how to cope with the dy > dx case in your code given the dx > dy case, you could just swap the x and y coords at the start, then swap back the x and y coords of all the output points afterwards. Odd, but effective :-) Slope would differ right for both case right? Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/6cd7b316/attachment.html From matthias.goergens at googlemail.com Fri Jul 17 10:14:38 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Fri Jul 17 09:56:22 2009 Subject: [Haskell-cafe] Python vs Haskell in tying the knot In-Reply-To: References: <4ec472cb0907151935s586a7e2eqb3f82fba760e58cf@mail.gmail.com> <1247722060.8533.71.camel@localhost> Message-ID: > BTW, after a -O2 compilation, fib' is apparently as fast a fib. The compiler is your friend. :o) From g9ks157k at acme.softbase.org Fri Jul 17 10:21:29 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 10:03:17 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: References: <200907101035.15723.g9ks157k@acme.softbase.org> Message-ID: <200907171621.29339.g9ks157k@acme.softbase.org> Am Freitag, 10. Juli 2009 23:41 schrieben Sie: > On Jul 10, 2009, at 4:35 AM, Wolfgang Jeltsch wrote: > > I fear that this instance doesn?t satisfy required laws. As far as > > I know, the following equalities should hold: > > > > (*>) = (>>) > > > > f *> empty = empty > > > > empty <|> g = g > > > > This implies the following: > > > > (f >> empty) <|> g = g > > > > But this wouldn?t hold with your instance. (f >> empty) <|> g would > > cause the side effects of f and of g, while g would (obviously) only cause > > the side effects of g. > > I think the third equality you provide is too strong (which isn't to > say that it might not be the law that people have documented and > expect). Lots of useful alternative instances fail it, not least any > parser combinator library (such as Parsec) without automatic > backtracking. Really? The third equality is required since Alternative instances have to be monoids with empty as the neutral element and (<|>) as composition. > [?] > Additionally, the second equality you provide is just wrong. > > f *> empty = empty is no more true than f *> g = g, I don?t understand this. The equation f *> g = g is much more general than f *> empty = empty. (<|>) usually denotes non-determinism and empty should be the neutral element of non-determinism, which is failing. This leads me to f *> empty = empty. > [?] Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Jul 17 10:23:30 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 10:05:19 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: <200907101816.59847.dan.doel@gmail.com> References: <200907101035.15723.g9ks157k@acme.softbase.org> <200907101816.59847.dan.doel@gmail.com> Message-ID: <200907171623.31047.g9ks157k@acme.softbase.org> Am Samstag, 11. Juli 2009 00:16 schrieben Sie: > On Friday 10 July 2009 4:35:15 am Wolfgang Jeltsch wrote: > > I fear that this instance doesn?t satisfy required laws. As far as I > > know, the following equalities should hold: > > > > (*>) = (>>) > > > > f *> empty = empty > > IO already fails at this law, because (f *> empty) is not the same as > empty, Huh? There was no Applicative instance for IO. This was the reason for Cristiano to define one, and my mail pointed out a problem in his definition. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Jul 17 10:27:04 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 10:08:51 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <20090707134239.0cdbc1c2@fedora> References: <200907101044.52078.g9ks157k@acme.softbase.org> <20090707134239.0cdbc1c2@fedora> Message-ID: <200907171627.04589.g9ks157k@acme.softbase.org> Am Dienstag, 7. Juli 2009 14:42 schrieb Robin Green: > On Fri, 10 Jul 2009 10:44:51 +0200 > > Wolfgang Jeltsch wrote: > > PASCAL > > uses ?program?, not ?programme?, > > The word program (as in computer program) is spelled program in both > British and American English. Probably just because British English took it from American English. It?s similar to the ?German? word ?Computer?. It?s not native. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Jul 17 10:35:34 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 10:17:23 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: References: <200907101044.52078.g9ks157k@acme.softbase.org> Message-ID: <200907171635.35039.g9ks157k@acme.softbase.org> Am Mittwoch, 15. Juli 2009 05:27 schrieben Sie: > On Jul 10, 2009, at 8:44 PM, Wolfgang Jeltsch wrote: > > Why do we use English for identifiers? Because English is the language of > > computer science. What English should we use? It?s tempting to say, we > > should use the original English, which is British English. But we should > > ask again what is the language of computer science. And the language of > > computer science is American English. > > It was possible to adopt such an attitude in the 20th century. But this is > the 21st century. We have globalisation, internationalisation, > localisation. We have Unicode, so that people are no longer limited to the > set of characters that technicians from the USA found tolerable back in > 1967. So I should upload a package with German identifiers to Hackage? Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Jul 17 10:37:43 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 10:19:30 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> Message-ID: <200907171637.43867.g9ks157k@acme.softbase.org> Am Freitag, 10. Juli 2009 09:54 schrieb david48: > Hello all, > > I made a small program for my factory and I wanted to try to document > it using haddock. The thing is, the comments are in French and the > resulting html pages are unreadable because the accentuated letters > are mangled. > > It's not acceptable to use HTML entities, as I'd like the comments to > remain readable when/if I edit the code. > > Anyone has had the same problem ? Found a workaround ? > > Thanks, > > David. To my knowledge, Haddock only supports ASCII as input encoding. If you want to have characters outside ASCII, you have to escape them using something like  . Best wishes, Wolfgang From dav.vire+haskell at gmail.com Fri Jul 17 10:43:13 2009 From: dav.vire+haskell at gmail.com (david48) Date: Fri Jul 17 10:24:58 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: <200907171637.43867.g9ks157k@acme.softbase.org> References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> <200907171637.43867.g9ks157k@acme.softbase.org> Message-ID: <4c88418c0907170743i64c6ac55i8f95ccd12768303b@mail.gmail.com> On Fri, Jul 17, 2009 at 4:37 PM, Wolfgang Jeltsch wrote: > To my knowledge, Haddock only supports ASCII as input encoding. If you want to > have characters outside ASCII, you have to escape them using something like >  . Which would mean, while editing the code I'd have to read comments like that : -- | s lection de l' tat Which becomes totally unreadable. :( David From dave at zednenem.com Fri Jul 17 10:47:21 2009 From: dave at zednenem.com (David Menendez) Date: Fri Jul 17 10:29:04 2009 Subject: [Haskell-cafe] Alternative IO In-Reply-To: <200907171621.29339.g9ks157k@acme.softbase.org> References: <200907101035.15723.g9ks157k@acme.softbase.org> <200907171621.29339.g9ks157k@acme.softbase.org> Message-ID: <49a77b7a0907170747l1ff58680kc8b061f412a63e2a@mail.gmail.com> On Fri, Jul 17, 2009 at 10:21 AM, Wolfgang Jeltsch wrote: > Am Freitag, 10. Juli 2009 23:41 schrieben Sie: > >> Additionally, the second equality you provide is just wrong. >> >> f *> empty = empty is no more true than f *> g = g, > > I don?t understand this. The equation f *> g = g is much more general than > f *> empty = empty. (<|>) usually denotes non-determinism and empty should be > the neutral element of non-determinism, which is failing. This leads me to > f *> empty = empty. That's too strong, unless you want to restrict Alternative to applicative functors with reversible side-effects. It's generally accepted that LogicT IO is an instance of MonadPlus, but liftIO (putStrLn "effects!") >> mzero /= mzero I would expect LogicT IO to be an instance of Alternative as well. -- Dave Menendez From matthias.goergens at googlemail.com Fri Jul 17 10:57:09 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Fri Jul 17 10:39:12 2009 Subject: [Haskell-cafe] Jane Street Message-ID: If one of you knows something about working at Jane Street, I'd be happy to have exchange some mails. I am considering applying there. Thanks! From tphyahoo at gmail.com Fri Jul 17 11:17:07 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Jul 17 10:58:52 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: References: Message-ID: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> cabal -v3 update will give you a more verbose version of what is going wrong. cabal --help regrettably, cabal --help doesn't tell you this but there is always the man page I suppose. 2009/7/16 Tony Hannan : > Hello, > > I'm on Ubuntu 8.10. > I installed ghc 6.10.4 (from binary package: > ghc-6.10.4-i386-unknown-linux-n.tar.bz2). > I installed haskell-platform-2009.2.0.1 (from source package: > haskell-platform-2009.2.0.1.tar.gz). It contains cabal-install-0.6.2. > > Then when I run "cabal update", I get the following error: > cabal:? : openFile: does not exist (No such file or directory) > > Any ideas? > > Thanks, > Tony > > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://www.haskell.org/mailman/listinfo/libraries > > From matthias.goergens at googlemail.com Fri Jul 17 11:47:22 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Fri Jul 17 11:29:25 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> Message-ID: Thomas, if you did no know, where to look for `lazy-memory-hole', say in your first example, how would you go about solving that puzzle systematically with a Profiler (or other tools)? From g9ks157k at acme.softbase.org Fri Jul 17 12:05:46 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 11:47:36 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: <4c88418c0907170743i64c6ac55i8f95ccd12768303b@mail.gmail.com> References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> <200907171637.43867.g9ks157k@acme.softbase.org> <4c88418c0907170743i64c6ac55i8f95ccd12768303b@mail.gmail.com> Message-ID: <200907171805.46186.g9ks157k@acme.softbase.org> Am Freitag, 17. Juli 2009 16:43 schrieben Sie: > On Fri, Jul 17, 2009 at 4:37 PM, Wolfgang > > Jeltsch wrote: > > To my knowledge, Haddock only supports ASCII as input encoding. If you > > want to have characters outside ASCII, you have to escape them using > > something like  . > > Which would mean, while editing the code I'd have to read comments like > that : > > -- | s lection de l' tat > > Which becomes totally unreadable. > > :( Yes, it?s a pity. For me, it?s not such a big problem since I don?t write my Haddock comments in my native language (German) but in English. I only experience this problem because I use nice typography, i.e., ? ? ? instead of " " -. GHC supports UTF-8 input, and Haddock uses GHC nowadays. So, in my opinion, Haddock should also support UTF-8 input. Do you want to file a feature request? Best wishes, Wolfgang From tphyahoo at gmail.com Fri Jul 17 12:06:18 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Jul 17 11:48:03 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> Message-ID: <910ddf450907170906h32aa21daw72fa9c4b5a49163d@mail.gmail.com> I don't have a good answer to that, and I unable to reliably solve this type of problem, which is one reason I am posting around on haskell cafe hoping to accumulate wisdom. Here for instance I think I did t = last . take (10^6) $ repeat $ S.empty which doesn't blow up, and by process of elimination figured the process must be in iterate. I then looked at iterate by writing myiterate (could have also copied from hackage prelude) and thought about it until the answer (well, an answer, maybe not the best one) came myiterate f x = x : myiterate f (f x) In general, I feel like I don't do very well solving these types of problems. Am 17. Juli 2009 08:47 schrieb Matthias G?rgens : > Thomas, if you did no know, where to look for `lazy-memory-hole', say > in your first example, how would you go about solving that puzzle > systematically with a Profiler (or other tools)? > From dav.vire+haskell at gmail.com Fri Jul 17 12:15:56 2009 From: dav.vire+haskell at gmail.com (david48) Date: Fri Jul 17 11:57:40 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: <200907171805.46186.g9ks157k@acme.softbase.org> References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> <200907171637.43867.g9ks157k@acme.softbase.org> <4c88418c0907170743i64c6ac55i8f95ccd12768303b@mail.gmail.com> <200907171805.46186.g9ks157k@acme.softbase.org> Message-ID: <4c88418c0907170915p4dcc24a9p8cef743121326320@mail.gmail.com> On Fri, Jul 17, 2009 at 4:05 PM, Wolfgang Jeltsch wrote: > Yes, it?s a pity. For me, it?s not such a big problem since I don?t write my > Haddock comments in my native language (German) but in English. I only > experience this problem because I use nice typography, i.e., ? ? ? instead > of " " -. I would write the comments in English, but as it is, it's a little piece of code for our factory that's never going to be released. Still, I wanted to document it properly, and my boss can't read English. > GHC supports UTF-8 input, and Haddock uses GHC nowadays. So, in my opinion, > Haddock should also support UTF-8 input. Do you want to file a feature > request? Sure. I'm registering to haddock trac site and will search the tickets. David. From dav.vire+haskell at gmail.com Fri Jul 17 12:25:09 2009 From: dav.vire+haskell at gmail.com (david48) Date: Fri Jul 17 12:06:53 2009 Subject: [Haskell-cafe] What's the status with unicode characters on haddock ? In-Reply-To: <4c88418c0907170915p4dcc24a9p8cef743121326320@mail.gmail.com> References: <4c88418c0907100054o45d3de04s1f8cddf14d9ec69f@mail.gmail.com> <200907171637.43867.g9ks157k@acme.softbase.org> <4c88418c0907170743i64c6ac55i8f95ccd12768303b@mail.gmail.com> <200907171805.46186.g9ks157k@acme.softbase.org> <4c88418c0907170915p4dcc24a9p8cef743121326320@mail.gmail.com> Message-ID: <4c88418c0907170925o3d73d8e7i6540f4cfa8d12be2@mail.gmail.com> On Fri, Jul 17, 2009 at 4:15 PM, david48 wrote: > On Fri, Jul 17, 2009 at 4:05 PM, Wolfgang >> GHC supports UTF-8 input, and Haddock uses GHC nowadays. So, in my opinion, >> Haddock should also support UTF-8 input. Do you want to file a feature >> request? > Sure. I'm registering to haddock trac site and will search the tickets. There are two tickets already about unicode or character handling: #20 and #116. It doesn't look like it's a hot issue :( David. From cetin.sert at gmail.com Fri Jul 17 12:31:20 2009 From: cetin.sert at gmail.com (Cetin Sert) Date: Fri Jul 17 12:15:00 2009 Subject: [Haskell-cafe] Plot data reconstruction reading pixel colors from image files Message-ID: <1ff5dedc0907170931x63620a6cy72d85db5e6120fb2@mail.gmail.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: fig37-points.png Type: image/png Size: 8904 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/345e7f91/fig37-points.png From matthias.goergens at googlemail.com Fri Jul 17 12:50:55 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Fri Jul 17 12:32:59 2009 Subject: [Haskell-cafe] laziness blowup exercise In-Reply-To: <910ddf450907170906h32aa21daw72fa9c4b5a49163d@mail.gmail.com> References: <910ddf450907141802t64297d2dmef01c24d459c59b2@mail.gmail.com> <910ddf450907170906h32aa21daw72fa9c4b5a49163d@mail.gmail.com> Message-ID: I tried using your original code and stuffing it into a profiler. But all I get is a triangle of linearly increasing resource usage, and then it breaks for lack of stack. I guess I am just to ignorant about retainer profiling and such stuff. From andrewcoppin at btinternet.com Fri Jul 17 13:07:03 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jul 17 12:48:48 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <61f84eff0907161538u2ae15974g6c303d8206da7c71@mail.gmail.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> <4A5F8508.3040403@btinternet.com> <61f84eff0907161538u2ae15974g6c303d8206da7c71@mail.gmail.com> Message-ID: <4A60AFB7.2000003@btinternet.com> Derek Elkins wrote: > The answer to your questions are on the back of this T-shirt. > http://www.cafepress.com/skicalc.6225368 > Oh... dear God. o_O From andrewcoppin at btinternet.com Fri Jul 17 13:08:37 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Jul 17 12:50:20 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <20090717000531.GB21698@sliver.repetae.net> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> <4A5F8508.3040403@btinternet.com> <20090717000531.GB21698@sliver.repetae.net> Message-ID: <4A60B015.9090903@btinternet.com> John Meacham wrote: > actually, the rules are pretty straightforward. It doesn't matter where > something is bound, just _how_ it is bound. Let-bound names (which > includes 'where' and top-level definitions) can be polymorphic. > lambda-bound or case-bound names (names bound as an argument to a > function or that appear in a pattern) can only be monomorphic. And > that's all there is to it. (the monomorphism restriction complicates it > a little, but we don't need to worry about that for now) > That seems simple enough (although problematic to implement). However, the Report seems to say that it matters whether or not the bindings are muturally recursive [but I'm not sure precisely *how* it matters...] From matthias.goergens at googlemail.com Fri Jul 17 13:15:36 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Fri Jul 17 12:57:40 2009 Subject: [Haskell-cafe] Plot data reconstruction reading pixel colors from image files In-Reply-To: <1ff5dedc0907170931x63620a6cy72d85db5e6120fb2@mail.gmail.com> References: <1ff5dedc0907170931x63620a6cy72d85db5e6120fb2@mail.gmail.com> Message-ID: If you don't find anything more specific, I suggest taking a look at Data.Binary and reading a simple format like BMP or so. (You can convert your file to BMP with an external program before.) From felipe.lessa at gmail.com Fri Jul 17 13:24:00 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Jul 17 13:05:51 2009 Subject: [Haskell-cafe] Plot data reconstruction reading pixel colors from image files In-Reply-To: <1ff5dedc0907170931x63620a6cy72d85db5e6120fb2@mail.gmail.com> References: <1ff5dedc0907170931x63620a6cy72d85db5e6120fb2@mail.gmail.com> Message-ID: <20090717172400.GA21826@kira.casa> On Fri, Jul 17, 2009 at 06:31:20PM +0200, Cetin Sert wrote: > How can I open and read colors of specific pixels of an image file in > Haskell? Which packages, functions do you recommend? You could try DevIL, SDL-image or Gtk, I guess. -- Felipe. From ck_kashyap at yahoo.com Fri Jul 17 13:47:22 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Fri Jul 17 13:29:08 2009 Subject: [Haskell-cafe] Oops in Haskell Message-ID: <29934.22682.qm@web112510.mail.gq1.yahoo.com> Hi, Can someone please send me a working example based on the contents posted in the URL below? http://yi-editor.blogspot.com/2008/12/prototypes-encoding-oo-style.html Thanks, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/a46bf83e/attachment.html From stefan at cs.uu.nl Fri Jul 17 14:28:47 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Jul 17 14:10:33 2009 Subject: [Haskell-cafe] Oops in Haskell In-Reply-To: <29934.22682.qm@web112510.mail.gq1.yahoo.com> References: <29934.22682.qm@web112510.mail.gq1.yahoo.com> Message-ID: <893A052F-9106-4838-9086-6BBCCF7ED1E7@cs.uu.nl> Kashyap, > Can someone please send me a working example based on the contents > posted in the URL below? There's a small typo in the post: the definition of Proto should read data Proto = Proto {a :: A, b :: B, c :: C} The rest seems fine to me. (See below for an excerpt). Cheers, Stefan ------------------------------------------- import Data.Function (fix) data A = A B C ; fa = A data B = B A C ; fb = B data C = C A B ; fc = C userFunction = C data Proto = Proto {a :: A, b :: B, c :: C} proto = \self -> Proto { a = fa (b self) (c self), b = fb (a self) (c self), c = fc (a self) (b self) } customizedProto = \self -> proto self { c = userFunction (a self) (b self) } customizedABC = fix customizedProto From stefan at cs.uu.nl Fri Jul 17 14:34:09 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Jul 17 14:15:53 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A60B015.9090903@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> <4A5F8508.3040403@btinternet.com> <20090717000531.GB21698@sliver.repetae.net> <4A60B015.9090903@btinternet.com> Message-ID: <9FE51A96-8FBC-433A-9052-C6FC6A06A995@cs.uu.nl> Andrew, > That seems simple enough (although problematic to implement). > However, the Report seems to say that it matters whether or not the > bindings are muturally recursive [but I'm not sure precisely *how* > it matters...] It means that functions can only be used monomorphically within their own binding group. (That includes the definition of the function itself: functions cannot be polymorphically recursive. Of course, these restrictions do not apply in case of explicit type signatures. Even if this doesn't all make sense, immediately, it should give you something to google for. ;-)) Cheers, Stefan From chrisdone at googlemail.com Fri Jul 17 14:35:10 2009 From: chrisdone at googlemail.com (Christopher Done) Date: Fri Jul 17 14:16:53 2009 Subject: [Haskell-cafe] Pattern matching with where free variables can be used more than once Message-ID: <7f55268a0907171135j76e41da4h3036f04b85416dc3@mail.gmail.com> Wouldn't it be great if pattern variables could be used more than once in a pattern? Like so: foo [x,x,_,x] = "The values are the same!" foo _ = "They're not the same!" where this could be rewritten to: foo [x,y,_,z] | x == y && x == z = "The values are the same!" foo _ = "They're not the same!" It seems like a straight-forward translation and there wouldn't be a speed hit for normal patterns because it would only be triggered in compilation where the same free variable appears twice. Implications are: 1. in ``foo [x,y] = ...'', x has type a 1. in ``foo [x,x] = ...'', x has type Eq a => a Was this ever considered? Is it a bad idea for some reason I'm not aware of? On a mildly irrelevant note, I have observed newbies to the language wonder why on earth it's not already like this. Cheers From stefan at cs.uu.nl Fri Jul 17 14:38:54 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Jul 17 14:20:38 2009 Subject: [Haskell-cafe] Pattern matching with where free variables can be used more than once In-Reply-To: <7f55268a0907171135j76e41da4h3036f04b85416dc3@mail.gmail.com> References: <7f55268a0907171135j76e41da4h3036f04b85416dc3@mail.gmail.com> Message-ID: Christopher, > Wouldn't it be great if pattern variables could be used more than once > in a pattern? Like so: > > foo [x,x,_,x] = "The values are the same!" > foo _ = "They're not the same!" These are called nonlinear patterns. I think Miranda (a precursor of Haskell, sort of) used to have them. Cheers, Stefan From deb at pudlak.name Fri Jul 17 14:56:49 2009 From: deb at pudlak.name (Petr Pudlak) Date: Fri Jul 17 14:38:33 2009 Subject: [Haskell-cafe] excercise - a completely lazy sorting algorithm In-Reply-To: References: <20090706192637.GA19982@pudlak.name> <1246917027.4335.19.camel@supermule.opasia.dk> <2a774a0c0907061642m139b75aep7ee835dfc3f08b06@mail.gmail.com> Message-ID: <20090717185649.GD20415@pudlak.name> Hi all, I apologize that I didn't react to your posts, I was on a vacation. (BTW, if you ever come to Slovakia, I strongly recommend visiting Mala (Lesser) Fatra mountains. IMHO it's more beautiful than more-known Tatra mountains.) Thanks for your interest and many intriguing ideas. Especially, I like cata-/ana-/hylo-morphisms, it looks to me as a very useful concept to learn. I hope I'll manage to create my own version of the sorting algorithm based on your advices. Maybe I'll also try to do some real benchmarks, if I have time. -Petr On Tue, Jul 07, 2009 at 02:49:08AM +0200, Matthias G?rgens wrote: > The "sorted array of bags of unsorted input" is a nice idea. However, > you have to use the data structure in a single-threaded [1] fashion to > obtain the claimed bounds. > > Here's a pure solution that uses amortization and laziness. > > > import qualified Data.Sequence as S > > import Data.Sequence ((><)) > > import Data.Foldable > > import Data.Monoid > > Suppose we have a function to find the the median of a list, and > partition it into three sublists: Smaller than the median, equal to > the media, larger than the median. That function should run in linear > time. > > > partitionOnMedian :: forall a. (Ord a) => (S.Seq a) -> BTreeRaw a (S.Seq a) > > where the following data structure holds the sublists and some > bookkeeping information: > > > data BTreeRaw a m = Leaf > > | Node {cmp::(a->Ordering) > > , lN :: Int > > , less::m > > , eq :: (S.Seq a) > > , gN :: Int > > , greater::m > > } > > where 'lN' and 'gN' are the length of 'less' and 'greater'. > > We can make BTreeRaw a functor: > > > instance Functor (BTreeRaw a) where > > fmap f Leaf = Leaf > > fmap f (Node c lN l e gN g) = Node c lN (f l) e gN (f g) > > Now using a fixed-point construction we can bootstrap a sorting > algorithm from partitionOnMedian: > > > data Fix m = Fix {unfix :: (m (Fix m))} > > type BTree a = Fix (BTreeRaw a) > > > treeSort :: forall a. (Ord a) => S.Seq a -> BTree a > > treeSort = Fix . helper . partitionOnMedian > > where helper = fmap (Fix . helper . partitionOnMedian) > > Now treeSort produces the thunk of a balanced binary search tree. Of > course we can get a sorted list out of it (forcing the whole > structure): > > > flatten :: BTree a -> S.Seq a > > flatten (Fix Leaf) = S.empty > > flatten (Fix (Node _ lN l e gN g)) = flatten l >< e >< flatten g > > > mySort = flatten . treeSort > > But we can also get elements efficently, forcing only a linear amount > of comparisions in the worst case: > > > index :: BTree a -> Int -> a > > index (Fix Leaf) _ = error "tried to get an element of Leaf" > > index (Fix (Node lN l e gN g)) i | i < lN > > = index l i > > | i - lN < S.length e > > = S.index e (i-lN) > > | i - lN - S.length e < gN > > = index g (i - lN - S.length e) > > | i - lN - S.length e - gN >= 0 > > = error "index out of bounds" > > Although we do have to force comparisions only once every time we > touch the same element in the tree, we do still have to traverse the > tree (in logarithmic time). > > If you want linear time access on first touch of an element and > constant time access afterwards us toArray: > > > toArray :: (IA.IArray a t) => Fix (BTreeRaw t) -> a Int t > > toArray tree = IA.listArray (0,maxI) (map (index tree) [0..maxI]) > > where size (Fix Leaf) = 0 > > size (Fix (Node lN _ e gN _)) = lN + S.length e + gN > > maxI = size tree - 1 > > [1] Single-Threaded in the sense of Okasaki's use of the word. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dmehrtash at gmail.com Fri Jul 17 15:06:23 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Fri Jul 17 14:48:07 2009 Subject: [Haskell-cafe] What is the point of the 'What the bleep' names in haskell? Message-ID: Why do Haskell programmers (and libraries) name their function like "<@<" or "###"? Why not use a more descriptive label for functions? Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/dc57304a/attachment.html From allbery at ece.cmu.edu Fri Jul 17 15:08:23 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Jul 17 14:50:16 2009 Subject: [Haskell-cafe] What is the point of the 'What the bleep' names in haskell? In-Reply-To: References: 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/20090717/2229e016/PGP.bin From deb at pudlak.name Fri Jul 17 15:14:33 2009 From: deb at pudlak.name (Petr Pudlak) Date: Fri Jul 17 14:56:18 2009 Subject: [Haskell-cafe] an instance in other than the last type parameters Message-ID: <20090717191433.GA19514@pudlak.name> Hi, I have probably a very simple question, but I wasn't able to figure it out myself. Consider a two-parameter data type: > data X a b = X a b If I want to make it a functor in the last type variable (b), I can just define > instance Functor (X a) where > fmap f (X a b) = X a (f b) But how do I write it if I want X to be a functor in its first type variable? Is that possible at all? Something like: > instance Functor ??? where > fmap f (X a b) = X (f a) b Thanks in advance, Petr From dons at galois.com Fri Jul 17 15:18:50 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 17 15:02:36 2009 Subject: [Haskell-cafe] What is the point of the 'What the bleep' names in haskell? In-Reply-To: References: Message-ID: <20090717191849.GI2240@whirlpool.galois.com> dmehrtash: > Why do Haskell programmers (and libraries) name their function like "<@<" or "# > ##"? Why not use a more descriptive label for functions? Where are those functions defined?? From stefan at cs.uu.nl Fri Jul 17 15:25:57 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Jul 17 15:07:42 2009 Subject: [Haskell-cafe] an instance in other than the last type parameters In-Reply-To: <20090717191433.GA19514@pudlak.name> References: <20090717191433.GA19514@pudlak.name> Message-ID: Petr, > If I want to make it a functor in the last type variable (b), I can > just define > >> instance Functor (X a) where >> fmap f (X a b) = X a (f b) > > But how do I write it if I want X to be a functor in its first type > variable? Short answer: you can't. Easiest way to workaround is to define a newtype wrapper around your original datatype: newtype X' b a = X' {unX' :: X a b} instance Functor (X' b) where fmap g (X' (X a b)) = X' (X b (g a)) Cheers, Stefan From jgbailey at gmail.com Fri Jul 17 15:41:16 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Fri Jul 17 15:23:37 2009 Subject: [Haskell-cafe] What is the point of the 'What the bleep' names in haskell? In-Reply-To: <20090717191849.GI2240@whirlpool.galois.com> References: <20090717191849.GI2240@whirlpool.galois.com> Message-ID: System.Console.Curses? Sorry couldn't resist ... On Fri, Jul 17, 2009 at 12:18 PM, Don Stewart wrote: > dmehrtash: >> Why do Haskell programmers (and libraries) name their function like "<@<" or "# >> ##"? ? ?Why not use a more descriptive label for functions? > > Where are those functions defined?? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From stefan at cs.uu.nl Fri Jul 17 15:43:03 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Jul 17 15:24:47 2009 Subject: [Haskell-cafe] an instance in other than the last type parameters In-Reply-To: References: <20090717191433.GA19514@pudlak.name> Message-ID: <1B5335DA-09BC-4DFE-9BFC-18CDECD3FF82@cs.uu.nl> Petr, > Short answer: you can't. Easiest way to workaround is to define a > newtype wrapper around your original datatype: > > newtype X' b a = X' {unX' :: X a b} > > instance Functor (X' b) where > fmap g (X' (X a b)) = X' (X b (g a)) Err.... fmap g (X' (X a b)) = X' (X (g a) b) Cheers, Stefan From geoffrey.marchant at gmail.com Fri Jul 17 16:08:08 2009 From: geoffrey.marchant at gmail.com (Geoffrey Marchant) Date: Fri Jul 17 15:50:10 2009 Subject: [Haskell-cafe] an instance in other than the last type parameters In-Reply-To: <20090717191433.GA19514@pudlak.name> References: <20090717191433.GA19514@pudlak.name> Message-ID: <79e6290e0907171308k3d6aeebrcccdd1af9e115bfa@mail.gmail.com> > data X a b = X a b> instance Functor (X a) where > fmap f (X a b) = X a (f b) Yeah, that works just fine. On Fri, Jul 17, 2009 at 1:14 PM, Petr Pudlak wrote: > Hi, I have probably a very simple question, but I wasn't able to figure it > out > myself. > > Consider a two-parameter data type: > > > data X a b = X a b > > If I want to make it a functor in the last type variable (b), I can just > define > > > instance Functor (X a) where > > fmap f (X a b) = X a (f b) > > But how do I write it if I want X to be a functor in its first type > variable? > Is that possible at all? > Something like: > > > instance Functor ??? where > > fmap f (X a b) = X (f a) b > > Thanks in advance, > Petr > _______________________________________________ > 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/20090717/2c44c1e7/attachment.html From g9ks157k at acme.softbase.org Fri Jul 17 16:19:09 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 16:00:56 2009 Subject: [Haskell-cafe] Pattern matching with where free variables can be used more than once In-Reply-To: References: <7f55268a0907171135j76e41da4h3036f04b85416dc3@mail.gmail.com> Message-ID: <200907172219.09142.g9ks157k@acme.softbase.org> Am Freitag, 17. Juli 2009 20:38 schrieb Stefan Holdermans: > Christopher, > > > Wouldn't it be great if pattern variables could be used more than once > > in a pattern? Like so: > > > > foo [x,x,_,x] = "The values are the same!" > > foo _ = "They're not the same!" > > These are called nonlinear patterns. I think Miranda (a precursor of > Haskell, sort of) used to have them. Yes, Miranda had them. I see the following problem with them: Patterns are about the structure of data. So using the same variable twice in the same pattern should mean that the values that match the variable must have the same structure. This would break data abstraction. For example, matching a pair of sets against the pattern (x,x) would succeed if both sets were represented by the same tree internally, but not succeed if both sets were equal but represented differently. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Jul 17 16:20:39 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 16:02:25 2009 Subject: [Haskell-cafe] What is the point of the 'What the bleep' names in haskell? In-Reply-To: References: Message-ID: <200907172220.39622.g9ks157k@acme.softbase.org> Am Freitag, 17. Juli 2009 21:06 schrieb Daryoush Mehrtash: > Why do Haskell programmers (and libraries) name their function like "<@<" > or "###"? Why not use a more descriptive label for functions? It?s for the same reason that mathematicians say 2 + 3 instead of plus(2,3): it?s more readable at times. :-) Best wishes, Wolfgang From lemming at henning-thielemann.de Fri Jul 17 16:25:48 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 17 16:07:33 2009 Subject: [Haskell-cafe] uncommon IMO problem - toilet management Message-ID: In the last two days I was invigilator at the International Mathematic Olympics 2009 in Bremen, Germany. There we got a problem different from the official math problems. :-) Eventually I solved it using Haskell. Read the detailed description at http://hackage.haskell.org/package/toilet-0.0.1 I think the problem is simple enough to be used in education of programming. (I also think it would have been better to avoid monads and use lazy list processing.) From g9ks157k at acme.softbase.org Fri Jul 17 16:58:23 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 16:40:14 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: first Grapefruit release In-Reply-To: References: <200902141719.09745.g9ks157k@acme.softbase.org> <200902161411.37127.g9ks157k@acme.softbase.org> Message-ID: <200907172258.24043.g9ks157k@acme.softbase.org> Am Montag, 16. Februar 2009 15:27 schrieben Sie: > On Mon, 16 Feb 2009, Wolfgang Jeltsch wrote: > > [redirecting to haskell-cafe] > > > > Am Sonntag, 15. Februar 2009 00:25 schrieben Sie: > >> Hi Wolfgang, > >> > >> I was wondering if I can use FLTK as GUI backend for Grapefruit? > > > > This should be possible in principal. It just could be that my > > assumptions about how widgets are created and composed were too tight so > > that Grapefruit?s general interface doesn?t fit FLTK. In this case, > > please just tell me and I will try to make the interface more general. > > Ok, great I ll have to use them then I will see and know what improvement > is needed. > > >> I believe for this to make it happen, I would have to output FLTK's C++ > >> into C then create bindings for Haskell (via FFI). Is that doable or an > >> quite tall order? > > > > Recently, a student of mine has written a program which generates a > > Haskell Qt binding fully automatically from Qt header files. The > > generated binding consists of three layers. The first layer is C++ code > > which reexports Qt?s functionality as a pure C interface. The C interface > > is ugly for humans and not type safe (because C doesn?t know classes). > > The second layer consists of a couple of FFI declarations. The third > > layer is Haskell code which provides a nice interface similar to the > > original C++ interface. > > > > I still have to get the source code of the binding generator from that > > student but I hope this will happen soon. I want to publish it then on > > the web. It hope that it is possible to reuse this binding generator for > > other C++ libraries. > > That would be very helpful, I ll be looking forward. Hello Jamie, it?s been quite some time that we had this discussion about writing a FLTK-based GUI backend for Grapefruit. I?m sorry that I have to tell you that the above-mentioned student never managed to send me a final version of this Qt binding generator. At least, I was able to make him send me the current state of his code. I don?t think he will improve this code anymore. If you want to have a look at the code, please visit and follow the link to the code and have a look at the building tips. In case you would like to improve the binding generator, I?d be happy to receive patches. :-) Best wishes, Wolfgang From g9ks157k at acme.softbase.org Fri Jul 17 17:03:59 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jul 17 16:45:46 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: first Grapefruit release In-Reply-To: <4165d3a70902180642k5b08153btb8b7530549afee0b@mail.gmail.com> References: <200902141719.09745.g9ks157k@acme.softbase.org> <200902181017.16980.g9ks157k@acme.softbase.org> <4165d3a70902180642k5b08153btb8b7530549afee0b@mail.gmail.com> Message-ID: <200907172303.59847.g9ks157k@acme.softbase.org> Hello Jeff, it?s been some time that we had the conversation below and I have to tell you the same thing I told Jamie in a haskell-cafe mail sent a few minutes ago: The student who wrote the Qt binding generator never managed to send me a final version of his code. At least, I was able to make him send me the current state. I don?t think he will improve this code anymore. If you want to have a look at the code, please visit and follow the link to the code and have a look at the building tips. In case you would like to improve the binding generator, I?d be happy to receive patches. :-) Sorry for these bad news. Best wishes, Wolfgang Am Mittwoch, 18. Februar 2009 15:42 schrieb Jeff Heard: > When he gives you the code, could you let me know? I would really > love to bind Open Scene Graph, but it's entirely C++ and that makes > for a lot more difficult coding to say the least. > > On Wed, Feb 18, 2009 at 4:17 AM, Wolfgang Jeltsch > > wrote: > > Am Dienstag, 17. Februar 2009 19:36 schrieben Sie: > >> > If you have problems with Gtk2Hs on Windows, it might be better to > >> > write a Win32-based backend for Grapefruit instead of a > >> > wxWidgets-based one. What do you think about that? > >> > >> Win32-based backend would make more sense as it is one less layer to > >> deal with. But how? Same thing with Mac. > > > > A student of mine wrote a fully automatic binding generator for C++ > > libraries which also supports Qt extensions (signals and slots). > > (However, this guy still has to give me the code. :-/ ) One could do a > > similar thing for generating Win32 and Cocoa bindings. Then one could > > write Grapefruit UI backends based on these bindings. > > > > Best wishes, > > Wolfgang > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe From lemming at henning-thielemann.de Fri Jul 17 17:16:57 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 17 16:57:53 2009 Subject: [Haskell-cafe] Re: [Haskell] ANN: data-ordlist-0.0.1 and NumberSieves-0.0 In-Reply-To: References: Message-ID: <4A60EA49.6020600@henning-thielemann.de> Leon Smith schrieb: > Two new packages have been uploaded to Hackage, one that implements bag > (multiset) and set operations on ordered lists, and another that offers > three different number theoretic sieves. > > http://hackage.haskell.org/package/data-ordlist > > Data.OrdList offers many of the same kinds of operations as Data.Set, > although Data.Set is likely to often be a better choice. However, > this library is not intended to be used as an abstract datatype for sets > and multisets, rather it is intended to be a convenient way for > efficiently dealing with lists that you happen to know are ordered. You could also implement that in terms of Map a Int. From lemming at henning-thielemann.de Fri Jul 17 17:42:44 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 17 17:23:40 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <200907171635.35039.g9ks157k@acme.softbase.org> References: <200907101044.52078.g9ks157k@acme.softbase.org> <200907171635.35039.g9ks157k@acme.softbase.org> Message-ID: <4A60F054.8050106@henning-thielemann.de> Wolfgang Jeltsch schrieb: > Am Mittwoch, 15. Juli 2009 05:27 schrieben Sie: >> On Jul 10, 2009, at 8:44 PM, Wolfgang Jeltsch wrote: >>> Why do we use English for identifiers? Because English is the language of >>> computer science. What English should we use? It?s tempting to say, we >>> should use the original English, which is British English. But we should >>> ask again what is the language of computer science. And the language of >>> computer science is American English. >> It was possible to adopt such an attitude in the 20th century. But this is >> the 21st century. We have globalisation, internationalisation, >> localisation. We have Unicode, so that people are no longer limited to the >> set of characters that technicians from the USA found tolerable back in >> 1967. > > So I should upload a package with German identifiers to Hackage? I most like identifiers like "getZahl". :-) From lemming at henning-thielemann.de Fri Jul 17 18:04:19 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 17 17:46:03 2009 Subject: [Haskell-cafe] Debugging methods for haskell In-Reply-To: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Message-ID: On Thu, 16 Jul 2009, Fernan Bolando wrote: > Hi all > > I recently used 2 hours of work looking for a bug that was causing > > Program error: Prelude.!!: index too large A good way to avoid such problems is to avoid partial functions at all. (!!) is also inefficient. Is it possible to define the function in terms of foldl? From tphyahoo at gmail.com Fri Jul 17 18:24:21 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Jul 17 18:06:05 2009 Subject: [Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo? Message-ID: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> The code below is, I think, n log n, a few seconds on a million + element list. I wonder if it's possible to get this down to O(N) by using a hashtable implemementation, or other better data structure. Further, is there a hashtable implementation for haskell that doesn't live in IO? Maybe in ST or something? import Data.HashTable import qualified Data.Set as S import Data.List (foldl') testdata = [1,4,8,9,20,11,20,14,2,15] ++ [1..(10^6)] wantedsum = 29 -- set data structure -- findsums locates pairs of integers in a list that add up to a wanted sum. findsums :: [Int] -> Int -> S.Set (Int,Int) findsums xs wanted = snd . foldl' f (S.empty,S.empty) $ xs where f (candidates,successes) next = if S.member (wanted-next) candidates then (candidates, S.insert (next,wanted-next) successes) else (S.insert next candidates,successes) -- hashtable data structure -- result: t -- fromList [(15,14),(16,13),(17,12),(18,11),(19,10),(20,9),(21,8),(22,7),(23,6),(24,5),(25,4),(26,3),(27,2),(28,1)] -- probably O(n log n) complexity since using tree based Data.Set (a few seconds on million+ element list) t = findsums testdata wantedsum From lemming at henning-thielemann.de Fri Jul 17 18:25:23 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jul 17 18:06:19 2009 Subject: [Haskell-cafe] Plot data reconstruction reading pixel colors from image files In-Reply-To: <20090717172400.GA21826@kira.casa> References: <1ff5dedc0907170931x63620a6cy72d85db5e6120fb2@mail.gmail.com> <20090717172400.GA21826@kira.casa> Message-ID: <4A60FA53.60407@henning-thielemann.de> Felipe Lessa schrieb: > On Fri, Jul 17, 2009 at 06:31:20PM +0200, Cetin Sert wrote: >> How can I open and read colors of specific pixels of an image file in >> Haskell? Which packages, functions do you recommend? > > You could try DevIL, SDL-image or Gtk, I guess. Perhaps http://hackage.haskell.org/package/pgm From conor at strictlypositive.org Fri Jul 17 11:38:36 2009 From: conor at strictlypositive.org (Conor McBride) Date: Fri Jul 17 18:19:13 2009 Subject: [Haskell-cafe] is closing a class this easy? Message-ID: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> Friends Is closing a class this easy? -------------------------------------- module Moo ( Public(..) ) where class Private x => Public x where blah :: ... class Private x where instance Private A where instance Public A where blah = ... instance Private B where instance Public B where blah = ... -------------------------------------- Modules importing Moo get Public and its instances, but cannot add new ones: any such instances must be accompanied by Private instances, and Private is out of scope. Does this work? If not, why not? If so, is this well known? It seems to be just what I need for a job I have in mind. I want a class with nothing but hypothetical instances. It seems like I could write -------------------------------------- module Noo ( Public(..) , public ) where class Private x => Public x where blah :: ... blah = ... class Private x where public :: (forall x. Public x => x -> y) -> y public f = f Pike data Pike = Pike instance Private Pike instance Public Pike -------------------------------------- But if I don't tell 'em Pike, I've ensured that blah can only be used in the argument to public. Or is there a hole? Cures youriously Conor From briqueabraque at yahoo.com Fri Jul 17 18:41:47 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Fri Jul 17 18:24:15 2009 Subject: [Haskell-cafe] FFI to double constants, printf Message-ID: When we printf doubles from C (like when using hsc2hs to bind to a constant) we can get something that's not valid Haskell. See these 2 examples: 3.40282347e+38F inf Do you know some way to printf a double using printf (or any other standard function) that's always going to give me valid Haskell text, even in special cases? Thanks, Maur?cio From qdunkan at gmail.com Fri Jul 17 18:56:41 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Fri Jul 17 18:38:25 2009 Subject: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with qualified names? Message-ID: <2518b95d0907171556l3745912na56481698094b2dd@mail.gmail.com> Record punning is not all that useful with qualified module names. If I write '(M.Record { M.rec_x })' it says " Qualified variable in pattern" and if I write '(M.Record { rec_x })' it says 'Not in scope: `rec_x''. Could it be this extension be further extended slightly so that 'f (M.Record { M.rec_x })' will desugar to 'f (M.Record { M.rec_x = rec_x })'? Similarly, RecordWildCards could support this too. It seems simple and useful to me... am I missing anything fatally problematic about this? Would anyone else use it? From vanenkj at gmail.com Fri Jul 17 18:59:37 2009 From: vanenkj at gmail.com (John Van Enk) Date: Fri Jul 17 18:41:20 2009 Subject: [Haskell-cafe] FFI to double constants, printf In-Reply-To: References: Message-ID: You probably want something like printf("%.10Lg",d);. Here's a shot C example and its output: #include int main(int argc, char * argv[]) { long double d = 0.123456789; printf("%.30Lf\n", d); printf("%.20Lg\n", d); printf("%.20Le\n", d); } /* 0.123456788999999997336054491370 0.12345678899999999734 1.23456788999999997336e-01 */ On Fri, Jul 17, 2009 at 6:41 PM, Maur??cio wrote: > When we printf doubles from C (like when using hsc2hs to bind to a > constant) we can get something that's not valid Haskell. See these > 2 examples: > > 3.40282347e+38F > > inf > > Do you know some way to printf a double using printf (or any other > standard function) that's always going to give me valid Haskell > text, even in special cases? > > Thanks, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ekmett at gmail.com Fri Jul 17 20:40:28 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Jul 17 20:22:13 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> Message-ID: <7fb8f82f0907171740x2f9b1d7pca599ffee1a574f8@mail.gmail.com> I've used a similar approach for a while, for instance in http://comonad.com/haskell/type-int/src/Data/Type/Boolean.hs But I think your approach is cleaner than mine, because it doesn't need my seemingly superfluous closure term or fundep. -Edward Kmett On Fri, Jul 17, 2009 at 11:38 AM, Conor McBride wrote: > Friends > > Is closing a class this easy? > > -------------------------------------- > > module Moo > ( Public(..) > ) where > > class Private x => Public x where > blah :: ... > > class Private x where > > instance Private A where > instance Public A where > blah = ... > > instance Private B where > instance Public B where > blah = ... > > -------------------------------------- > > Modules importing Moo get Public and its instances, > but cannot add new ones: any such instances must be > accompanied by Private instances, and Private is > out of scope. > > Does this work? If not, why not? If so, is this well > known? > > It seems to be just what I need for a job I have in > mind. I want a class with nothing but hypothetical > instances. It seems like I could write > > -------------------------------------- > > module Noo > ( Public(..) > , public > ) where > > class Private x => Public x where > blah :: ... > blah = ... > > class Private x where > > public :: (forall x. Public x => x -> y) -> y > public f = f Pike > > data Pike = Pike > instance Private Pike > instance Public Pike > > -------------------------------------- > > But if I don't tell 'em Pike, I've ensured that > blah can only be used in the argument to public. > > Or is there a hole? > > Cures youriously > > Conor > > _______________________________________________ > 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/20090717/0f220e96/attachment.html From ekmett at gmail.com Fri Jul 17 20:49:31 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Jul 17 20:31:15 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: References: Message-ID: <7fb8f82f0907171749k79570efdtaa281fe232d24cd9@mail.gmail.com> There is a Zip class in category-extras 's Control.Functor.Zip on hackage that covers this use-case. http://hackage.haskell.org/packages/archive/category-extras/latest/doc/html/Control-Functor-Zip.html It can basically be viewed as the ap of an Applicative functor chosen to be the left inverse of a genericly definable 'unzip'. Though, a Zippable functor isn't necessarily Applicative, because there is no reason it needs to support pure -- a lot of zippable functors are comonads after all. I wrote a short blog post on this: http://comonad.com/reader/2008/zipping-and-unzipping-functors/ and one on the less powerful dual operations (less powerful because while every Haskell Functor is strong, much fewer are costrong): http://comonad.com/reader/2008/cozipping/ -Edward Kmett On Thu, Jul 16, 2009 at 5:56 PM, Job Vranish wrote: > I was needing a way to zip generic data structures together today and was > very annoyed to find that there is no Zippable class, or variant there of. > > So I made my own: > > class (Foldable f, Functor f) => Zippable f where > fmaps :: (Foldable g) => g (a -> b) -> f a -> f b > fmaps' :: [a -> b] -> f a -> f b -- to save a step on instance > implementation > zipWith :: (a -> b -> c) -> f a -> f b -> f c > zip :: f a -> f b -> f (a, b) > unzip :: f (a, b) -> (f a, f b) > > fmaps fs a = fmaps' (toList fs) a > fmaps' fs a = fmaps fs a > zipWith f a b = fmaps (fmap f a) b > zip = zipWith (,) > unzip a = (fmap fst a, fmap snd a) > > instance Zippable [] where > fmaps' (fx:fs) (x:xs) = fx x : fmaps' fs xs > fmaps' _ _ = [] > > --The fmaps function is also quite handy as a replacment for zipWith3, > zipWith4, etc... > --For example: > > x = [1, 3, 5, 7, 3] > y = [6, 9, 3, 1, 4] > z = [2, 4, 0, 8, 2] > test = fmap (,,) x `fmaps` y `fmaps` z > -- > [(1,6,2),(3,9,4),(5,3,0),(7,1,8),(3,4,2)] > > --you can also throw in a functor instance to remove the dependency on the > Functor class, but it > -- might not be worth it: > instance (Zippable f) => Functor f where > fmap f a = fmaps (repeat f) a > > > Is there any good reason that there isn't something like this in the > standard libraries? Or, as far as I can tell, on hackage? > If not, then maybe I'll stick it on hackage. > > - Job Vranish > > > > _______________________________________________ > 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/20090717/eaee475b/attachment.html From jvlask at hotmail.com Fri Jul 17 20:56:11 2009 From: jvlask at hotmail.com (John Lask) Date: Fri Jul 17 20:41:14 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances References: <20090717191433.GA19514@pudlak.name> Message-ID: Can anyone explain the theoretical reason for this limitation, ie other than it is a syntactical restriction, what would it take to lift this restriction ? ----- Original Message ----- From: "Stefan Holdermans" To: "Petr Pudlak" Cc: Sent: Saturday, July 18, 2009 5:25 AM Subject: Re: [Haskell-cafe] an instance in other than the last type parameters > Petr, > >> If I want to make it a functor in the last type variable (b), I can just >> define >> >>> instance Functor (X a) where >>> fmap f (X a b) = X a (f b) >> >> But how do I write it if I want X to be a functor in its first type >> variable? > > Short answer: you can't. Easiest way to workaround is to define a newtype > wrapper around your original datatype: > > newtype X' b a = X' {unX' :: X a b} > > instance Functor (X' b) where > fmap g (X' (X a b)) = X' (X b (g a)) > > Cheers, > > Stefan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ekmett at gmail.com Fri Jul 17 21:11:56 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Jul 17 20:53:38 2009 Subject: [Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo? In-Reply-To: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> References: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> Message-ID: <7fb8f82f0907171811x36a9d99xf10765da20db3ea1@mail.gmail.com> Haskell hash tables are a notorious performance pig, mostly due to the fact that when we deal with big arrays, if the mutable array changes at all the garbage collector will have to retraverse the entire thing during the next collection. Guess the most common scenario for imperative hash tables that are even lightly tweaked from time to time... ;) As for other non-IO hash tables, I've seen a couple of unboxed hash tables using STUArrays (which can side step this issue for unboxable data), IIRC one may have even been used for a language shootout problem. I even wrote (a rather poorly performing) Witold Litwin-style sorted linear hash table for STM a couple of years back (it should still be on hackage under 'thash'). Data.HashTable could be easily reimplemented in ST s, but it would still suffer the same GC problems as the current hash table, which no one likes. -Ed On Fri, Jul 17, 2009 at 6:24 PM, Thomas Hartman wrote: > The code below is, I think, n log n, a few seconds on a million + element > list. > > I wonder if it's possible to get this down to O(N) by using a > hashtable implemementation, or other better data structure. > > Further, is there a hashtable implementation for haskell that doesn't > live in IO? Maybe in ST or something? > > import Data.HashTable > import qualified Data.Set as S > import Data.List (foldl') > > testdata = [1,4,8,9,20,11,20,14,2,15] ++ [1..(10^6)] > wantedsum = 29 > > -- set data structure > -- findsums locates pairs of integers in a list that add up to a > wanted sum. > findsums :: [Int] -> Int -> S.Set (Int,Int) > findsums xs wanted = snd . foldl' f (S.empty,S.empty) $ xs > where f (candidates,successes) next = if S.member (wanted-next) > candidates > then (candidates, S.insert > (next,wanted-next) successes) > else (S.insert next > candidates,successes) > > -- hashtable data structure > > > > -- result: t > -- fromList > [(15,14),(16,13),(17,12),(18,11),(19,10),(20,9),(21,8),(22,7),(23,6),(24,5),(25,4),(26,3),(27,2),(28,1)] > -- probably O(n log n) complexity since using tree based Data.Set (a > few seconds on million+ element list) > t = findsums testdata wantedsum > _______________________________________________ > 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/20090717/3f205f28/attachment.html From briqueabraque at yahoo.com Fri Jul 17 22:27:27 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Fri Jul 17 22:09:23 2009 Subject: [Haskell-cafe] Re: FFI to double constants, printf In-Reply-To: References: Message-ID: That helps, but: #include #include int main () { long double d = HUGE_VAL; printf("%.30Lf\n", d); } still prints just (as it should, I think): inf Is there maybe some way to check if a double or long double do have a "proper" value? > You probably want something like printf("%.10Lg",d);. Here's a shot C > example and its output: > > #include > > int main(int argc, char * argv[]) > { > long double d = 0.123456789; > > printf("%.30Lf\n", d); > printf("%.20Lg\n", d); > printf("%.20Le\n", d); > } > > /* > 0.123456788999999997336054491370 > 0.12345678899999999734 > 1.23456788999999997336e-01 > */ > > On Fri, Jul 17, 2009 at 6:41 PM, Maur??cio wrote: >> When we printf doubles from C (like when using hsc2hs to bind to a >> constant) we can get something that's not valid Haskell. See these >> 2 examples: >> >> 3.40282347e+38F >> >> inf >> >> Do you know some way to printf a double using printf (or any other >> standard function) that's always going to give me valid Haskell >> text, even in special cases? >> >> Thanks, >> Maur?cio >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From porges at porg.es Fri Jul 17 22:37:34 2009 From: porges at porg.es (porges@porg.es) Date: Fri Jul 17 22:19:30 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: <7fb8f82f0907171749k79570efdtaa281fe232d24cd9@mail.gmail.com> Message-ID: 2009/7/18 Edward Kmett : > I wrote a short blog post on this: > http://comonad.com/reader/2008/zipping-and-unzipping-functors/ > and one on the less powerful dual operations (less powerful because while > every Haskell Functor is strong, much fewer are costrong): > http://comonad.com/reader/2008/cozipping/ > -Edward Kmett This is getting a bit OT, but I just wanted to comment that attempting to remove polymorphism from the Functor class (see thread a couple of days ago) means that not every Functor is strong. So strength for Functor would seem to require a fully polymorphic type. I don't know if costrength is 'easier' to derive for those 'restricted' Functors... - George -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 908 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/1dff8300/signature.bin From allbery at ece.cmu.edu Fri Jul 17 22:39:35 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Jul 17 22:21:37 2009 Subject: [Haskell-cafe] Re: FFI to double constants, printf In-Reply-To: References: Message-ID: <850AEF5B-0A35-4720-A8A2-4055AD4EAF0B@ece.cmu.edu> On Jul 17, 2009, at 22:27 , Maur? cio wrote: > Is there maybe some way to check if a double or > long double do have a "proper" value? isNaN :: a -> Bool True if the argument is an IEEE "not-a-number" (NaN) value isInfinite :: a -> Bool True if the argument is an IEEE infinity or negative infinity isDenormalized :: a -> Bool True if the argument is too small to be represented in normalized format isNegativeZero :: a -> Bool True if the argument is an IEEE negative zero isIEEE :: a -> Bool True if the argument is an IEEE floating point number (in Prelude, even. Class RealFloat) -- 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/20090717/9170dcd4/PGP.bin From porges at porg.es Fri Jul 17 23:08:04 2009 From: porges at porg.es (porges@porg.es) Date: Fri Jul 17 22:49:51 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances In-Reply-To: Message-ID: [Ack, missed the reply-all button...] This was part of my motivation behind the 'removing polymorphism from Functor' thing... to select a different parameter we'd essentially need type-level lambdas... I'll use '?' (capital lambda) for it: instance Functor (? a. X a b) where fmap f (X a b) = X (f a) b We don't have these [1], but we *do* have type families, which are kind of like type-level lambdas turned 'inside out' (at least to my eyes), so my idea was to separate this out: type family Point :: * type instance Point (X a b) = a class Functor f where fmap :: (Point f -> Point f) -> f -> f Here I began to run into problems which are a bit irrelevant to this discussion :) [1]: I'm not sure of the exact connection, but see, e.g. Oleg's construction of computation at the type level (http://okmij.org/ftp/Haskell/TypeLC.lhs), wherein he notes the "primary role of type application rather than that of abstraction". - George -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 908 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/e22b84fd/signature.bin From ok at cs.otago.ac.nz Sat Jul 18 00:27:44 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sat Jul 18 00:10:03 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <200907171627.04589.g9ks157k@acme.softbase.org> References: <200907101044.52078.g9ks157k@acme.softbase.org> <20090707134239.0cdbc1c2@fedora> <200907171627.04589.g9ks157k@acme.softbase.org> Message-ID: <3AE2BF20-D9B1-4FD6-93AD-2EF4B2B127E6@cs.otago.ac.nz> On Jul 18, 2009, at 2:27 AM, Wolfgang Jeltsch wrote: > Probably just because British English took it from American English. > It?s > similar to the ?German? word ?Computer?. It?s not native. The spelling "program" goes back to 1633 at least; it cannot then have referred to computers, and is not likely to have been an American import. From ok at cs.otago.ac.nz Sat Jul 18 00:31:50 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sat Jul 18 00:14:06 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <200907171635.35039.g9ks157k@acme.softbase.org> References: <200907101044.52078.g9ks157k@acme.softbase.org> <200907171635.35039.g9ks157k@acme.softbase.org> Message-ID: <395F4290-383E-46A7-9C1D-557D1E5B8279@cs.otago.ac.nz> On Jul 18, 2009, at 2:35 AM, Wolfgang Jeltsch wrote: > So I should upload a package with German identifiers to Hackage? Sure, why not? The fact that I can't read it is my loss, not your fault, and there will be plenty of other German- reading Haskellers to benefit from it. I've happily worked with programs in French (not large ones (:-)). Mind you, I was specifically speaking of alternative *dialects* (English, Scots, American, Strine), not alternative *languages*. The library at this University contains books in a wide range of languages and is all the better for it; it would be as churlish as it would be foolish to say "English books only!" From ok at cs.otago.ac.nz Sat Jul 18 00:51:24 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sat Jul 18 00:33:10 2009 Subject: [Haskell-cafe] Pattern matching with where free variables can be used more than once In-Reply-To: <7f55268a0907171135j76e41da4h3036f04b85416dc3@mail.gmail.com> References: <7f55268a0907171135j76e41da4h3036f04b85416dc3@mail.gmail.com> Message-ID: <1F7CB4ED-3747-46B2-B26D-F4C1417BC7C3@cs.otago.ac.nz> On Jul 18, 2009, at 6:35 AM, Christopher Done wrote: [non-linear patterns] This kind of matching is provided in Prolog and Erlang. Neither of them lets the user define equality. We find the same issue with n+k patterns (e.g., n+1 as a pattern) l++r patterns (e.g., "prefix"++tail) (x,x) patterns (hidden ==) In each case, the question is "what if the Prelude's version of the explicit or implied function is not in scope?" (For n+k patterns, is the relevant function "+" or is it ">=" and "-"? For l++r patterns, is it "++", or "null", "head", and "tail"?) My preferred answer would be to say "the only functions in scope in a pattern are constructors; these aren't functions, they're syntax, and they always relate to the Prelude." The Haskell' community's preferred answer seems to be "avoid the question, ban the lot of them." It's fair to say that any such pattern _can_ be rewritten to something Haskell can handle; it's also fair to say that the result is often less readable, but that a rewrite may reduce the pain. From miguelimo38 at yandex.ru Sat Jul 18 02:51:26 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat Jul 18 02:33:09 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> Message-ID: <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> What is it for? Yes, you would know that only A and B are Public, but you have no way of telling that to the compiler. I usually prefer something like that: class Public x where blah :: ... isAB :: forall y. (A -> y) -> (B -> y) -> x -> y Both solutions, however, allow the user to declare some new instances when GeneralizedNewtypeDeriving is enabled. On 17 Jul 2009, at 19:38, Conor McBride wrote: > Friends > > Is closing a class this easy? > > -------------------------------------- > > module Moo > ( Public(..) > ) where > > class Private x => Public x where > blah :: ... > > class Private x where > > instance Private A where > instance Public A where > blah = ... > > instance Private B where > instance Public B where > blah = ... > > -------------------------------------- > > Modules importing Moo get Public and its instances, > but cannot add new ones: any such instances must be > accompanied by Private instances, and Private is > out of scope. > > Does this work? If not, why not? If so, is this well > known? > > It seems to be just what I need for a job I have in > mind. I want a class with nothing but hypothetical > instances. It seems like I could write > > -------------------------------------- > > module Noo > ( Public(..) > , public > ) where > > class Private x => Public x where > blah :: ... > blah = ... > > class Private x where > > public :: (forall x. Public x => x -> y) -> y > public f = f Pike > > data Pike = Pike > instance Private Pike > instance Public Pike > > -------------------------------------- > > But if I don't tell 'em Pike, I've ensured that > blah can only be used in the argument to public. > > Or is there a hole? > > Cures youriously > > Conor > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From miguelimo38 at yandex.ru Sat Jul 18 02:58:08 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat Jul 18 02:39:53 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> Message-ID: <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> Oops... Sorry, wrong line. Should be isAB :: forall p. p A -> p B -> p x On 18 Jul 2009, at 10:51, Miguel Mitrofanov wrote: > What is it for? Yes, you would know that only A and B are Public, > but you have no way of telling that to the compiler. > > I usually prefer something like that: > > class Public x where > blah :: ... > isAB :: forall y. (A -> y) -> (B -> y) -> x -> y > > Both solutions, however, allow the user to declare some new > instances when GeneralizedNewtypeDeriving is enabled. > > On 17 Jul 2009, at 19:38, Conor McBride wrote: > >> Friends >> >> Is closing a class this easy? >> >> -------------------------------------- >> >> module Moo >> ( Public(..) >> ) where >> >> class Private x => Public x where >> blah :: ... >> >> class Private x where >> >> instance Private A where >> instance Public A where >> blah = ... >> >> instance Private B where >> instance Public B where >> blah = ... >> >> -------------------------------------- >> >> Modules importing Moo get Public and its instances, >> but cannot add new ones: any such instances must be >> accompanied by Private instances, and Private is >> out of scope. >> >> Does this work? If not, why not? If so, is this well >> known? >> >> It seems to be just what I need for a job I have in >> mind. I want a class with nothing but hypothetical >> instances. It seems like I could write >> >> -------------------------------------- >> >> module Noo >> ( Public(..) >> , public >> ) where >> >> class Private x => Public x where >> blah :: ... >> blah = ... >> >> class Private x where >> >> public :: (forall x. Public x => x -> y) -> y >> public f = f Pike >> >> data Pike = Pike >> instance Private Pike >> instance Public Pike >> >> -------------------------------------- >> >> But if I don't tell 'em Pike, I've ensured that >> blah can only be used in the argument to public. >> >> Or is there a hole? >> >> Cures youriously >> >> Conor >> >> _______________________________________________ >> 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 pumpkingod at gmail.com Sat Jul 18 03:57:12 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Sat Jul 18 03:38:54 2009 Subject: [Haskell-cafe] Importance of identity element in finger trees? Message-ID: Hi all, I was looking at finger trees and the tricks for getting priority queues out of them seemed a little hackish, with a distinguished infinity element or maxBound. But it seems (although I have not yet tried it) like in many cases the monoid's identity element wouldn't be necessary (a bit like the difference between fold* and fold*1). Could a finger tree be applied to an arbitrary semigroup? Or is the identity more fundamental than it looks? Thanks, Dan From conor at strictlypositive.org Sat Jul 18 04:30:55 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat Jul 18 04:12:38 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> Message-ID: Hi Miguel On 18 Jul 2009, at 07:58, Miguel Mitrofanov wrote: > Oops... Sorry, wrong line. Should be > > isAB :: forall p. p A -> p B -> p x Yep, dependent case analysis, the stuff of my thesis,... > On 18 Jul 2009, at 10:51, Miguel Mitrofanov wrote: > >> What is it for? I have a different purpose in mind. I want to write localize :: (forall a. Equipment a => Abstract a) -> Concrete rather than localize :: (forall a. F1 a -> ... -> Fn a -> Abstract a) -> Concrete so I can use the type class machinery to pass around the dictionaries of equipment. I want to make sure that nobody else gets the equipment. It's possible that I don't need to be so extreme: it's enough that there's no other way to use Abstracts than via localize. >> Yes, you would know that only A and B are Public, but you have no >> way of telling that to the compiler. >> >> I usually prefer something like that: >> >> class Public x where >> blah :: ... >> isAB :: forall y. (A -> y) -> (B -> y) -> x -> y But now I can write bogus instances of Public with genuine implementations of blah and wicked lies for isAB. It is important to use the dependent version, otherwise I might have instance Public (A, B) where isAB af bf (a, b) = af a and lots more, without even lying. >> Both solutions, however, allow the user to declare some new >> instances when GeneralizedNewtypeDeriving is enabled. I'm scared. What about this? data EQ :: * -> * -> * where Refl :: EQ x x class Public x where blah :: EQ x Fred instance Public Fred where blah = Refl What happens when I say newtype Jim = Hide Fred deriving Public ? I tried it. I get blah :: EQ Jim Fred It's clear that GeneralizedNewtypeDeriving goes too far. I hope a class with *no* instances in public has no newtype leak! Fun stuff. Cheers Conor From stefan at cs.uu.nl Sat Jul 18 04:42:59 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Sat Jul 18 04:24:42 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> Message-ID: <952A6074-9CAA-46D7-BB07-783F0FC70DFC@cs.uu.nl> Conor, > I'm scared. What about this? > > data EQ :: * -> * -> * where > Refl :: EQ x x > > class Public x where > blah :: EQ x Fred > > instance Public Fred where > blah = Refl > > What happens when I say > > newtype Jim = Hide Fred deriving Public > > ? I tried it. I get > > blah :: EQ Jim Fred > > It's clear that GeneralizedNewtypeDeriving goes too far. Now, I am scared. This should be regarded as a bug in generalised newtype deriving, shouldn't it? I would expect newtype deriving to be unable to come up with instances that cannot be written by hand. I would have expected people out on the streets marching to GHC headquarters by now; how can you stay so calm? Cheers, Stefan From conor at strictlypositive.org Sat Jul 18 04:51:02 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat Jul 18 04:32:44 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: <3F5D6086-6433-4BF7-B0A5-4457BDAC9F86@gmail.com> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <3F5D6086-6433-4BF7-B0A5-4457BDAC9F86@gmail.com> Message-ID: <3A7F7575-3264-47F5-8528-85FDA6913772@strictlypositive.org> On 18 Jul 2009, at 01:43, Lennart Augustsson wrote: > As far as I know it works. It's an old Oleg trick. Then it probably does work. > The only drawback is that error messages may refer to Private. As I found out when probing its security. "No instance for Moo.Private" shows up. I guess that's what happens when you hide stuff: you get told what stuff's being hidden. In some situations, that's insecure, but here it's ok. Cheers (and have fun in China, Lennart!) Conor From jon.fairbairn at cl.cam.ac.uk Sat Jul 18 04:57:49 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sat Jul 18 04:39:48 2009 Subject: [Haskell-cafe] Re: Debugging methods for haskell References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Message-ID: Henning Thielemann writes: > On Thu, 16 Jul 2009, Fernan Bolando wrote: > >> Hi all >> >> I recently used 2 hours of work looking for a bug that was causing >> >> Program error: Prelude.!!: index too large > > A good way to avoid such problems is to avoid partial > functions at all. (!!) is also inefficient. Is it possible > to define the function in terms of foldl? I've looked at the code a bit more, and, with apologies to the original poster, it doesn't look much like Haskell. For example, in there's stuff beginning with tADM :: Int tADM = 1 tVSRC :: Int tVSRC = 2 tISRC :: Int tISRC = 3 ... that I think probably should be data Something = ADM | VSRC | ISRC ... deriving (Enum, ...) though when I get to "(((fst z0)!!pMSET)!!pMTYPE) == mOP" I'm at a loss to determine quite what the intention is. Maybe it should be an array indexed by enum types, maybe a function, maybe something that can be pattern matched on? I don't know. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From andrewcoppin at btinternet.com Sat Jul 18 05:04:41 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jul 18 04:46:25 2009 Subject: [Haskell-cafe] Plot data reconstruction reading pixel colors from image files In-Reply-To: <4A60FA53.60407@henning-thielemann.de> References: <1ff5dedc0907170931x63620a6cy72d85db5e6120fb2@mail.gmail.com> <20090717172400.GA21826@kira.casa> <4A60FA53.60407@henning-thielemann.de> Message-ID: <4A619029.5080902@btinternet.com> Henning Thielemann wrote: > Felipe Lessa schrieb: > >> On Fri, Jul 17, 2009 at 06:31:20PM +0200, Cetin Sert wrote: >> >>> How can I open and read colors of specific pixels of an image file in >>> Haskell? Which packages, functions do you recommend? >>> >> You could try DevIL, SDL-image or Gtk, I guess. >> > > Perhaps > http://hackage.haskell.org/package/pgm > This is (one of) the problems that AC-EasyRaster is supposed to make easy. (AC-EasyRaster is just is a convinience binding over the top of Gtk2hs... Makes it easier to find the stuff you're actually looking for. Hopefully.) From vigalchin at gmail.com Sat Jul 18 05:17:37 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat Jul 18 04:59:19 2009 Subject: [Haskell-cafe] cabal version issue Message-ID: <5ae4f2ba0907180217n50057cccp6791fdb77d88c3f9@mail.gmail.com> Hello, vigalchin@ubuntu:~/FTP/Haskell/06052009.Swish-0.2.1$ cabal --version cabal-install version 0.5.1 using version 1.4.0.1 of the Cabal library vigalchin@ubuntu:~/FTP/Haskell/Swish-0.2.1$ cabal configure --user --prefix=$HOME Warning: swish.cabal: A package using section syntax should require "Cabal-Version: >= 1.2" or equivalent. Warning: swish.cabal: A package using section syntax should require "Cabal-Version: >= 1.2" or equivalent. What is the "Cabal-Version" in the latter? Why I am getting this warning? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090718/01f990f4/attachment.html From g9ks157k at acme.softbase.org Sat Jul 18 05:26:00 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sat Jul 18 05:07:44 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <395F4290-383E-46A7-9C1D-557D1E5B8279@cs.otago.ac.nz> References: <200907171635.35039.g9ks157k@acme.softbase.org> <395F4290-383E-46A7-9C1D-557D1E5B8279@cs.otago.ac.nz> Message-ID: <200907181126.00302.g9ks157k@acme.softbase.org> Am Samstag, 18. Juli 2009 06:31 schrieben Sie: > On Jul 18, 2009, at 2:35 AM, Wolfgang Jeltsch wrote: > > So I should upload a package with German identifiers to Hackage? > > Sure, why not? The fact that I can't read it is my loss, not your fault, > and there will be plenty of other German-reading Haskellers to benefit from > it. I've happily worked with programs in French (not large ones (:-)). I don?t think, it?s a good idea to have German identifiers, since Haskell?s keywords are English. On the other hand, I strongly argue that a library about B?zier curves uses the identifier B?zier, not Bezier. So non-ASCII identifiers are useful even if identifiers are in English. Best wishes, Wolfgang From thaldyron at gmail.com Sat Jul 18 05:36:33 2009 From: thaldyron at gmail.com (Peter Robinson) Date: Sat Jul 18 05:18:35 2009 Subject: [Haskell-cafe] catchSTM and asynchronous exceptions Message-ID: I couldn't find any information on whether catchSTM catches asynchronous exceptions so I tried to run the following: import Control.Concurrent.STM import Control.Concurrent import Control.Exception import Prelude hiding (catch) test = do tid <- myThreadId forkIO (threadDelay 5000000 >> throwTo tid (AssertionFailed "Exception in forked thread!")) (atomically $ retry `catchSTM` stmHandler) `catch` (ioHandler tid) where stmHandler (e::SomeException) = throw $ AssertionFailed ("Caught Exc. in STM; Rethrowing exception: "++ show e) ioHandler tid (e::SomeException) = print (tid,"Caught Exception in IO: ",e) Yielding the following output: # (ThreadId 6942,"Caught Exception in IO: ",Exception in forked thread!) Apparently the exception is caught by "catch" and not by "catchSTM". So the point is that catchSTM is only meant to be used for non-async exceptions, right? Regards, Peter From conor at strictlypositive.org Sat Jul 18 05:43:09 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat Jul 18 05:24:51 2009 Subject: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy? In-Reply-To: <952A6074-9CAA-46D7-BB07-783F0FC70DFC@cs.uu.nl> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> <952A6074-9CAA-46D7-BB07-783F0FC70DFC@cs.uu.nl> Message-ID: <5815F3A8-5032-489A-A4CA-1E7B56437D27@strictlypositive.org> Hi Stefan On 18 Jul 2009, at 09:42, Stefan Holdermans wrote: > Conor, > >> >> What happens when I say >> >> newtype Jim = Hide Fred deriving Public >> >> ? I tried it. I get >> >> blah :: EQ Jim Fred >> >> It's clear that GeneralizedNewtypeDeriving goes too far. > > Now, I am scared. This should be regarded as a bug in generalised > newtype deriving, shouldn't it? I would expect newtype deriving to > be unable to come up with instances that cannot be written by hand. I think the latter is a useful general principle for "deriving". The trouble here is that somewhere along the line (GADTs? earlier?) it became possible to construct candidates for p :: * -> * which don't respect isomorphism. These tend to be somewhat intensional in nature, and they mess up the transfer of functionality. If we could be sure that all such a p would do with its parameter (x, say) is trade in values of x (as opposed to trading in the identity of x), then we could be sure that p respects isomorphisms. I'm hoping that a category theorist will say something about dinaturality at this point, because I'd like to understand that stuff. I wonder if there's a potential refinement of the kind system lurking here, distinguishing *, types-up-to-iso, from |*|, types-up-to-identity. That might help us to detect classes for which newtype deriving is inappropriate: GADTs get indexed over |*|, not *; classes of *s are derivable, but classes of |*|s are not. I certainly don't have a clear proposal just now. It looks like an important distinction: recognizing it somehow might buy us something. > I would have expected people out on the streets marching to GHC > headquarters by now; how can you stay so calm? GHC HQ are up to their armpits in newtypes already. This distinction between type equality and (trivial) type isomorphism is something they're already facing. I don't know if they've solved this problem yet, but I suspect they're in the area. No need for a commotion. All the best Conor From matthias.goergens at googlemail.com Sat Jul 18 05:50:32 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Jul 18 05:32:33 2009 Subject: [Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo? In-Reply-To: <7fb8f82f0907171811x36a9d99xf10765da20db3ea1@mail.gmail.com> References: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> <7fb8f82f0907171811x36a9d99xf10765da20db3ea1@mail.gmail.com> Message-ID: However you can use the wider idea of hashing: A nesting of two finite maps. One fast, but approximative map. And one slow, but exact map. The quintessential example is an array indexed with some hash function for the first map. And linked lists of (key,value) pairs as the latter. In Haskell you might want to use IntMap and a the mentioned list of pairs (combined with the lookup functions from Data.List). Of course you need to supply a function to hash your keys to Int for the IntMap. From ross at soi.city.ac.uk Sat Jul 18 06:04:10 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Sat Jul 18 05:45:54 2009 Subject: [Haskell-cafe] Importance of identity element in finger trees? In-Reply-To: References: Message-ID: <20090718100410.GA7332@soi.city.ac.uk> On Sat, Jul 18, 2009 at 03:57:12AM -0400, Daniel Peebles wrote: > I was looking at finger trees and the tricks for getting priority > queues out of them seemed a little hackish, with a distinguished > infinity element or maxBound. But it seems (although I have not yet > tried it) like in many cases the monoid's identity element wouldn't be > necessary (a bit like the difference between fold* and fold*1). Could > a finger tree be applied to an arbitrary semigroup? Or is the identity > more fundamental than it looks? Two answers: 1) It can be applied to an arbitrary semigroup, because you can always turn that into a monoid by adding an identity element. 2) It suffices to have an associative operation with a left identity (exercise 7 in the paper). But an identity is still needed, as the measure of the empty tree. You could special case that, but it would be equivalent to 1) above. From bulat.ziganshin at gmail.com Sat Jul 18 06:16:49 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jul 18 06:03:07 2009 Subject: [Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo? In-Reply-To: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> References: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> Message-ID: <565557226.20090718141649@gmail.com> Hello Thomas, Saturday, July 18, 2009, 2:24:21 AM, you wrote: > Further, is there a hashtable implementation for haskell that doesn't > live in IO? Maybe in ST or something? import Prelude hiding (lookup) import qualified Data.HashTable import Data.Array import qualified Data.List as List data HT a b = HT (a->Int) (Array Int [(a,b)]) -- size is the size of array (we implement a closed hash) -- hash is the hash function (a->Int) -- list is assoclist of items to put in hash create size hash list = HT hashfunc (accumArray (flip (:)) [] (0, arrsize-1) (map (\(a,b) -> (hashfunc a,(a,b))) list) ) where arrsize = head$ filter (>size)$ iterate (\x->3*x+1) 1 hashfunc a = hash a `mod` arrsize lookup a (HT hash arr) = List.lookup a (arr!hash a) main = do let assoclist = [("one", 1), ("two", 2), ("three", 3)] hash = create 10 (fromEnum . Data.HashTable.hashString) assoclist print (lookup "one" hash) print (lookup "zero" hash) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From miguelimo38 at yandex.ru Sat Jul 18 06:26:31 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat Jul 18 06:08:24 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <200907181126.00302.g9ks157k@acme.softbase.org> References: <200907171635.35039.g9ks157k@acme.softbase.org> <395F4290-383E-46A7-9C1D-557D1E5B8279@cs.otago.ac.nz> <200907181126.00302.g9ks157k@acme.softbase.org> Message-ID: <1394D19C-0DC8-4010-84E4-15BB1FD2EE27@yandex.ru> On 18 Jul 2009, at 13:26, Wolfgang Jeltsch wrote: > Am Samstag, 18. Juli 2009 06:31 schrieben Sie: >> On Jul 18, 2009, at 2:35 AM, Wolfgang Jeltsch wrote: >>> So I should upload a package with German identifiers to Hackage? >> >> Sure, why not? The fact that I can't read it is my loss, not your >> fault, >> and there will be plenty of other German-reading Haskellers to >> benefit from >> it. I've happily worked with programs in French (not large ones >> (:-)). > > I don?t think, it?s a good idea to have German identifiers, since > Haskell?s > keywords are English. On the other hand, I strongly argue that a > library > about B?zier curves uses the identifier B?zier, not Bezier. So non- > ASCII > identifiers are useful even if identifiers are in English.\ And I think that a library about Dynkin diagrams should use the identifier "Dynkin", not "??????". From sjoerd at w3future.com Sat Jul 18 06:28:51 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Sat Jul 18 06:10:39 2009 Subject: [Haskell-cafe] cabal version issue In-Reply-To: <5ae4f2ba0907180217n50057cccp6791fdb77d88c3f9@mail.gmail.com> References: <5ae4f2ba0907180217n50057cccp6791fdb77d88c3f9@mail.gmail.com> Message-ID: The message means that the .cabal file should contain the line "Cabal- Version: >= 1.2" Sjoerd On Jul 18, 2009, at 11:17 AM, Vasili I. Galchin wrote: > Hello, > > vigalchin@ubuntu:~/FTP/Haskell/06052009.Swish-0.2.1$ cabal --version > cabal-install version 0.5.1 > using version 1.4.0.1 of the Cabal library > > vigalchin@ubuntu:~/FTP/Haskell/Swish-0.2.1$ cabal configure --user -- > prefix=$HOME > Warning: swish.cabal: A package using section syntax should require > "Cabal-Version: >= 1.2" or equivalent. > Warning: swish.cabal: A package using section syntax should require > "Cabal-Version: >= 1.2" or equivalent. > > What is the "Cabal-Version" in the latter? Why I am getting this > warning? > > Thanks, Vasili > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From stefan at cs.uu.nl Sat Jul 18 08:16:16 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Sat Jul 18 07:57:59 2009 Subject: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy? In-Reply-To: <5815F3A8-5032-489A-A4CA-1E7B56437D27@strictlypositive.org> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> <952A6074-9CAA-46D7-BB07-783F0FC70DFC@cs.uu.nl> <5815F3A8-5032-489A-A4CA-1E7B56437D27@strictlypositive.org> Message-ID: Conor, >>> What happens when I say >>> >>> newtype Jim = Hide Fred deriving Public >>> >>> ? I tried it. I get >>> >>> blah :: EQ Jim Fred Thinking of it; this *does* make sense in System FC. The newtype- declaration gives you as an axiom Hide :: Jim ~ Fred To give an instance of Public for Jim, we have to provide blah :: EQ Jim Fred which, with Refl :: forall (a :: *) (b :: *). (a ~ b) => EQ a b can be given straightforwardly as blah = Refl {Jim, Fred, Hide} So, the problem, if any, is that the System FC-encoding of newtypes renders them into "guarded" type equalities, rather than proper type isomorphisms. (Or, the other way around, reduces ~ to type isomorphism rather than type equality.) > I wonder if there's a potential refinement of the kind system lurking > here, distinguishing *, types-up-to-iso, from |*|, types-up-to- > identity. > That might help us to detect classes for which newtype deriving is > inappropriate: GADTs get indexed over |*|, not *; classes of *s are > derivable, but classes of |*|s are not. I certainly don't have a clear > proposal just now. It looks like an important distinction: recognizing > it somehow might buy us something. That seems a promising approach. We would then have Jim :: * Fred :: * EQ :: |*| -> |*| -> * Hide :: Jim ~ Fred Refl :: forall (a :: |*|) (b :: |*|). (a ~ b) => EQ a b and (I guess) a type-level operation that allows you to lift every type T :: * into |T| :: |*|. Then we have, blahFred = Refl {|Fred|, |Fred|, |Fred|} which make sense, given that |*| :: TY, but both blahJim = Refl {Jim, Fred, Hide} and blahJim' = Refl {|Jim|, |Fred|, Hide} and variations thereof would be ill-kinded, as desired. And, indeed, generalised newtype deriving should then only make sense for *-indexed classes. I think this would work. Cheers, Stefan From g9ks157k at acme.softbase.org Sat Jul 18 08:42:14 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sat Jul 18 08:24:19 2009 Subject: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy? In-Reply-To: <5815F3A8-5032-489A-A4CA-1E7B56437D27@strictlypositive.org> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <952A6074-9CAA-46D7-BB07-783F0FC70DFC@cs.uu.nl> <5815F3A8-5032-489A-A4CA-1E7B56437D27@strictlypositive.org> Message-ID: <200907181442.15426.g9ks157k@acme.softbase.org> Am Samstag, 18. Juli 2009 11:43 schrieb Conor McBride: > The trouble here is that somewhere along the line (GADTs? earlier?) > it became possible to construct candidates for p :: * -> * which don't > respect isomorphism. Hello Conor, I?m not sure whether I exactly understand what you mean here. I think, it?s the following: Say, you have a type A and define a type B as follows: newtype B = B A Then, for any p :: * -> *, the type p A should be isomorphic to p B, i.e., it should basically contain the same values. This is no longer true with GADTs since you can define something like this: data GADT a where GADT :: GADT A Now, GADT :: GADT A but not GADT :: GADT B. Is this what you mean? > These tend to be somewhat intensional in nature, and they mess up the > transfer of functionality. Could you maybe elaborate on this? Best wishes, Wolfgang From ithika at gmail.com Sat Jul 18 08:47:27 2009 From: ithika at gmail.com (Dougal Stanton) Date: Sat Jul 18 08:29:08 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> Message-ID: <2d3641330907180547k16e00cdva4ad31103d2b4ae7@mail.gmail.com> On Fri, Jul 17, 2009 at 4:38 PM, Conor McBride wrote: > class Private x where > > public :: (forall x. Public x => x -> y) -> y > public f = f Pike > > data Pike = Pike > instance Private Pike > instance Public Pike > > -------------------------------------- > > But if I don't tell 'em Pike, I've ensured that > blah can only be used in the argument to public. Well I appreciated this bit even if no-one else did! :-) Also, that's a nifty trick if it works! D From g9ks157k at acme.softbase.org Sat Jul 18 08:49:14 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sat Jul 18 08:30:58 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> Message-ID: <200907181449.14474.g9ks157k@acme.softbase.org> Am Samstag, 18. Juli 2009 08:58 schrieb Miguel Mitrofanov: > Oops... Sorry, wrong line. Should be > > isAB :: forall p. p A -> p B -> p x Is this a well-known approach for closing classes? I came across the same idea and implemented a generic framework for closing classes in this way. I did this to simulate algebraic data kinds and kind polymorphism over such kinds. I needed this for the record system of Grapefruit. The code is here: Explaination of the techniques used in this code will probably follow as part of an IFL 2009 paper. Now I wonder which of my ideas are actually new and which are just old hat. Could you maybe answer this question? Best wishes, Wolfgang From fernanbolando at mailc.net Sat Jul 18 09:23:02 2009 From: fernanbolando at mailc.net (Fernan Bolando) Date: Sat Jul 18 09:04:43 2009 Subject: [Haskell-cafe] Re: Debugging methods for haskell In-Reply-To: References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> Message-ID: <1d5d51400907180623m59b48320o2159fd7703829be0@mail.gmail.com> On Sat, Jul 18, 2009 at 4:57 PM, Jon Fairbairn wrote: > Henning Thielemann writes: > >> On Thu, 16 Jul 2009, Fernan Bolando wrote: >> >>> Hi all >>> >>> I recently used 2 hours of work looking for a bug that was causing >>> >>> Program error: Prelude.!!: index too large >> >> A good way to avoid such problems is to avoid partial >> functions at all. (!!) is also inefficient. Is it possible >> to define the function in terms of foldl? > > I've looked at the code a bit more, and, with apologies to the original > poster, it doesn't look much like Haskell. For example, in > > there's stuff beginning with > > ? tADM :: Int > ? tADM = 1 > > ? tVSRC :: Int > ? tVSRC = 2 > > ? tISRC :: Int > ? tISRC = 3 > > ? ... > > that I think probably should be > > ? data Something = ADM | VSRC | ISRC ... deriving (Enum, ...) > > though when I get to "(((fst z0)!!pMSET)!!pMTYPE) == mOP" I'm at a loss > to determine quite what the intention is. Maybe it should be an array > indexed by enum types, maybe a function, maybe something that can be > pattern matched on? I don't know. The intention is z0 is a system parameter and database, it contains a set of info needed to define a particular simulation it looks like ( [n,m...], [m,o,p]) n is is a list info settings for the circuit analysis m is a list of statistics for the circuits that is need in sub-sequent calculation m is a list of circuit settings like temperature etc. o is a list of matrix solution for non-linear newton raphson p is a list of matrix solution for time dependent calculations the bug was in o this is a variable length [Double] whose length depends on the size of matrix bieng solved. so. (((fst z0)!!pMSET)!!pMTYPE) == mOP is checking if we are doing mOP type calculations. If this was C this would be a structure of settings and buffer data. fernan -- http://www.fernski.com From conor at strictlypositive.org Sat Jul 18 09:57:57 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat Jul 18 09:39:40 2009 Subject: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy? In-Reply-To: <200907181442.15426.g9ks157k@acme.softbase.org> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <952A6074-9CAA-46D7-BB07-783F0FC70DFC@cs.uu.nl> <5815F3A8-5032-489A-A4CA-1E7B56437D27@strictlypositive.org> <200907181442.15426.g9ks157k@acme.softbase.org> Message-ID: <0674D4E4-9EEB-465C-A45A-8EB45109DE84@strictlypositive.org> Hi Wolfgang On 18 Jul 2009, at 13:42, Wolfgang Jeltsch wrote: > Am Samstag, 18. Juli 2009 11:43 schrieb Conor McBride: >> The trouble here is that somewhere along the line (GADTs? earlier?) >> it became possible to construct candidates for p :: * -> * which >> don't >> respect isomorphism. > > Hello Conor, > > I?m not sure whether I exactly understand what you mean here. I > think, it?s > the following: > > Say, you have a type A and define a type B as follows: > > newtype B = B A > > Then, for any p :: * -> *, the type p A should be isomorphic to p B, > i.e., it > should basically contain the same values. This is no longer true > with GADTs > since you can define something like this: > > data GADT a where > > GADT :: GADT A > > Now, GADT :: GADT A but not GADT :: GADT B. > > Is this what you mean? Yes, that's what I mean. >> These tend to be somewhat intensional in nature, and they mess up the >> transfer of functionality. > > Could you maybe elaborate on this? Just as you've shown, we can use GADTs to express a p such that p A is inhabited but p B is not(*) Moreover, we can write type families which make TF A = IO String TF B = String so it'd be better not to get A and B confused. But all of these nasties rely on taking an intensional view of types as pieces of syntax, rather than the extensional view of types as sets of values. Predicates (to use a Curry-Howardism) which rely only on the extensional properties of types can be relied upon to respect isomorphism, and indeed to respect trivial isomorphisms trivially. (You can refine this to *inclusion* if you pay attention to co/contra-variance. This would give us inflate :: Functor f => f Void -> f x as a no-op.) Your GADT is an intensional predicate --- "being A", rather than "having the values of A" --- so it respects fewer equations. Consider a type expression t[x], over a free type variable x. Suppose you have some f :: a -> b and g :: b -> a. For the most part, you can use these to construct t[f,g> :: t[a] -> t[b] and hence t[g,f> :: t[b] -> t[a] by recursion on the structure of t. E.g,, x[f, g> = f Bool[f, g> = id (s -> t)[f, g> = \ h -> t[f,g> . h . s[g,f> ... You'll find that t[id,id> = id. But you'll get stuck at GADTs and type families. Functions both ways don't give you enough information: you need equality (same objects, different morphisms). Type classes are predicates: "supporting a dictionary". If they happen to be extensional predicates, then they should support newtype deriving. Can we draw out this distinction somehow? Interesting place to go... Cheers Conor (*) usual caveats for bottom spotters From ivan.miljenovic at gmail.com Sat Jul 18 10:23:07 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Sat Jul 18 10:04:53 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.0.0.0 Message-ID: <87ljmm9ik4.fsf@gmail.com> I am pleased to announce a new release of the graphviz package for Haskell, which provides bindings to the GraphViz [1] suite of tools. [1] http://www.graphviz.org/ Probably the biggest and most important change in this release is that AFAICT, all 152 attributes utilised/supported by GraphViz [2] are now specified and supported by this library. However, I'm not fully sure how well the parsing of these attributes will turn out; if you notice a bug/problem then please let me know. [2] http://graphviz.org/doc/info/attrs.html I've specified this as being the first in the 2999.0 series of releases. I will switch to 3000.0 when the generic graph class has been released and graphviz switched to using it rather than just FGL. One other future change that I'm considering is to improve the parsing ability of the Dot language. At the moment, graphviz assumes the following layout is followed: * Graph attributes * Nodes with their attributes (clusters are supported only for creation, not parsing). * Edges with their attributes. To match the behaviour of upstream, this will need to be changed into just a list of statements, where a statement is one of five things [3]: * A Node * An Edge * An attribute (either for the graph overall, nodes or for edges) * "ID '=' ID" (not quite sure what this is; some kind of assignment) * A subgraph (clusters are a specific type of subraph) As the way of defining an attribute for a specific grouping of nodes/edges/subgraphs is to have them all listed after the attribute definition (whereas those beforehand do not have this attribute), the imperative nature of the Dot language does not allow us to split these statements up as we currently do. [3] http://graphviz.org/doc/info/lang.html As such, I'm asking which of the following two choices people would prefer: 1. Follow upstream so that it can fully parse a Dot graph 2. Keep it as it is, so that it is possible to consider all edges, etc. easily. Other major changes to this release: ==================================== * Fixed a bug where the Show instance and read function for DotEdge had the from/to nodes the wrong way round. This was not immediately noticed since the Graph -> DotGraph functions created them the wrong way round, so for those users who only used these this was not apparent. Spotted by Neil Brown. * Greatly improved Attribute usage: almost all attributes are now covered with allowed values. * Extend DotGraph to include whether a graph is strict or not and if it has an ID. Also move the directedGraph field. * Make "Dot" refer to the actual dot command and DotArrow refer to the ArrowType (rather than DotCmd and Dot as before). * Make the Data.GraphViz.ParserCombinators module available to end users again, but not re-exported by Data.GraphViz; it has a warning message up the top not to be used. It is there purely for documentative purposes. * Use extensible-exceptions so that base < 4 is once again supported. * Follow the PVP rather than using dates for versions: http://www.haskell.org/haskellwiki/Package_versioning_policy Note that this means that any library/application using more than a trivial sub-set of graphviz will most likely need to be updated. However, now that the PVP is being followed it should be easier to tell in future when updates will be required. Other items I'm wanting to do in future releases: ================================================= * Allow user to choose whether or not the graph is meant to be directed or undirected. * Improve parsing to fully (or at least follow more closely) support Dot. * Improve clustering/subgraph support. * Use a PrettyPrinter rather than Show to generate Dot output. * Improve Output support. * Find and fix the handle closing bug with graphvizWithHandle. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From tphyahoo at gmail.com Sat Jul 18 11:23:10 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Jul 18 11:04:52 2009 Subject: [Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo? In-Reply-To: <565557226.20090718141649@gmail.com> References: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> <565557226.20090718141649@gmail.com> Message-ID: <910ddf450907180823s68902889i758489ec80bb5bb1@mail.gmail.com> Thanks Bulat. FWIW, i take it that http://www.haskell.org/haskellwiki/Shootout/Knucleotide is what Edward was referring to, with the shootouts. It seems that a lot of progress has been made but not much has been migrated back to hackage. Going back to my original question, I am now looking for a dead simple motivating example for showing the example of using a (good) hashtable over Data.Map, with a tangible demo of O(n) over O(n log n) running times. I mean, something where running an input of (10^4) size versus (10^6) size shows a noticeably laggier run when using Set versus hashtable. I don't think maybe my original example quite qualifies because I think in practice the computation is dominated by space complexity. However, I haven't yet ported it over to a hashtable version, so not sure. (And the shootout example doesn't satisfy my sense of "dead simple.") 2009/7/18 Bulat Ziganshin : > Hello Thomas, > > Saturday, July 18, 2009, 2:24:21 AM, you wrote: > >> Further, is there a hashtable implementation for haskell that doesn't >> live in IO? Maybe in ST or something? > > import Prelude hiding (lookup) > import qualified Data.HashTable > import Data.Array > import qualified Data.List as List > > > data HT a b = HT (a->Int) (Array Int [(a,b)]) > > -- size is the size of array (we implement a closed hash) > -- hash is the hash function (a->Int) > -- list is assoclist of items to put in hash > create size hash list = HT hashfunc > ? ? ? ? ? ? ? ? ? ? ? ? ? (accumArray (flip (:)) > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [] > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (0, arrsize-1) > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (map (\(a,b) -> (hashfunc a,(a,b))) list) > ? ? ? ? ? ? ? ? ? ? ? ? ? ) > > ?where arrsize ? ? = ?head$ filter (>size)$ iterate (\x->3*x+1) 1 > ? ? ? ?hashfunc a ?= ?hash a `mod` arrsize > > > lookup a (HT hash arr) = List.lookup a (arr!hash a) > > > main = do let assoclist = [("one", 1), ("two", 2), ("three", 3)] > ? ? ? ? ? ? ?hash = create 10 (fromEnum . Data.HashTable.hashString) assoclist > ? ? ? ? ?print (lookup "one" hash) > ? ? ? ? ?print (lookup "zero" hash) > > > -- > Best regards, > ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com > > From byorgey at seas.upenn.edu Sat Jul 18 11:23:29 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Jul 18 11:05:12 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 126 - July 18, 2009 Message-ID: <20090718152329.GA16388@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090718 Issue 126 - July 18, 2009 --------------------------------------------------------------------------- Welcome to issue 126 of HWN, a newsletter covering developments in the [1]Haskell community. [2]Hac phi is next weekend! With almost 30 people already registered, it looks like we're going to have a fantastic time hacking in Philadelphia. It's still not too late to [3]register! Announcements GHC 6.10.4. Ian Lynagh [4]announced a new patchlevel release of GHC, 6.10.4. This version has very few changes over 6.10.3, but fixes some bugs that could be critical for a few users. See the [5]release notes for details. shelltestrunner 0.6 released. Simon Michael [6]announced the first release of [7]shelltestrunner, a small tool for testing any command-line program by running it through "shell" tests defined with a simple file format. generator 0.5.1. Yair Chuchem [8]announced the release of the [9]generator package, which implements an alternative list monad transformer, a list class, and related functions. GLURaw 1.0.0.0. Sven Panne [10]announced a new [11]GLURaw package, containing full support for all GLU functionality and similar in spirit to the OpenGLRaw package: it is a 1:1 mapping of the C interface, no libraries or headers are needed at build time, and the GLU API entries are resolved dynamically at runtime. OpenGLRaw 1.0.1.0. Sven Panne [12]announced a new version of the [13]OpenGLRaw package, which adds support for a number of OpenGL extensions. ObjectName 1.0.0.0. Sven Panne [14]announced a (tiny) new package, [15]ObjectName, which contains a class corresponding to the general notion of explicitly handled identifiers for API objects, e.g. a texture object name in OpenGL or a buffer object name in OpenAL. StateVar 1.0.0.0. Sven Panne [16]announced the [17]StateVar package, which further modularizes the OpenGL/OpenAL packages. It implements state variables, which are references in the IO monad, like IORefs or parts of the OpenGL state. data-ordlist-0.0.1 and NumberSieves-0.0. Leon Smith [18]announced the release of two new packages: [19]Data.OrdList offers a convenient way for efficiently dealing with lists that you happen to know are ordered, and includes operations such as union, merge, exclusive union, intersection, and difference. [20]NumberSieves includes the Sieve of O'Neill, from "The Geniune Sieve of Eratosthenes" by Melissa O'Neill, which offers an incremental primality sieve based on priority queues. Also included are two array-based generalizations of the Sieve of Eratosthenes: one for factoring a large quantity of small numbers, and another for calculating the phi function for a large quantity of small numbers. graphviz-2999.0.0.0. Ivan Lazar Miljenovic [21]announced a new release of the [22]graphviz package for Haskell, which provides bindings to the [23]GraphViz suite of tools. The biggest and most important change in this release is that all 152 attributes utilised/supported by GraphViz are now specified and supported. uncommon IMO problem - toilet management. Henning Thielemann [24]announced a [25]Haskell package for managing toilet use at the International Mathematical Olympiad. darcs 2.3 beta 4. Petr Rockai [26]announced another darcs 2.3 beta release, which features better Windows support. If you're on Windows, you should be able to install it with 'cabal install darcs-beta' -- give it a try! Google Summer of Code Progress updates from participants in the 2008 [27]Google Summer of Code. space profiling. Gergely Patai has been working on a [28]heap profile manager. fast darcs. Petr Rockai put out another [29]another darcs 2.3 beta release, and made a [30]bunch of other progress including getting darcs up and running on win32, working on hashed-storage, and optimizing 'darcs show contents'. Discussion is closing a class this easy? Conor McBride [31]asked for feedback on some code intended to effectively create a closed type class. laziness blowup exercise. Thomas Hartman [32]challenged readers to squash a memory leak. Blog noise [33]Haskell news from the [34]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Gergely Patai: [35]Introducing the heap profile manager. * FP Lunch: [36]Folding Statistics. * Petr Rockai: [37]soc progress 8. * Greg Bacon: [38]Monadic takeWhile. * Petr Rockai: [39]darcs 2.3 beta 4. * David Amos: [40]Counting symmetries using transversals. * Magnus Therning: [41]XML prettifier in Haskell. * Petr Rockai: [42]soc progress 7. Quotes of the Week * Berengal: For me, understanding the basics/reasoning behind haskell's type system was just a minute meditating on the phrase "what's the square root of hello?" * bitwize: The oleg is to functional studliness as the farad is to capacitance: a hopelessly large base unit. * maartenm: euclidate: to promote a conjecture to an axiom just for the sake of simplicity * RobertGreaye: Some suggest the original English remained in Britain when the North American colonies were founded; others claim it was brought to the Americas by the British settlers, leaving a pale imitation back in Britain. The truth is much stranger: the original English was actually smuggled out of Britain to the West Indies in a wardrobe belonging to General Sir Ralph Abercromby, where it ended up on the island of Trinidad after Sir Ralph took possession of that territory in the name of the British Crown. About the Haskell Weekly News New editions are posted to [43]the Haskell mailing list as well as to [44]the Haskell Sequence and [45]Planet Haskell. [46]RSS is also available, and headlines appear on [47]haskell.org. To help create new editions of this newsletter, please see the information on [48]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [49]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://haskell.org/haskellwiki/Hac_%CF%86 3. http://haskell.org/haskellwiki/Hac_%CF%86/Register 4. http://www.haskell.org//pipermail/haskell/2009-July/021508.html 5. http://haskell.org/ghc/docs/6.10.4/html/users_guide/release-6-10-4.html 6. http://article.gmane.org/gmane.comp.lang.haskell.general/17367 7. http://hackage.haskell.org/package/shelltestrunner 8. http://article.gmane.org/gmane.comp.lang.haskell.general/17366 9. http://hackage.haskell.org/package/generator 10. http://article.gmane.org/gmane.comp.lang.haskell.general/17364 11. http://hackage.haskell.org/package/GLURaw 12. http://article.gmane.org/gmane.comp.lang.haskell.general/17363 13. http://hackage.haskell.org/package/OpenGLRaw 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17362 15. http://hackage.haskell.org/package/ObjectName 16. http://article.gmane.org/gmane.comp.lang.haskell.general/17361 17. http://hackage.haskell.org/package/StateVar 18. http://article.gmane.org/gmane.comp.lang.haskell.general/17355 19. http://hackage.haskell.org/package/data-ordlist 20. http://hackage.haskell.org/package/NumberSieves 21. http://article.gmane.org/gmane.comp.lang.haskell.cafe/61494 22. http://hackage.haskell.org/package/graphviz 23. http://www.graphviz.org/ 24. http://article.gmane.org/gmane.comp.lang.haskell.cafe/61448 25. http://hackage.haskell.org/package/toilet-0.0.1 26. http://article.gmane.org/gmane.comp.lang.haskell.cafe/61302 27. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 28. http://just-bottom.blogspot.com/2009/07/introducing-heap-profile-manager.html 29. http://web.mornfall.net/blog/darcs_2.3_beta_4.html 30. http://web.mornfall.net/blog/soc_progress_8.html 31. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/61456 32. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/61283 33. http://planet.haskell.org/ 34. http://haskell.org/haskellwiki/Blog_articles 35. http://just-bottom.blogspot.com/2009/07/introducing-heap-profile-manager.html 36. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=232 37. http://web.mornfall.net/blog/soc_progress_8.html 38. http://feedproxy.google.com/~r/gbacon/~3/Q-Y-KapB8iI/monadic-takewhile.html 39. http://web.mornfall.net/blog/darcs_2.3_beta_4.html 40. http://haskellformaths.blogspot.com/2009/07/counting-symmetries-using-transversals.html 41. http://therning.org/magnus/archives/695 42. http://web.mornfall.net/blog/soc_progress_7.html 43. http://www.haskell.org/mailman/listinfo/haskell 44. http://sequence.complete.org/ 45. http://planet.haskell.org/ 46. http://sequence.complete.org/node/feed 47. http://haskell.org/ 48. http://haskell.org/haskellwiki/HWN 49. http://code.haskell.org/~byorgey/code/hwn/ From bulat.ziganshin at gmail.com Sat Jul 18 11:57:04 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jul 18 11:38:54 2009 Subject: [Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo? In-Reply-To: <910ddf450907180823s68902889i758489ec80bb5bb1@mail.gmail.com> References: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> <565557226.20090718141649@gmail.com> <910ddf450907180823s68902889i758489ec80bb5bb1@mail.gmail.com> Message-ID: <1887698464.20090718195704@gmail.com> Hello Thomas, Saturday, July 18, 2009, 7:23:10 PM, you wrote: > Going back to my original question, I am now looking for a dead simple > motivating example for showing the example of using a (good) hashtable > over Data.Map spell checking? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dons at galois.com Sat Jul 18 12:54:04 2009 From: dons at galois.com (Don Stewart) Date: Sat Jul 18 12:37:48 2009 Subject: [Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo? In-Reply-To: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> References: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> Message-ID: <20090718165404.GB6997@whirlpool.galois.com> tphyahoo: > The code below is, I think, n log n, a few seconds on a million + element list. Have you tried the judy arrays library on Hackage? (It provides a hashtable, which I've used occasionally) -- Don From tphyahoo at gmail.com Sat Jul 18 15:12:08 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Jul 18 14:53:49 2009 Subject: [Haskell-cafe] uncommon IMO problem - toilet management In-Reply-To: References: Message-ID: <910ddf450907181212j6e26f24ree0a8231a97d36b5@mail.gmail.com> I enjoyed learning from this app and seeing monad transformers in action. One nit, the parsing seems a bit wonky It would be nice to use parsec here, perhaps, rather than this hand rolled, and complain about input that can't be parsed rather than just say "toilet free" or whatever is going on here. thartman@ubuntu:~/tmp>toilet asdf 123 ASDF 123 enters toilet at 21:08 asdf 123 123 toilet blocked by ASDF123 since 21:08 asdf 124 123 toilet blocked by ASDF123 since 21:08 asdf 123 ASDF 123 leaves toilet at 21:09 asdf 124 123 toilet free asdf 124 ASDF 124 enters toilet at 21:09 1234 124 124 toilet free asdf 124 ASDF 124 leaves toilet at 21:09 2009/7/17 Henning Thielemann : > > In the last two days I was invigilator at the International Mathematic > Olympics 2009 in Bremen, Germany. There we got a problem different from the > official math problems. :-) Eventually I solved it using Haskell. Read the > detailed description at > ?http://hackage.haskell.org/package/toilet-0.0.1 > > I think the problem is simple enough to be used in education of programming. > > (I also think it would have been better to avoid monads and use lazy list > processing.) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From zsol.zso.l at gmail.com Sat Jul 18 15:48:36 2009 From: zsol.zso.l at gmail.com (Zsolt Dollenstein) Date: Sat Jul 18 15:30:37 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.0.0.0 In-Reply-To: <87ljmm9ik4.fsf@gmail.com> References: <87ljmm9ik4.fsf@gmail.com> Message-ID: <419feb5f0907181248u7a2a7aa3gf2753baf5c64fd5f@mail.gmail.com> Hi, On Sat, Jul 18, 2009 at 10:23 AM, Ivan Lazar Miljenovic < ivan.miljenovic@gmail.com> wrote: > I am pleased to announce a new release of the graphviz package for > Haskell, which provides bindings to the GraphViz [1] suite of tools. > Nice work! As the way of defining an attribute for a specific grouping of > nodes/edges/subgraphs is to have them all listed after the attribute > definition (whereas those beforehand do not have this attribute), the > imperative nature of the Dot language does not allow us to split these > statements up as we currently do. > > [3] http://graphviz.org/doc/info/lang.html > > As such, I'm asking which of the following two choices people would > prefer: > 1. Follow upstream so that it can fully parse a Dot graph > 2. Keep it as it is, so that it is possible to consider all edges, > etc. easily. I would vote for the second one since I think that is the most widely used feature of this package. Cheers, Zsolt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090718/203160e4/attachment-0001.html From wren at freegeek.org Sat Jul 18 18:47:41 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 18 18:29:22 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago In-Reply-To: <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> Message-ID: <4A62510D.1000104@freegeek.org> Richard O'Keefe wrote: > > On Jul 15, 2009, at 5:25 PM, Benjamin L.Russell wrote: >> it interesting that you should use the biological term "disease"; >> according to a post [1] entitled "Re: Re: Smalltalk Data Structures >> and Algorithms," by K. K. Subramaniam, dated "Mon, 29 Jun 2009 >> 11:25:34 +0530," on the squeak-beginners mailing list (see >> http://lists.squeakfoundation.org/pipermail/beginners/2009-June/006270.html), >> >>> Concepts in Squeak [a dialect and implementation of Smalltalk] have >> their origins >>> in biology rather than in computational math.... > > That posting is wrong. > > Smalltalk's roots are very firmly planted in Lisp, > with perhaps a touch of Logo (which also had its roots in Lisp). > The classic Smalltalk-76 paper even contains a meta-circular > interpreter, which I found reminiscent of the old Lisp one. > The "biological" metaphor in Smalltalk is actually a SOCIAL > metaphor: sending and receiving messages, and a "social" > model of agents with memory exchanging messages naturally > leads to anthropomorphisms. Also of note, the social metaphor is also very mathematical. It has its roots in process calculi like the pi-calculus, petri nets, the join-calculus, etc. The "original" OOP metaphor of Agents is also strongly aligned to this process calculus interpretation. (And any anthropologist will defy that sociality has more than a primitive connexion with biological systems. Animal behaviorists may disagree.) -- Live well, ~wren From wren at freegeek.org Sat Jul 18 18:45:00 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 18 18:29:57 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago In-Reply-To: <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> Message-ID: <4A62506C.4020305@freegeek.org> Richard O'Keefe wrote: > > On Jul 15, 2009, at 5:25 PM, Benjamin L.Russell wrote: >> it interesting that you should use the biological term "disease"; >> according to a post [1] entitled "Re: Re: Smalltalk Data Structures >> and Algorithms," by K. K. Subramaniam, dated "Mon, 29 Jun 2009 >> 11:25:34 +0530," on the squeak-beginners mailing list (see >> http://lists.squeakfoundation.org/pipermail/beginners/2009-June/006270.html), >> >>> Concepts in Squeak [a dialect and implementation of Smalltalk] have >> their origins >>> in biology rather than in computational math.... > > That posting is wrong. > > Smalltalk's roots are very firmly planted in Lisp, > with perhaps a touch of Logo (which also had its roots in Lisp). > The classic Smalltalk-76 paper even contains a meta-circular > interpreter, which I found reminiscent of the old Lisp one. > The "biological" metaphor in Smalltalk is actually a SOCIAL > metaphor: sending and receiving messages, and a "social" > model of agents with memory exchanging messages naturally > leads to anthropomorphisms. Also of note, the social metaphor is also very mathematical. It has its roots in process calculi like the pi-calculus, petri nets, the join-calculus, etc. The "original" OOP metaphor of Agents is also strongly aligned to this process calculus interpretation. (And any anthropologist will defy that sociality has more than a primitive connexion with biological systems. Animal behaviorists may disagree.) -- Live well, ~wren From wren at freegeek.org Sat Jul 18 19:09:34 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 18 18:51:14 2009 Subject: [Haskell-cafe] Haskell Zippers on Wikibooks: teasing! :) In-Reply-To: References: Message-ID: <4A62562E.2070104@freegeek.org> Peter Verswyvelen wrote: > After my colleague explained me about zippers and how one could derive the > datatype using differential rules, I had to read about it. > > So I started reading > http://en.wikibooks.org/wiki/Haskell/Zippers#Mechanical_Differentiation > > This page contains the sentence: *"For a systematic construction, we need > to calculate with types. The basics of structural calculations with types > are outlined in a separate chapter **Generic > Programming* > * and we will heavily rely on this material"* > * > * > However, the generic programming link does not exist yet :-) > > So although I now have a rough idea about it, I don't understand the details > yet, e.g. notation like > > [image: \mathit{Node}\,A = \mu X.\,\mathit{NodeF}_A\,X] > > doesn't make much sense to me yet, although I suspect I can read the mu as a > lambda on types? |\mu X. T| can be interpreted as |fix (\lambda X. T)| on types (where fix is the function returning the least fixed point of its argument), so you're close. To figure out what this interpretation means, you can just think of it as tying the knot, where the X is the name we give to the recursive type; thus: data List x = Nil | Cons x (List x) == data List x = \mu xs -> Nil | Cons x xs -- i.e. "xs" = \mu xs -> Nil | Cons x xs ==> data ListF x xs = Nil | Cons x xs type List x = \mu xs -> ListF x xs ... The full details are a bit more complex because we should distinguish between \mu (least fixed point) and \nu (greatest fixed point). For Haskell data types these two fixed points happen to coincide, but that's not the case in general. -- Live well, ~wren From wren at freegeek.org Sat Jul 18 19:40:41 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 18 19:22:22 2009 Subject: [Haskell-cafe] Re: Debugging methods for haskell In-Reply-To: <1d5d51400907180623m59b48320o2159fd7703829be0@mail.gmail.com> References: <1d5d51400907151507s3706eb8fwdcf55370acf11dd0@mail.gmail.com> <1d5d51400907180623m59b48320o2159fd7703829be0@mail.gmail.com> Message-ID: <4A625D79.6030602@freegeek.org> Fernan Bolando wrote: > The intention is z0 is a system parameter and database, it contains a > set of info needed to define a particular simulation > > it looks like ( [n,m...], [m,o,p]) > > n is is a list info settings for the circuit analysis > m is a list of statistics for the circuits that is need in sub-sequent > calculation > m is a list of circuit settings like temperature etc. > o is a list of matrix solution for non-linear newton raphson > p is a list of matrix solution for time dependent calculations This would be better as, data SystemParameterDatabase = SystemParameterDatabase { infoSettings :: InfoSettings , statistics :: Statistics , settings :: Settings , nlnr :: [Matrix Double] , timeDependent :: [Matrix Double] } data InfoSettings = InfoSettings { pMSET :: MSET , aSetting :: A , bSetting :: B ... } data Statistics = Statistics { aStatistic :: A , anotherStatistic :: A , bStatistic :: B ... } data Settings = Settings { temperature :: Kelvin , etc :: Etc } ... A single-constructor ADT, especially with the labeled-fields syntax, is pretty close to C structs; no need to reinvent them and give yourself headaches. Really, the only thing you should be using lists for is a variable-length sequence of elements drawn from the same type and distinguished only by their position in the sequence. Whenever the length is fixed or the (semantic) type of elements can be distinguished from one another (or altered by pushing/popping the list), then a list is not what you want to be using because it doesn't capture the intention of the type (and therefore allows unintelligible values of the type, and inappropriate transformations on the type). -- Live well, ~wren From wren at freegeek.org Sat Jul 18 19:52:48 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 18 19:34:28 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A5F821E.6000402@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> Message-ID: <4A626050.3000109@freegeek.org> Andrew Coppin wrote: > Robert Greayer wrote: >> f0 _ = (foo True, foo 'x') where foo = id >> >> is well-typed. >> > > Really? That actually works? How interesting... This suggests to me that > where-clauses also do strange things to the type system. Not too strange, in fact we need it to do that for local definitions to be helpful at all. The short answer is that let-binding is still polymorphic, whereas lambda-binding (passing in a parameter) is monomorphic. If let-binding were not polymorphic, then we could remove it entirely can just desugar everything into lambda-bindings. You should read this classic paper which introduced Hindley--Milner type inference, Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17:348-375, August 1978. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.67.5276 -- Live well, ~wren From wren at freegeek.org Sat Jul 18 20:01:53 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Jul 18 19:43:34 2009 Subject: [Haskell-cafe] A voyage of undiscovery In-Reply-To: <4A60B015.9090903@btinternet.com> References: <4A5F72AA.9060402@btinternet.com> <4ec472cb0907161158t71dae15cve54d4f84a227a040@mail.gmail.com> <4A5F821E.6000402@btinternet.com> <8CBF60D3-9219-45AF-B51D-2F64FE7A4A14@z.odi.ac> <4A5F8508.3040403@btinternet.com> <20090717000531.GB21698@sliver.repetae.net> <4A60B015.9090903@btinternet.com> Message-ID: <4A626271.6080201@freegeek.org> Andrew Coppin wrote: > > That seems simple enough (although problematic to implement). However, > the Report seems to say that it matters whether or not the bindings are > muturally recursive [but I'm not sure precisely *how* it matters...] Seriously, check out the classic Milner paper. Of languages in the ML tradition, Haskell is actually a bit strange in that it doesn't require the programmer to explicitly annotate recursive functions and recursive groups. That's *very* nice for programmers (since the compiler needs to and can figure it out anyways), though it hides some of the implementation complexity since you need to discover the "implicit" annotations. Polymorphic recursion was one of the big bugbears in the original HM inference algorithm. We can deal with it now, like we can deal with rank-N polymorphism (aka polymorphic lambda-binding) and many other improvements, but it's easiest to start out with the original algorithm when learning everything. -- Live well, ~wren From uzytkownik2 at gmail.com Sat Jul 18 21:16:07 2009 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Sat Jul 18 20:57:52 2009 Subject: [Haskell-cafe] Problem with lazy IO Message-ID: <1247966167.2835.13.camel@notebook> Hello. I've tried to combine lazy IO and parsec. The hole process is done by network. Currently I have implemented 'short parsers' so I enter them on need. To update state I have following code: parser2nntp :: Monad m => NntpParser m a -> NntpT m a parser2nntp p = do s <- NntpT (gets $ input . connection) e <- runParserT (do v <- p i <- getInput return (v, i)) () "" s case e of Left er -> error $ show er Right (v, i') -> (NntpT (modify (pNI i')) >> return v) where pNI :: Monad m => ByteString ->NntpState m -> NntpState m pNI i s = s {connection = (connection s) {input = i}} However the 4 line (i <- getInput) blocks the execution as trace indicated. String returned have no input available so it should block on evaluation - and here I pass only a reference to it (or rather I think so). What's wrong? PS. Full code is in darsc nntp repository http://code.haskell.org/nntp/ - please note that it seems to require network compiled against parsec 3 - not 2. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090718/50006493/attachment.bin From fernanbolando at mailc.net Sat Jul 18 21:32:29 2009 From: fernanbolando at mailc.net (Fernan Bolando) Date: Sat Jul 18 21:14:10 2009 Subject: [Haskell-cafe] was: Debugging methods for haskell structured data types the right way in haskell Message-ID: <1d5d51400907181832h36a769b4jc895318b82b014c3@mail.gmail.com> On Sun, Jul 19, 2009 at 7:40 AM, wren ng thornton wrote: > Fernan Bolando wrote: >> >> The intention is z0 is a system parameter and database, it contains a >> set of info needed to define a particular simulation >> >> it looks like ( [n,m...], [m,o,p]) >> >> n is is a list info settings for the circuit analysis >> m is a list of statistics for the circuits that is need in sub-sequent >> calculation >> m is a list of circuit settings like temperature etc. >> o is a list of matrix solution for non-linear newton raphson >> p is a list of matrix solution for time dependent calculations > > > This would be better as, > > > data SystemParameterDatabase = SystemParameterDatabase > ? ?{ infoSettings ?:: InfoSettings > ? ?, statistics ? ?:: Statistics > ? ?, settings ? ? ?:: Settings > ? ?, nlnr ? ? ? ? ?:: [Matrix Double] > ? ?, timeDependent :: [Matrix Double] > ? ?} > > data InfoSettings = InfoSettings > ? ?{ pMSET ? ?:: MSET > ? ?, aSetting :: A > ? ?, bSetting :: B > ? ?... > ? ?} > > data Statistics = Statistics > ? ?{ aStatistic ? ? ? :: A > ? ?, anotherStatistic :: A > ? ?, bStatistic ? ? ? :: B > ? ?... > ? ?} > > data Settings = Settings > ? ?{ temperature :: Kelvin > ? ?, etc ? ? ? ? :: Etc > ? ?} > ... > > > A single-constructor ADT, especially with the labeled-fields syntax, is > pretty close to C structs; no need to reinvent them and give yourself > headaches. > > > Really, the only thing you should be using lists for is a variable-length > sequence of elements drawn from the same type and distinguished only by > their position in the sequence. Whenever the length is fixed or the > (semantic) type of elements can be distinguished from one another (or > altered by pushing/popping the list), then a list is not what you want to be > using because it doesn't capture the intention of the type (and therefore > allows unintelligible values of the type, and inappropriate transformations > on the type). > > -- > Live well, > ~wren This is the kind of code recommendations I was looking. thanks -- http://www.fernski.com From ivan.miljenovic at gmail.com Sun Jul 19 04:13:52 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Sun Jul 19 03:55:37 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.0.0.0 In-Reply-To: <419feb5f0907181248u7a2a7aa3gf2753baf5c64fd5f@mail.gmail.com> (Zsolt Dollenstein's message of "Sat, 18 Jul 2009 15:48:36 -0400") References: <87ljmm9ik4.fsf@gmail.com> <419feb5f0907181248u7a2a7aa3gf2753baf5c64fd5f@mail.gmail.com> Message-ID: <87bpnhdr9b.fsf@gmail.com> Two clarifications I'd like to add to my previous announcement (both of which were prompted by Zsolt :p ): 1. Some Attribute values take something like (Either Bool String); this is used when upstream indicates that two different types of values are allowed. Typically in this kind of situation, the allowed String values are limited to a few specific values, so the usage of Either typically indicates that they should be replaced with a custom value type. 2. When considering the new representation of DotGraph, this isn't limited to just people who wish to parse Dot code: if you want to do anything out of the ordinary/fancy, then unfortunately you will need this imperative usage (as the indicated way to have global attributes to a graph but not to its subgraphs is to list all the subgraphs, and then define the graph attribute). For an example of this, consider the layout of Andy Gill's dotgen library [1]. If you look at the internals, he does consider graphs to be a list of statements. This amongst other things allows him to have a monadic interface for building graphs with much greater flexibility in what you can do, whereas graphviz limits you to either converting a pre-existing graph or else creating one within the limits of specifying it as a list of global attributes, a list of nodes/clusters and a list of edges between the nodes. [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dotgen What I'm considering is that if I internally represent DotGraph as a list of statements, then I will have getNodes and getEdges functions to extract the nodes and edges (with their attributes) out. This also simplifies some of the definitions, as a subgraph/cluster is then also just a list of statements. Zsolt Dollenstein writes: > Hi, > > On Sat, Jul 18, 2009 at 10:23 AM, Ivan Lazar Miljenovic < > ivan.miljenovic@gmail.com> wrote: > >> I am pleased to announce a new release of the graphviz package for >> Haskell, which provides bindings to the GraphViz [1] suite of tools. >> > > Nice work! > > As the way of defining an attribute for a specific grouping of >> > nodes/edges/subgraphs is to have them all listed after the attribute >> definition (whereas those beforehand do not have this attribute), the >> imperative nature of the Dot language does not allow us to split these >> statements up as we currently do. >> >> [3] http://graphviz.org/doc/info/lang.html >> >> As such, I'm asking which of the following two choices people would >> prefer: >> 1. Follow upstream so that it can fully parse a Dot graph >> 2. Keep it as it is, so that it is possible to consider all edges, >> etc. easily. > > > I would vote for the second one since I think that is the most widely used > feature of this package. > > Cheers, > Zsolt -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From apfelmus at quantentunnel.de Sun Jul 19 04:26:14 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sun Jul 19 04:07:54 2009 Subject: [Haskell-cafe] Re: can there be (hash-table using) O(n) version of this (I think currently) n log n algo? In-Reply-To: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> References: <910ddf450907171524x2720c0deya1d524b22698a558@mail.gmail.com> Message-ID: Thomas Hartman wrote: > The code below is, I think, n log n, a few seconds on a million + element list. > > I wonder if it's possible to get this down to O(N) by using a > hashtable implemementation, or other better data structure. > > -- findsums locates pairs of integers in a list > that add up to a wanted sum. > > findsums :: [Int] -> Int -> S.Set (Int,Int) > findsums xs wanted = snd . foldl' f (S.empty,S.empty) $ xs > where f (candidates,successes) next = > if S.member (wanted-next) candidates > then (candidates, S.insert (next,wanted-next) successes) > else (S.insert next candidates,successes) Remember that hash tables are actually O(key length) instead of O(1), so I don't think you can break the log n for really large lists this way since the key length increases as well (unless most elements are equal anyway). In any case, I have this conjecture On which I will lecture: A Set of some things Is sorting for kings. ;-) findsums goal = uncurry sweep . (id &&& reverse) . sort where sweep [] _ = [] sweep _ [] = [] sweep (x:xs) (y:ys) = if x > y then [] else case compare (x+y) goal of LT -> sweep xs (y:ys) EQ -> (x,y) : sweep xs ys GT -> sweep (x:xs) ys This algorithm needs a proof of correctness, though. And it's longer that the Data.Set version, too. Regards, apfelmus -- http://apfelmus.nfshost.com From ekmett at gmail.com Sun Jul 19 05:36:44 2009 From: ekmett at gmail.com (Edward Kmett) Date: Sun Jul 19 05:18:22 2009 Subject: [Haskell-cafe] Why is there no Zippable class? Would this work? In-Reply-To: References: <7fb8f82f0907171749k79570efdtaa281fe232d24cd9@mail.gmail.com> Message-ID: <7fb8f82f0907190236w1dc81df6tdd650c2368b060df@mail.gmail.com> On Fri, Jul 17, 2009 at 10:37 PM, wrote: > 2009/7/18 Edward Kmett : > >> I wrote a short blog post on this: >> http://comonad.com/reader/2008/zipping-and-unzipping-functors/ >> and one on the less powerful dual operations (less powerful because while >> every Haskell Functor is strong, much fewer are costrong): >> http://comonad.com/reader/2008/cozipping/ >> -Edward Kmett >> > > This is getting a bit OT, but I just wanted to comment that attempting to > remove polymorphism from the Functor class (see thread a couple of days ago) > means that not every Functor is strong. So strength for Functor would seem > to require a fully polymorphic type. I don't know if costrength is 'easier' > to derive for those 'restricted' Functors.. Continuing the OT aside... Well, the monomorphic not-quite-Functor from that post is a pretty ugly concept categorically, and obviously doesn't qualify as a Hask endofunctor, given its limited scope. That isn't to say that occasionally you don't want a function that can map a ByteString to a ByteString a byte at a time -- merely that it is a different animal. ;) Strength does require polymorphism... which comes for free if we're talking about an actual endofunctor. The ad-hoc not-quite-Functor provides no guarantee that a member of that you have an instance of the class supporting pairs "instance Functor' F (X,Y)" or that if you do that you have an instance for the class supports pairs that you have one for the left side of the pair "instance Functor' F X" let alone that these definitions are consistent. But even if you grant all of that, regarding costrength, it makes things no easier. Costrength is effectively about the ability to check inside of a functor and see if in some Functor f, a value f x where x = Either a b has any b's and if so, it gives you one, otherwise it gives you an "f a", because no b's occurred. Clearly for some simple functors you can complete this operation. But, there are many for which you cannot. The most obvious problem case is f = (->) a, because you need an oracle that knows the outcome of an arbitrary Haskell function; Kurt Godel would roll over in his grave. Similarly you run into problems deciding the outcome of costrength on a stream of Eithers even if you limit your instances to the bare minimum of () and Either () (), because you'd need to decide equality of streams, which leads to a need for a halting problem oracle. See http://comonad.com/reader/2008/deriving-strength-from-laziness/ for more details. -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090719/99609bfb/attachment.html From miguelimo38 at yandex.ru Sun Jul 19 09:51:58 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sun Jul 19 09:33:36 2009 Subject: [Haskell-cafe] is closing a class this easy? In-Reply-To: <200907181449.14474.g9ks157k@acme.softbase.org> References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> <200907181449.14474.g9ks157k@acme.softbase.org> Message-ID: <228F88EA-00D0-4A45-944F-B24BE1109BA9@yandex.ru> On 18 Jul 2009, at 16:49, Wolfgang Jeltsch wrote: > Am Samstag, 18. Juli 2009 08:58 schrieb Miguel Mitrofanov: >> Oops... Sorry, wrong line. Should be >> >> isAB :: forall p. p A -> p B -> p x > > Is this a well-known approach for closing classes? I have an impression that this is kinda folklore. But I can't provide any references; I don't even remember if I invented it myself or not. From allbery at ece.cmu.edu Sun Jul 19 10:22:19 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Jul 19 10:04:08 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.0.0.0 In-Reply-To: <87bpnhdr9b.fsf@gmail.com> References: <87ljmm9ik4.fsf@gmail.com> <419feb5f0907181248u7a2a7aa3gf2753baf5c64fd5f@mail.gmail.com> <87bpnhdr9b.fsf@gmail.com> Message-ID: On Jul 19, 2009, at 04:13 , Ivan Lazar Miljenovic wrote: > 1. Some Attribute values take something like (Either Bool String); > this > is used when upstream indicates that two different types of values > are allowed. Typically in this kind of situation, the allowed > String > values are limited to a few specific values, so the usage of Either > typically indicates that they should be replaced with a custom value > type. Shouldn't String then be replaced by a sum type? In fact, as described this would subsume the Either as well. > -- replace Either Bool String: AttrN are the strings, AltValue the bool > data upstreamValue = AttrA | AttrB | AltValue -- 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/20090719/7be4325b/PGP.bin From batterseapower at hotmail.com Sun Jul 19 10:58:08 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Sun Jul 19 10:39:47 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions Message-ID: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> Dear Cafe, For fun, I spent a few hours yesterday implement support for this syntax in GHC, originally propsed by Koen Claessen: >>> [k, "=", v, " " | (k, v) <- [("foo", "1"), ("bar", "2")] ["foo", "=", "1", " ", "bar", "=", "2", " "] This is a generalisation of list comprehensions that allows several items to be concatenated onto the result list at once, by having several comma-separated items before the pipe. One situation where I have found this to be useful is when you are writing Haskell programs that call lots of external programs and you need to set the flags based on some tests, like so: rawSystem "myProgram" $ ["foo" | fooing_enabled] ++ ["bar1", "bar2" | baring_enabled] I have submitted a ticket to GHC HQ with the patch (http://hackage.haskell.org/trac/ghc/ticket/3380#comment:5), but as it is just a small convenience it most likely won't make it in unless there is more demand for the feature. So, now is the time to speak up in favour of (or indeed, against) the added syntax! All the best, Max P.S. I also implemented tuple sections (http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3) which are a lot more useful: >>> (, True, "Hello", ) 1 "World" (1, True, "Hello", "World") From uzytkownik2 at gmail.com Sun Jul 19 11:06:05 2009 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Sun Jul 19 10:47:58 2009 Subject: [Haskell-cafe] Re: Problem with lazy IO References: <1247966167.2835.13.camel@notebook> Message-ID: Maciej Piechotka gmail.com> writes: > > Hello. > > I've tried to combine lazy IO and parsec. The hole process is done by > network. > > Currently I have implemented 'short parsers' so I enter them on need. To > update state I have following code: > parser2nntp :: Monad m => NntpParser m a -> NntpT m a > parser2nntp p = do s <- NntpT (gets $ input . connection) > e <- runParserT (do v <- p > i <- getInput > return (v, i)) () "" s > case e of > Left er -> error $ show er > Right (v, i') -> (NntpT (modify (pNI i')) >> return > v) > where pNI :: Monad m => ByteString ->NntpState m -> > NntpState m > pNI i s = s {connection = (connection s) {input = > i}} > > However the 4 line (i <- getInput) blocks the execution as trace > indicated. String returned have no input available so it should block on > evaluation - and here I pass only a reference to it (or rather I think > so). What's wrong? > > PS. Full code is in darsc nntp repository http://code.haskell.org/nntp/ > - please note that it seems to require network compiled against parsec 3 > - not 2. > > This code seems to work: parser2nntp :: Monad m => NntpParser m a -> NntpT m a parser2nntp p = do s <- NntpT (gets $ input . connection) r <- parserRep =<< runParsecT p (State s (initialPos "") ()) case r of Ok v (State i _ _) _ -> NntpT (modify $ pNI i) >> return v Error e -> error $ show e where parserRep (Consumed x) = x parserRep (Empty x) = x pNI i s = s {connection = (connection s) {input = i}} Regards From ndmitchell at gmail.com Sun Jul 19 11:14:35 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sun Jul 19 10:56:14 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> Message-ID: <404396ef0907190814l7ac29eedy9a3279d4c5c26133@mail.gmail.com> Hi Max, > For fun, I spent a few hours yesterday implement support for this > syntax in GHC, originally propsed by Koen Claessen: > >>>> [k, "=", v, " " | (k, v) <- [("foo", "1"), ("bar", "2")] > ["foo", "=", "1", " ", "bar", "=", "2", " "] > > This is a generalisation of list comprehensions that allows several > items to be concatenated onto the result list at once, by having > several comma-separated items before the pipe. I like the power this feature gives, and if it was already in Haskell 98 I'd certainly have used it a few times. I can't think of anything else the syntax could mean, so I don't see a potential for it stealing syntax that might otherwise be reused. However, it doesn't seem that discoverable or natural - I'm not sure I'd have ever guessed that such a feature might exist. > P.S. I also implemented tuple sections > (http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3) which are > a lot more useful: Yay! Discoverable, useful and really common in practice - a brilliant extension :-) Thanks Neil From tphyahoo at gmail.com Sun Jul 19 11:18:48 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sun Jul 19 11:00:25 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <404396ef0907190814l7ac29eedy9a3279d4c5c26133@mail.gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <404396ef0907190814l7ac29eedy9a3279d4c5c26133@mail.gmail.com> Message-ID: <910ddf450907190818n4ca3baf7mb97803e8230dd293@mail.gmail.com> I vote for tuple sections. Very nice! I don't really see immediate places where I would use the list comprehension improvement so I guess I don't vote for that. 2009/7/19 Neil Mitchell : > Hi Max, > >> For fun, I spent a few hours yesterday implement support for this >> syntax in GHC, originally propsed by Koen Claessen: >> >>>>> [k, "=", v, " " | (k, v) <- [("foo", "1"), ("bar", "2")] >> ["foo", "=", "1", " ", "bar", "=", "2", " "] >> >> This is a generalisation of list comprehensions that allows several >> items to be concatenated onto the result list at once, by having >> several comma-separated items before the pipe. > > I like the power this feature gives, and if it was already in Haskell > 98 I'd certainly have used it a few times. I can't think of anything > else the syntax could mean, so I don't see a potential for it stealing > syntax that might otherwise be reused. However, it doesn't seem that > discoverable or natural - I'm not sure I'd have ever guessed that such > a feature might exist. > >> P.S. I also implemented tuple sections >> (http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3) which are >> a lot more useful: > > Yay! Discoverable, useful and really common in practice - a brilliant > extension :-) > > Thanks > > Neil > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From greenrd at greenrd.org Sun Jul 19 11:41:50 2009 From: greenrd at greenrd.org (Robin Green) Date: Sun Jul 19 11:23:48 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <910ddf450907190818n4ca3baf7mb97803e8230dd293@mail.gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <404396ef0907190814l7ac29eedy9a3279d4c5c26133@mail.gmail.com> <910ddf450907190818n4ca3baf7mb97803e8230dd293@mail.gmail.com> Message-ID: <20090719164150.31669bc3@fedora> I really like tuple sections and I've wanted them for years. I never use comprehensions though, so I abstain from the other vote. -- Robin On Sun, 19 Jul 2009 08:18:48 -0700 Thomas Hartman wrote: > I vote for tuple sections. Very nice! > > I don't really see immediate places where I would use the list > comprehension improvement so I guess I don't vote for that. > > 2009/7/19 Neil Mitchell : > > Hi Max, > > > >> For fun, I spent a few hours yesterday implement support for this > >> syntax in GHC, originally propsed by Koen Claessen: > >> > >>>>> [k, "=", v, " " | (k, v) <- [("foo", "1"), ("bar", "2")] > >> ["foo", "=", "1", " ", "bar", "=", "2", " "] > >> > >> This is a generalisation of list comprehensions that allows several > >> items to be concatenated onto the result list at once, by having > >> several comma-separated items before the pipe. > > > > I like the power this feature gives, and if it was already in > > Haskell 98 I'd certainly have used it a few times. I can't think of > > anything else the syntax could mean, so I don't see a potential for > > it stealing syntax that might otherwise be reused. However, it > > doesn't seem that discoverable or natural - I'm not sure I'd have > > ever guessed that such a feature might exist. > > > >> P.S. I also implemented tuple sections > >> (http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3) which > >> are a lot more useful: > > > > Yay! Discoverable, useful and really common in practice - a > > brilliant extension :-) > > > > Thanks > > > > Neil From phil at beadling.co.uk Sun Jul 19 13:44:50 2009 From: phil at beadling.co.uk (phil@beadling.co.uk) Date: Sun Jul 19 13:26:31 2009 Subject: [Haskell-cafe] Ambiguous type variable - help! Message-ID: Hi, I'm trying to work out how to handle a choice at runtime which determines what instance of a State monad should be used. The choice will dictate the internal state of the monad so different implementations are needed for each. I've concocted a very simple example to illustrate this (below) - but it doesn't compile because ghc complains that my type is ambiguous arising from my use of 'fromSeq'. I can kind-of see what the compiler is complaining about, I'm guessing because it is the internals of my type which dictate which state Monad to use and it can't know that? Thinking about it I tried making SeqType an instance of Sequence class, but had no luck here. I understand that haskell is static at compile time, so I'm looking for something like a template solution in C++ (rather than a virtual function style implementation). I see there are libraries out their which do this, but I was wondering in my simple example if there was a way of doing this without writing a load of boilerplate code in main (this would get ugly very quickly if you had loads of choices). If this is impossible does anyone have an example / advice of implementing simple template style code in Haskell? Any help or suggestions would be really appreciated. Many Thanks, Phil. Thus just implements a state Monad which counts up from 1 to 10, using either an Int or a Double depending on user choice. It's pointless of course, but illustrates my point. {-# LANGUAGE TypeSynonymInstances #-} import Control.Monad.State.Strict data SeqType = SeqDouble Double | SeqInt Int class SequenceClass a where nextSeq :: State a Int fromSeq :: SeqType -> a instance SequenceClass Int where nextSeq = State $ \s -> (s,s+1) fromSeq (SeqInt i) = i fromSeq _ = 0 instance SequenceClass Double where nextSeq = State $ \s -> (truncate s,s+1.0) fromSeq (SeqDouble d) = d fromSeq _ = 0.0 chooser :: String -> SeqType chooser inStr | inStr == "Double" = SeqDouble 1.0 | inStr == "Int" = SeqInt 1 | otherwise = SeqInt 1 main :: IO() main = do userInput <- getLine let result = evalState (do replicateM 10 nextSeq) $ fromSeq $ chooser userInput print result From gale at sefer.org Sun Jul 19 16:18:32 2009 From: gale at sefer.org (Yitzchak Gale) Date: Sun Jul 19 16:00:30 2009 Subject: [Haskell-cafe] Ambiguous type variable - help! In-Reply-To: References: Message-ID: <2608b8a80907191318o7a6c6e18s8fddcd4efc9e5341@mail.gmail.com> Hi Phil, > I'm trying to work out how to handle a choice at runtime > which determines what instance of a State monad should > be used. First of all, you should realize that you'll almost never want to do something like that in Haskell. In my opinion, if you're coming from an OO language, you should ban yourself from defining Haskell classes or using existential types until you are completely comfortable with how different Haskell is from OO. You can get along fine without them. > I've concocted a very simple example to illustrate this (below) - but > it doesn't compile because ghc complains that my type is ambiguous arising > from my use of 'fromSeq'. Notice that you have given two completely separate sets of instructions of what to do depending on whether Int or Double is selected. You have not given any indication of how to choose between them, even at runtime. Of course, the compiler doesn't care that your string constants "Int" and "Double" happen also to be the names of types if unquoted. The way you avoid boilerplate in Haskell in these kinds of cases is by using polymorphism. Note that there could still remain a small amount of boilerplate - you move the actual hard work into a single polymorphic function, but then you may still need to mention that function once for each type. If that bothers you, there are more advanced tools to get rid of that last bit of boilerplate, like Template Haskell or "Scrap Your Boilerplate". Below is one way to fix up your example, with a few other minor bits of polish. Regards, Yitz import Control.Monad.State -- Why Strict? Haskell is lazy by default. data SeqType = SeqInt Int | SeqDouble Double class SequenceClass a where nextSeq :: State a Int instance SequenceClass Int where nextSeq = State $ \s -> (s, s + 1) instance SequenceClass Double where nextSeq = State $ \s -> (truncate s, s + 1) chooser :: String -> SeqType chooser inStr | inStr == "Double" = SeqDouble 1 | otherwise = SeqInt 1 -- Here is the polymorphism. -- Make this a function so that we can move it -- out of main. result :: SequenceClass a => a -> [Int] result = evalState $ replicateM 10 nextSeq -- Here is the only boilerplate needed printResult :: SeqType -> IO () printResult (SeqInt i) = print $ result i printResult (SeqDouble x) = print $ result x main :: IO() main = do userInput <- getLine printResult $ chooser userInput -- or you could just say -- main = getLine >>= printResult . chooser From ok at cs.otago.ac.nz Sun Jul 19 17:42:37 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Jul 19 17:24:53 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <200907181126.00302.g9ks157k@acme.softbase.org> References: <200907171635.35039.g9ks157k@acme.softbase.org> <395F4290-383E-46A7-9C1D-557D1E5B8279@cs.otago.ac.nz> <200907181126.00302.g9ks157k@acme.softbase.org> Message-ID: <44458CB5-F971-42D1-99C1-C0AE486E0959@cs.otago.ac.nz> On Jul 18, 2009, at 9:26 PM, Wolfgang Jeltsch wrote: > > I don?t think, it?s a good idea to have German identifiers, since > Haskell?s > keywords are English. Put it this way: if Haskell's keywords were in German, do you suppose I would write my Haskell code in anything but English? Does the fact that 'data' is a Latin word mean that some fraction of our Haskell identifiers should be in Latin? Some say ita, some say minime. > On the other hand, I strongly argue that a library > about B?zier curves uses the identifier B?zier, not Bezier. So non- > ASCII > identifiers are useful even if identifiers are in English. Indeed, you need non-ASCII letters to write English well. From nominolo at googlemail.com Sun Jul 19 18:07:18 2009 From: nominolo at googlemail.com (Thomas Schilling) Date: Sun Jul 19 17:48:56 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> Message-ID: <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> 2009/7/19 Max Bolingbroke > > Dear Cafe, > > For fun, I spent a few hours yesterday implement support for this > syntax in GHC, originally propsed by Koen Claessen: > > >>> [k, "=", v, " " | (k, v) <- [("foo", "1"), ("bar", "2")] > ["foo", "=", "1", " ", "bar", "=", "2", " "] Given that this can easily be simulated via: >>> [ x | (k, v) <- [("foo", "1"), ("bar", "2")], x <- [k, "=", v, " "]] ["foo","=","1"," ","bar","=","2"," "] I believe that the added syntax (which every complete tool operating on Haskell code would have to support) is not worth its price. > > This is a generalisation of list comprehensions that allows several > items to be concatenated onto the result list at once, by having > several comma-separated items before the pipe. One situation where I > have found this to be useful is when you are writing Haskell programs > that call lots of external programs and you need to set the flags > based on some tests, like so: > > rawSystem "myProgram" $ > ?["foo" | fooing_enabled] ++ > ?["bar1", "bar2" | baring_enabled] > > I have submitted a ticket to GHC HQ with the patch > (http://hackage.haskell.org/trac/ghc/ticket/3380#comment:5), but as it > is just a small convenience it most likely won't make it in unless > there is more demand for the feature. So, now is the time to speak up > in favour of (or indeed, against) the added syntax! > > All the best, > Max > > P.S. I also implemented tuple sections > (http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3) which are > a lot more useful: They are indeed, and here I would be inclined to consider the added cost worth it. -- Push the envelope. ?Watch it bend. From greenrd at greenrd.org Sun Jul 19 18:35:34 2009 From: greenrd at greenrd.org (Robin Green) Date: Sun Jul 19 18:17:18 2009 Subject: [Haskell-cafe] ANN: cautious-file 0.1.1: Ways to write a file cautiously, to avoid data loss Message-ID: <20090719233534.7c5d85ac@fedora> I'm pleased to announce the first public release of cautious-file: http://hackage.haskell.org/package/cautious-file This library currently provides a writeFile function that is intended to have three advantages over Prelude.writeFile: 1. There was a controversy a few months ago about the new Linux filesystem ext4, and how existing applications which write certain files naively might expose their users to the risk of data loss after a crash or power failure. (Actually, it turns out that this is not a new issue - certain other filesystems or filesystem mount options can cause similar issues, but few people made a fuss about it.) cautious-file uses the recommended way of writing a file on POSIX (more or less). On non-POSIX systems (i.e. Windows), it tries to do something sensible, but it may not be the best way to do it, and I've only ran the tests on Linux. 2. With almost any filesystem or operating system, saving a file by overwriting it exposes the user to the risk of data loss if there is a crash or power failure. cautious-file creates a temporary file first and only overwrites the file when it has finished writing (on POSIX systems with sane filesystems, at least). 3. Prelude.writeFile is supposed to lock files so that they at least cannot be written to simultaneously in multiple threads. This is good for safety, but might lead to avoidable problems with IO exceptions when one thread tries to open a file for writing which is still being written to by another thread. Again, the use of a randomly-named temporary file avoids this problem (not with certainty, but with a high probability, which is good enough for some applications). It does not prevent all file-related race conditions (nothing with its type signature could!), but if you are sure you don't care which thread wins, you should be able to use cautious-file's writeFile. A variant, writeFileWithBackup, also allows you to supply a custom backup computation to backup old copy(ies) of the destination file (which is not necessary with Prelude.writeFile, because you can just do it before you call Prelude.writeFile, but is necessary with cautious-file). cautious-file is obviously not appropriate for all circumstances - for instance, it's not needed for writing truly temporary files. But of course if it's close to what you need, you can adapt it (and send me a patch if you like). There is a test runner that can be run by running "runhaskell Setup.lhs test" or "cabal test" in a built copy of the source distribution. The tests do not actually verify that data loss doesn't happen if there's a crash! Indeed, attention should be drawn to the standard BSD license - despite the name "cautious-file", there is no warranty. If in doubt, I suggest you take a close look at the source code - it's very short. I'd appreciate comments, patches, pointers to Haskell code that does the same thing already, etc. Thanks, -- Robin From g9ks157k at acme.softbase.org Sun Jul 19 19:05:49 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sun Jul 19 18:47:51 2009 Subject: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK In-Reply-To: <44458CB5-F971-42D1-99C1-C0AE486E0959@cs.otago.ac.nz> References: <200907181126.00302.g9ks157k@acme.softbase.org> <44458CB5-F971-42D1-99C1-C0AE486E0959@cs.otago.ac.nz> Message-ID: <200907200105.49661.g9ks157k@acme.softbase.org> Am Sonntag, 19. Juli 2009 23:42 schrieben Sie: > On Jul 18, 2009, at 9:26 PM, Wolfgang Jeltsch wrote: > > I don?t think, it?s a good idea to have German identifiers, since > > Haskell?s keywords are English. > > Put it this way: if Haskell's keywords were in German, do you suppose I > would write my Haskell code in anything but English? At least, many people all over the world write their code in something other than their native language. :-) > Does the fact that 'data' is a Latin word mean that some fraction of our > Haskell identifiers should be in Latin? data is also an English word nowadays. Best wishes, Wolfgang From ivan.miljenovic at gmail.com Sun Jul 19 20:00:33 2009 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Sun Jul 19 19:42:09 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.0.0.0 In-Reply-To: References: <87ljmm9ik4.fsf@gmail.com> <419feb5f0907181248u7a2a7aa3gf2753baf5c64fd5f@mail.gmail.com> <87bpnhdr9b.fsf@gmail.com> Message-ID: 2009/7/20 Brandon S. Allbery KF8NH : > Shouldn't String then be replaced by a sum type? ?In fact, as described this > would subsume the Either as well. > >> -- replace Either Bool String: AttrN are the strings, AltValue the bool >> data upstreamValue = AttrA | AttrB | AltValue Yes, as I said. I didn't for a few reasons: 1. I was running out of time and wanted to make a release on the weekend (I'm heading overseas in just over a week and have a fair few things to do before then). In future, this will probably be improved. 2. I forgot to replace those ones with the custom constructors :s Though IIRC, most of those that still have Either are those which probably aren't likely to be used, etc. Note also that (and this is also a problem with using Either) I have to think of a way to parse the values with a possible Bool field properly, since if a Bool is a valid value then just the attribute name is equivalent to name = true. At the moment, most attributes use a parseField function (that consumes the attribute name, the equals sign and then parses and returns the result) but those with just Bool attributes use a slight variant where if there is no equals sign, then True is returned. This will obviously not work too well with sum types :s. > > -- > 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 > > > -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Pablo Picasso - "Computers are useless. They can only give you answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html From bit at mutantlemon.com Sun Jul 19 21:37:21 2009 From: bit at mutantlemon.com (Bit Connor) Date: Sun Jul 19 21:19:01 2009 Subject: [Haskell-cafe] Problem resizing widget contained in window In-Reply-To: <4165d3a70907140746h4c25511bwce6a3bf078eefa1b@mail.gmail.com> References: <4165d3a70907140746h4c25511bwce6a3bf078eefa1b@mail.gmail.com> Message-ID: <6205bd290907191837r198436dfn2e37906162c603ac@mail.gmail.com> On Tue, Jul 14, 2009 at 5:46 PM, Jeff Heard wrote: > Now, if someone resizes the window, the GLArea does not appear to > resize along with it. ?Did I screw something up? You need to call the opengl glViewport function(I don't remember what the haskell binding is called) in your resize handler so that opengl knows about the new viewport size. And you are also probably going to want to update the opengl projection matrix to prevent distortion as a result of a changed aspect ratio. From vigalchin at gmail.com Mon Jul 20 04:26:52 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Mon Jul 20 04:08:32 2009 Subject: [Haskell-cafe] Hackage and version control Message-ID: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> Hello, It seems to me that Hackage doesn't provide version control, e.g. check out and check in. Am I incorrect? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/9a2c1cb3/attachment.html From greenrd at greenrd.org Sun Jul 19 22:24:49 2009 From: greenrd at greenrd.org (Robin Green) Date: Mon Jul 20 04:19:07 2009 Subject: [Haskell-cafe] FFI problem - possibility of CStringLen overflow? Message-ID: <20090720032449.690fdf47@fedora> While rewriting cautious-file to use ByteStrings and FFI just now, I came across this potential problem: Why does the FFI specification define CStringLen as (Ptr CChar, Int)? As the FFI specification itself notes, Haskell 98 implementors are allowed to have a quite small range for Int (only up to 2^29-1) - so you could in principle have a very large String which cannot be represented as a CStringLen, or a very large CString which cannot be represented as a CStringLen. They would take up wads of memory, so this has probably never happened yet, but it's in principle possible, no? If so, what are the implications of this for code correctness? -- Robin From bulat.ziganshin at gmail.com Mon Jul 20 04:49:38 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jul 20 04:40:56 2009 Subject: [Haskell-cafe] FFI problem - possibility of CStringLen overflow? In-Reply-To: <20090720032449.690fdf47@fedora> References: <20090720032449.690fdf47@fedora> Message-ID: <1096519401.20090720124938@gmail.com> Hello Robin, Monday, July 20, 2009, 6:24:49 AM, you wrote: > Why does the FFI specification define CStringLen as (Ptr CChar, Int)? 1. i think it was done to simplify using the api 2. hugs usually don't used for data-massive apps, it's niche is learning and quick development -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From magnus at therning.org Mon Jul 20 05:03:56 2009 From: magnus at therning.org (Magnus Therning) Date: Mon Jul 20 04:45:33 2009 Subject: [Haskell-cafe] Hackage and version control In-Reply-To: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> References: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> Message-ID: On Mon, Jul 20, 2009 at 9:26 AM, Vasili I. Galchin wrote: > Hello, > > ???? It seems to me that Hackage doesn't provide version control, e.g. check > out and check in. Am I incorrect? Hackage is, AFAIU, a repository where _released_ versions of libraries/tools/etc related to Haskell can be kept. It is not fully comparable to SourceForge, Github, or any other _source hosting_ service. If you are looking for source hosting then take a look at SF, Github, Google Code, or something like that. Then upload _released_ versions to Hackage. IIRC there is also the possibility of having a Darcs repo on community.haskell.org. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From jon.fairbairn at cl.cam.ac.uk Mon Jul 20 05:26:02 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Mon Jul 20 05:07:52 2009 Subject: [Haskell-cafe] Re: was: Debugging methods for haskell structured data types the right way in haskell References: <1d5d51400907181832h36a769b4jc895318b82b014c3@mail.gmail.com> Message-ID: Fernan Bolando writes: > On Sun, Jul 19, 2009 at 7:40 AM, wren ng thornton wrote: >> Fernan Bolando wrote: >>> >>> The intention is z0 is a system parameter and database, it contains a >>> set of info needed to define a particular simulation >> >> A single-constructor ADT, especially with the labeled-fields syntax, is >> pretty close to C structs; no need to reinvent them and give yourself >> headaches. >> >> >> Really, the only thing you should be using lists for is a variable-length >> sequence of elements drawn from the same type and distinguished only by >> their position in the sequence. > > This is the kind of code recommendations I was looking. I'd worked out a longer reply over the weekend, but wren got there first (It hadn't occured to me that anyone would write that much code without knowing about algebraic types, so thought something else was going on). I'd like to add that thinking about the C code for a programme like this is counterproductive. If you are doing various mathematical operations, it's better to go straight from the mathematics to Haskell, and work out the appropriate abstractions (in Haskell) for the operations you are using. You'll generally end up with much shorter code that is easier to maintain. It might be worth pointing out that you can do things with Haskell data structures that you can't do conveniently in C. For example, if you were doing something that involved calculating the determinants of matrices fairly often, but you didn't know in advance which matrices, you could define your own matrix type like this (roughly): data MyMatrix t = MM {theNumbers:: Matrix t, my_determinant:: t} make_matrix m = MM {theNumbers = m, my_determinant = determinant m } and then use make_matrix whenever you make a new matrix and my_determinant whenever you want a determinant. Now, although to a C programmer this looks like you calculate the determinant of every matrix, laziness means that you only calculate the ones you use, and calculate them at most once for each matrix. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From bulat.ziganshin at gmail.com Mon Jul 20 05:27:06 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jul 20 05:08:49 2009 Subject: [Haskell-cafe] Hackage and version control In-Reply-To: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> References: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> Message-ID: <1393740130.20090720132706@gmail.com> Hello Vasili, Monday, July 20, 2009, 12:26:52 PM, you wrote: > ???? It seems to me that Hackage doesn't provide version control, > e.g. check out and check in. Am I incorrect? i recommend you to use either codeplex or code.google -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From greenrd at greenrd.org Sun Jul 19 23:25:25 2009 From: greenrd at greenrd.org (Robin Green) Date: Mon Jul 20 05:20:09 2009 Subject: [Haskell-cafe] Hackage and version control In-Reply-To: References: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> Message-ID: <20090720042525.3e02b4ae@fedora> On Mon, 20 Jul 2009 10:03:56 +0100 Magnus Therning wrote: > On Mon, Jul 20, 2009 at 9:26 AM, Vasili I. > Galchin wrote: > > Hello, > > > > ???? It seems to me that Hackage doesn't provide version control, > > e.g. check out and check in. Am I incorrect? > > Hackage is, AFAIU, a repository where _released_ versions of > libraries/tools/etc related to Haskell can be kept. It is not fully > comparable to SourceForge, Github, or any other _source hosting_ > service. > > If you are looking for source hosting then take a look at SF, Github, > Google Code, or something like that. Then upload _released_ versions > to Hackage. IIRC there is also the possibility of having a Darcs repo > on community.haskell.org. Yes, and darcs repos can also be hosted on patch-tag.com. community.haskell.org requires you to wait for a volunteer to review every new project request. Although, you don't need to make a project request if you only want a 1-developer repository. And by the way, it only hosts Haskell-related projects, not arbitrary darcs repositories. patch-tag.com doesn't have those constraints. -- Robin From miguelimo38 at yandex.ru Mon Jul 20 05:41:40 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Jul 20 05:23:20 2009 Subject: [Haskell-cafe] Hackage and version control In-Reply-To: <1393740130.20090720132706@gmail.com> References: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> <1393740130.20090720132706@gmail.com> Message-ID: Or patch-tag.com On 20 Jul 2009, at 13:27, Bulat Ziganshin wrote: > Hello Vasili, > > Monday, July 20, 2009, 12:26:52 PM, you wrote: > >> It seems to me that Hackage doesn't provide version control, >> e.g. check out and check in. Am I incorrect? > > i recommend you to use either codeplex or code.google > > > -- > 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 jfredett at gmail.com Mon Jul 20 06:36:28 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Jul 20 06:18:03 2009 Subject: [Haskell-cafe] Hackage and version control In-Reply-To: <1393740130.20090720132706@gmail.com> References: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> <1393740130.20090720132706@gmail.com> Message-ID: <4A6448AC.6060202@gmail.com> Don't forget about Patch-tag! Bulat Ziganshin wrote: > Hello Vasili, > > Monday, July 20, 2009, 12:26:52 PM, you wrote: > > >> It seems to me that Hackage doesn't provide version control, >> e.g. check out and check in. Am I incorrect? >> > > i recommend you to use either codeplex or code.google > > > -------------- 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/20090720/42d7f039/jfredett.vcf From g9ks157k at acme.softbase.org Mon Jul 20 06:40:14 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Mon Jul 20 06:22:23 2009 Subject: [Haskell-cafe] Hackage and version control In-Reply-To: <20090720042525.3e02b4ae@fedora> References: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> <20090720042525.3e02b4ae@fedora> Message-ID: <200907201240.14760.g9ks157k@acme.softbase.org> Am Montag, 20. Juli 2009 05:25 schrieb Robin Green: > community.haskell.org requires you to wait for a volunteer to review > every new project request. However, response times are usually low. Best wishes, Wolfgang From bulat.ziganshin at gmail.com Mon Jul 20 06:41:25 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jul 20 06:23:08 2009 Subject: [Haskell-cafe] Hackage and version control In-Reply-To: <4A6448AC.6060202@gmail.com> References: <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> <1393740130.20090720132706@gmail.com> <4A6448AC.6060202@gmail.com> Message-ID: <121430820.20090720144125@gmail.com> Hello Joe, Monday, July 20, 2009, 2:36:28 PM, you wrote: afaik it provides minimal features, only VCS, while sitea i mentioned provides full service for OSS developer > Don't forget about Patch-tag! > Bulat Ziganshin wrote: >> Hello Vasili, >> >> Monday, July 20, 2009, 12:26:52 PM, you wrote: >> >> >>> It seems to me that Hackage doesn't provide version control, >>> e.g. check out and check in. Am I incorrect? >>> >> >> i recommend you to use either codeplex or code.google >> >> >> -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From greenrd at greenrd.org Mon Jul 20 01:09:50 2009 From: greenrd at greenrd.org (Robin Green) Date: Mon Jul 20 07:04:17 2009 Subject: [Haskell-cafe] ANN: cautious-file 0.1.1: Ways to write a file cautiously, to avoid data loss In-Reply-To: <20090719233534.7c5d85ac@fedora> References: <20090719233534.7c5d85ac@fedora> Message-ID: <20090720060950.076176fa@fedora> I've since uploaded two new versions with the following changes: 0.1.2: Fixed an issue where it would clobber symbolic links to files, which is usually not what you want. Test case added for this. 0.1.3: ByteString support! FFI is also now used under the hood to do things in a slightly less hacky way. -- Robin On Sun, 19 Jul 2009 23:35:34 +0100 Robin Green wrote: > I'm pleased to announce the first public release of cautious-file: > > http://hackage.haskell.org/package/cautious-file From vandijk.roel at gmail.com Mon Jul 20 07:27:57 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Jul 20 07:09:32 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> Message-ID: I think the tuple sections are a great idea! It also makes tuple types and constructors more alike: x :: (,) String Double x = (,) "Pi" 3.14159 I can also see some uses in writing pointfree code. I would definitely want this in a future GHC (or any other Haskell compiler/interpreter) release. I'm not so sure about the list comprehension concatenation. Like Thomas Schilling wrote, it is only a bit shorter then writing it with the current syntax. So I'm not sure if it is worth the cost. From felipe.lessa at gmail.com Mon Jul 20 08:02:54 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon Jul 20 07:44:34 2009 Subject: [Haskell-cafe] ANN: cautious-file 0.1.1: Ways to write a file cautiously, to avoid data loss In-Reply-To: <20090719233534.7c5d85ac@fedora> References: <20090719233534.7c5d85ac@fedora> Message-ID: <20090720120254.GA6396@kira.casa> Nice library! On Sun, Jul 19, 2009 at 11:35:34PM +0100, Robin Green wrote: > A variant, writeFileWithBackup, also allows you to supply a custom > backup computation to backup old copy(ies) of the destination file It would be nice to have the backup action receive the file name as a parameter, so it would be possible to have a library of possible backup strategies. :) -- Felipe. From haskell at gimbo.org.uk Mon Jul 20 08:16:03 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Mon Jul 20 07:57:44 2009 Subject: [Haskell-cafe] Typeclass default implementation in subclasses Message-ID: <5A40667D-984C-4F0A-A7E3-F21980B60CE9@gimbo.org.uk> Hi all, This email is literate Haskell. I have a question about default implementations of typeclasses. > {-# LANGUAGE TypeSynonymInstances #-} > module Thing where > import Text.PrettyPrint.HughesPJ Let say I want to pretty-print some values, enclosed in double quotes. The natural thing to do (within the HughesPJ pretty-printing framework, anyway - and that's where I am in this problem's wider context) is: > ppQuote :: Show a => a -> Doc > ppQuote = doubleQuotes . text . show Now, this works nicely for (say) Int: > x :: Int > x = 1 *Thing> ppQuote x "1" But less nicely for String and Char, because their Show instances already insert double/single quotes respectively: > y :: String > y = "hello" > z :: Char > z = 'a' *Thing> ppQuote y ""hello"" *Thing> ppQuote z "'a'" I don't want this. I'd like them to be "hello" and "a" respectively. So I thought I'd create a typeclass, whose default implementation is as above... > class (Show a) => Quotable a where > quote :: a -> Doc > quote = ppQuote ... but with specialised instances for String and Char (the former seems to need the TypeSynonymInstances extension?): > instance Quotable String where > quote = text . show -- don't need the doubleQuotes call for String > instance Quotable Char where > quote c = quote [c] -- just lift it to String Unfortunately, while this works great for String and Char... *Thing> quote y "hello" *Thing> quote z "a" ... the "default implementation" mechanism doesn't work as I'd expect/hope: *Thing> quote x :1:0: No instance for (Quotable Int) arising from a use of `quote' at :1:0-6 Possible fix: add an instance declaration for (Quotable Int) In the expression: quote x In the definition of `it': it = quote x What I would _like_ would be for the compiler to say "OK, the Quotable class depends on the Show class, and Int is an instance of Show so Int is also an instance of Quotable, having the default implementation (since there isn't a specialised one for it)" - but clearly it doesn't. Please can someone tell me why this doesn't happen, and if there is a way of making it happen? Also, if there's a more sensible way of attacking this whole problem, I'd be curious to hear it. I should perhaps add that this isn't a huge problem for me, because my instances will in practice tend to be String and Char anyway, and one can of course add Quotable instances for anything else easily enough - but I'm curious now I've come this far. :-) Many thanks! -Andy From RafaelGCPP.Linux at gmail.com Mon Jul 20 08:30:24 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Mon Jul 20 08:12:00 2009 Subject: [Haskell-cafe] ICFP contest write-up Message-ID: <351ff25e0907200530s2c998777g482bd7674ad5d85a@mail.gmail.com> For all Portuguese reading haskellers, I am describing my ICFP 2009 contest write-up on my blog. Feel free to comment. http://rafaelgcpp.blogspot.com/search/label/ICFP2009 For the non-Portuguese readers, Google translation tools do a lousy job, but it is still readable. Regards Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/30061e23/attachment.html From reiner.pope at gmail.com Mon Jul 20 08:39:09 2009 From: reiner.pope at gmail.com (Reiner Pope) Date: Mon Jul 20 08:20:44 2009 Subject: [Haskell-cafe] SpecConstr difficulties Message-ID: <4cf038ee0907200539w1676a6e7ub29350cf5025b91a@mail.gmail.com> Hi everyone, I've been having some trouble getting SpecConstr to work as I want it to. The following example (see end of email) came up in some code I was playing around with. The loops g1 and g2 both compute the same thing: the maximum element of the "list" (which has been fused away) of numbers from 1 to 10. Since 'maximum' is a foldl1 not a foldl, I use a strict Maybe type as an accumulator. The Maybe gets filled after the first element is seen, so the Maybe is a Just for almost the entire running of the loop. It would be good to have this recognised by SpecConstr, to create an optimised loop for the Just case. This does indeed happen for g1, but not for g2. My difficulty is that I am only able to produce code similar to g2, i.e. where the pattern matching is in a separate function, 'expose', because the 'expose' function is implemented in a type-class, like in stream-fusion. Is there some way to keep the SpecConstr while leaving the 'expose' as a separate function? Here is the code: > {-# LANGUAGE BangPatterns #-} > > module Test(ans1,ans2) where > > import Prelude hiding(Maybe(..)) > > data Maybe a = Just !a | Nothing > > Nothing `mapp` Just b = Just b > Just a `mapp` Just b = Just (max a b) > > ans1 = g1 Nothing (0::Int) > > g1 m !n = case m of > Nothing -> if n > 10 then m else g1 (m `mapp` Just n) (n+1) > Just x -> if n > 10 then m else g1 (m `mapp` Just n) (n+1) > > ans2 = g2 Nothing (0::Int) > > g2 m !n = expose m (if n > 10 then m else g2 (m `mapp` Just n) (n+1)) > expose Nothing b = b > expose (Just a) b = a `seq` b On a similar note, when I was having difficulties with this problem, I started to wonder if it would be possible to come up with a more direct way to tell GHC, "do SpecConstr on this variable". From reading the source code of the stream-fusion package, it seems that the current way of doing this is with 'expose' functions like I wrote below. Could we instead have a {-# SPECCONSTR #-} pragma, to be used on function arguments, like: foo {-# SPECCONSTR #-} x y {-# SPECCONSTR #-} z = ... This pragma should say to the GHC something like "ignore conditions H2, H5 and H6 of the SpecConstr paper, for this function and this argument". Cheers, Reiner From vandijk.roel at gmail.com Mon Jul 20 08:40:26 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Jul 20 08:22:02 2009 Subject: [Haskell-cafe] Typeclass default implementation in subclasses In-Reply-To: <5A40667D-984C-4F0A-A7E3-F21980B60CE9@gimbo.org.uk> References: <5A40667D-984C-4F0A-A7E3-F21980B60CE9@gimbo.org.uk> Message-ID: This post is also literate haskell. By enabling these potentially dangerous extensions you'll get the behaviour you want. > {-# LANGUAGE TypeSynonymInstances #-} > {-# LANGUAGE UndecidableInstances #-} > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE OverlappingInstances #-} > module Thing where > import Text.PrettyPrint.HughesPJ > ppQuote :: Show a => a -> Doc > ppQuote = doubleQuotes . text . show > x :: Int > x = 1 > y :: String > y = "hello" > z :: Char > z = 'a' > class (Show a) => Quotable a where > quote :: a -> Doc > quote = ppQuote > instance (Show a) => Quotable a > instance Quotable String where > quote = text . show -- don't need the doubleQuotes call for String > instance Quotable Char where > quote c = quote [c] -- just lift it to String Example: *Thing> quote "pi" "pi" *Thing> quote 3.14159 "3.14159" From ivan.miljenovic at gmail.com Mon Jul 20 09:08:49 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Mon Jul 20 08:50:33 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.1.0.1 Message-ID: <87vdlnwlge.fsf@gmail.com> This is a bug-fix release to fix the various Attribute-related problems in the previous release (2999.0.0.0) spotted mainly by Zsolt Dollenstein. Please disregard version 2999.1.0.0; it had a small bug. Similarly, people should avoid using 2999.0.0.0 unless they don't use any Either-based Attributes. The problem (which took me a while to realise) was that whilst I was using Either to denote that an attribute could take one of two different types of values (e.g. Bool and String) and the parsing for that worked. However, since I was using Show (I know it's bad, it was on my TODO, remember?) to generate the Dot code, then whenever one of these values was converted then either Left or Right would appear, and GraphViz doesn't seem to like that for some reason... I also took the opportunity to define custom types for more Attributes (as they only accept certain String values). Furthermore, GraphViz states that attributes that can accept a boolean value are set to True when the attribute is listed on its own; the library now does this even for those Attributes that use a custom type that combines Bool with something else. One other small change is that the Color Attribute now takes in a list of Colors; if you only want one, use a singleton list (it was either that or a custom datatype that takes either a single Color or a list of Colors...). Note that 2999.1.0.0 accidentally only had singleton Color values for the Color Attribute rather than a list, hence the quick version bump. Nothing else has changed in the library apart from the Attributes. Regarding my request in the previous email about the possible new layout of the DotGraph datatype: How many people actually build DotGraphs by hand or pull them apart by hand? If there were getNodes :: DotGraph -> [Node] and getEdges :: DotGraph -> [Edge] functions available, would you accept an all-in-one data type that just contains a generic list of statements and thus follows upstream more closely? Even leaving aside parsing, this would allow for greater flexibility for creating wild and wacky graphs or for a monadic interface or something for building DotGraphs (which someone has asked me for, but which at the moment I have no idea how to do...). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From vandijk.roel at gmail.com Mon Jul 20 09:22:24 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Jul 20 09:04:00 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> Message-ID: On Mon, Jul 20, 2009 at 1:27 PM, Roel van Dijk wrote: > I think the tuple sections are a great idea! It also makes tuple types > and constructors more alike: > > x :: (,) String Double > x = (,) "Pi" 3.14159 I just realised this is already in GHC :-) But does you patch also add the equivalent for tuple type annotations? x :: (String, ) Double x = ("Pi", ) 3.14159 I am also wondering what the following would/should mean: (1, , ( , 2), ) 'a' 'b' 'c' Should this mean (1, 'a', ('b', 2), 'c') or (1, 'a', ('c', 2), 'b') Intuitively I would expect the first option. Just reading from left to right. But it doesn't look entirely trivial. From ganesh.sittampalam at credit-suisse.com Mon Jul 20 09:25:56 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Mon Jul 20 09:07:39 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9F7DC@ELON17P32001A.csfb.cs-group.com> Roel van Dijk wrote: > On Mon, Jul 20, 2009 at 1:27 PM, Roel van > Dijk wrote: >> I think the tuple sections are a great idea! It also makes tuple >> types and constructors more alike: >> >> x :: (,) String Double >> x = (,) "Pi" 3.14159 > > I just realised this is already in GHC :-) But does you patch also > add the equivalent for tuple type annotations? > > x :: (String, ) Double > x = ("Pi", ) 3.14159 > > I am also wondering what the following would/should mean: > > (1, , ( , 2), ) 'a' 'b' 'c' I would expect it to be a type error, since I think the following is the only sane type the tuple can have (assuming numeric literals :: Int): (1, , ( , 2), ) :: a -> b -> (Int, a, c -> (c, Int), b) Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From vandijk.roel at gmail.com Mon Jul 20 09:42:08 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Jul 20 09:23:44 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B03B9F7DC@ELON17P32001A.csfb.cs-group.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B03B9F7DC@ELON17P32001A.csfb.cs-group.com> Message-ID: >> I am also wondering what the following would/should mean: >> >> ? (1, , ( , 2), ) 'a' 'b' 'c' > > I would expect it to be a type error, since I think the following is the > only sane type the tuple can have (assuming numeric literals :: Int): > > (1, , ( , 2), ) :: a -> b -> (Int, a, c -> (c, Int), b) > > Ganesh Ah you're completely right! I would be applying a tuple to a Char which is nonsense. From dagit at codersbase.com Mon Jul 20 10:02:22 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Jul 20 09:43:58 2009 Subject: [Haskell-cafe] FFI problem - possibility of CStringLen overflow? In-Reply-To: <20090720032449.690fdf47@fedora> References: <20090720032449.690fdf47@fedora> Message-ID: On Sun, Jul 19, 2009 at 7:24 PM, Robin Green wrote: > While rewriting cautious-file to use ByteStrings and FFI just now, I > came across this potential problem: > > Why does the FFI specification define CStringLen as (Ptr CChar, Int)? Do you think it was a typo and the author(s) meant (Ptr CChar, CInt) ? Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/abed0080/attachment.html From flippa at flippac.org Mon Jul 20 10:07:23 2009 From: flippa at flippac.org (Philippa Cowderoy) Date: Mon Jul 20 09:49:21 2009 Subject: [Haskell-cafe] Anglohaskell - wifi signups Message-ID: <4A647A1B.7010408@flippac.org> Wifi signups are Anglohaskell are now on the wiki - please add your details by the 31st of July if you want a wifi account at MS Research for the Friday. Alternatively, reply to this email with your full name, institution, country of residence and email address. The Anglohaskell wiki page can be found at http://www.haskell.org/haskellwiki/AngloHaskell/2009 There's still room for more talks if anyone's got something they fancy giving a go - everything from cutting edge research to "what I did with Haskell on my holiday" is welcome, as is everyone from GHC implentors to newbies frantically writing Hello World on their laptop in the back row. -- flippa@flippac.org From thomas.dubuisson at gmail.com Mon Jul 20 14:09:40 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Mon Jul 20 13:51:16 2009 Subject: [Haskell-cafe] Pruning the Front Page Message-ID: <4c44d90b0907201109v75f5427ra5aadefdf1722663@mail.gmail.com> All, I think we should remove unmaintained or refocused implementations from the haskell.org front page. This would mean removing: YHC - unmaintained, hasn't built for me in a while LHC - Not a standalone compiler these days - perhaps should be linked as a GHC subproject? Other than those I'd propose NHC but I'm guessing that would get some pushback (even though it currently doesn't build for me). Before anyone brings up HUGS I'll just say that 1) it is used 2) it builds 3) at least it's been updated more recently than the Haskell langauge. Thomas From dons at galois.com Mon Jul 20 14:12:16 2009 From: dons at galois.com (Don Stewart) Date: Mon Jul 20 13:55:52 2009 Subject: [Haskell-cafe] Pruning the Front Page In-Reply-To: <4c44d90b0907201109v75f5427ra5aadefdf1722663@mail.gmail.com> References: <4c44d90b0907201109v75f5427ra5aadefdf1722663@mail.gmail.com> Message-ID: <20090720181216.GL15846@whirlpool.galois.com> thomas.dubuisson: > All, > I think we should remove unmaintained or refocused implementations > from the haskell.org front page. This would mean removing: > YHC - unmaintained, hasn't built for me in a while > LHC - Not a standalone compiler these days - perhaps should be > linked as a GHC subproject? > > Other than those I'd propose NHC but I'm guessing that would get some > pushback (even though it currently doesn't build for me). Before > anyone brings up HUGS I'll just say that 1) it is used 2) it builds 3) > at least it's been updated more recently than the Haskell langauge. > I guess we just acknowledge that all implementations are not equal, and for newbies we strongly recommend GHC + Haskell Platform. For reference, we point to a page listing all implementations. This follows convention (i.e. Python, Ruby only point to the canonical impls, not the various forks). -- Don From batterseapower at hotmail.com Mon Jul 20 15:14:30 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Mon Jul 20 14:56:04 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> Message-ID: <9d4d38820907201214n79cc48a8jc5e5f19af511129d@mail.gmail.com> 2009/7/20 Roel van Dijk : > I just realised this is already in GHC :-) But does you patch also add > the equivalent for tuple type annotations? > > x :: (String, ) Double > x = ("Pi", ) 3.14159 It doesn't, and indeed it would only work in the special case where your only missing type arguments are on the right (since we lack type-level lambda, we can only accept eta-reduced forms). So it probably wouldn't be worth it - it wouldn't allow you to write anything significantly shorter than the existing form "(,) String". Cheers, Max From phil at beadling.co.uk Mon Jul 20 16:26:05 2009 From: phil at beadling.co.uk (phil@beadling.co.uk) Date: Mon Jul 20 16:07:44 2009 Subject: [Haskell-cafe] Ambiguous type variable - help! In-Reply-To: <2608b8a80907191318o7a6c6e18s8fddcd4efc9e5341@mail.gmail.com> References: <2608b8a80907191318o7a6c6e18s8fddcd4efc9e5341@mail.gmail.com> Message-ID: <47ED22E9-0828-4B19-A182-6F69DE919CC4@beadling.co.uk> On 19 Jul 2009, at 21:18, Yitzchak Gale wrote: > Hi Phil, > > >> I've concocted a very simple example to illustrate this (below) - but >> it doesn't compile because ghc complains that my type is ambiguous >> arising >> from my use of 'fromSeq'. > > Notice that you have given two completely separate sets > of instructions of what to do depending on whether Int > or Double is selected. You have not given any indication > of how to choose between them, even at runtime. Of course, > the compiler doesn't care that your string constants "Int" and > "Double" happen also to be the names of types if unquoted. I see now. I'm passing fromSeq a SeqType, but it has no way of knowing if I want to process it as an Int or a Double. The only thing which is polymorphic is nextSeq as it must handle the underlying state of Int and Double. Your result function handles the general case and the typeclass instances deal with the specialization depending on the state's type. The printResult function takes in a SeqType and then "parses" (for want of a better word) out the underlying type of Int or Double. It then calls results against the Int or Double which in turn will invoke the correct version of nextSeq. Thank you very much for explaining this! Phil. > > import Control.Monad.State -- Why Strict? Haskell is lazy by default. > Ahh, no reason for the Strict - in the large program I'm righting it is required because otherwise I end up with almighty thunks. But here it serves no purpose. From nicolas.pouillard at gmail.com Mon Jul 20 16:25:30 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Mon Jul 20 16:08:35 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> Message-ID: <1248121473-sup-8534@ausone.local> Excerpts from Max Bolingbroke's message of Sun Jul 19 16:58:08 +0200 2009: > Dear Cafe, > > For fun, I spent a few hours yesterday implement support for this > syntax in GHC, originally propsed by Koen Claessen: > [...] > P.S. I also implemented tuple sections > (http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3) which are > a lot more useful: I vote for both extensions. -- Nicolas Pouillard http://nicolaspouillard.fr From porges at porg.es Mon Jul 20 21:36:04 2009 From: porges at porg.es (porges@porg.es) Date: Mon Jul 20 21:17:54 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: Message-ID: 2009/7/21 Roel van Dijk : >>> I am also wondering what the following would/should mean: >>> >>> ? (1, , ( , 2), ) 'a' 'b' 'c' >> >> I would expect it to be a type error, since I think the following is the >> only sane type the tuple can have (assuming numeric literals :: Int): >> >> (1, , ( , 2), ) :: a -> b -> (Int, a, c -> (c, Int), b) >> >> Ganesh > > Ah you're completely right! I would be applying a tuple to a Char > which is nonsense. You can kind of do it if you indicate which 'field' is to be applied: import Control.Applicative newtype Fst b a = Fst (a,b) deriving (Show) newtype Snd a b = Snd (a,b) deriving (Show) instance Functor (Fst b) where fmap f (Fst (a,b)) = Fst (f a,b) instance Functor (Snd a) where fmap f (Snd (a,b)) = Snd (a,f b) f <$$> x = ($x) <$> f ... > Fst ((,)1,3) <$$> 2 -- no section, don't have the patch ;) Fst ((1,2),3) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 908 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/914e9c57/signature.bin From gwern0 at gmail.com Mon Jul 20 22:02:00 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Jul 20 21:43:35 2009 Subject: [Haskell-cafe] Pruning the Front Page In-Reply-To: <4c44d90b0907201109v75f5427ra5aadefdf1722663@mail.gmail.com> References: <4c44d90b0907201109v75f5427ra5aadefdf1722663@mail.gmail.com> Message-ID: On Mon, Jul 20, 2009 at 2:09 PM, Thomas DuBuisson wrote: > All, > I think we should remove unmaintained or refocused implementations > from the haskell.org front page. ?This would mean removing: > ? ?YHC - unmaintained, hasn't built for me in a while > ? ?LHC - Not a standalone compiler these days - perhaps should be > linked as a GHC subproject? > > Other than those I'd propose NHC but I'm guessing that would get some > pushback (even though it currently doesn't build for me). ?Before > anyone brings up HUGS I'll just say that 1) it is used 2) it builds 3) > at least it's been updated more recently than the Haskell langauge. > > Thomas What about UHC and JHC? They're both maintained (in their varying degrees), but I don't think they can do anything but pure Haskell '98*, and I dunno whether they could even compile the Cabal packages which are/depend only on Haskell '98. What should our criterion be? Just maintained? Maintained and at least able to compile Haskell '98 source? Maintained, able to compile Haskell '98, and also the pure Haskell '98 subset of Hackage? I prefer the last triplet since it's the best for newbies and the minimum necessary for practicality beyond rolling everything oneself, but perhaps that's too strict for everyone else. * by which I mean Haskell '98, the FFI, and hierarchical modules -- gwern From lambda at 10k.org Mon Jul 20 22:15:35 2009 From: lambda at 10k.org (Jake) Date: Mon Jul 20 21:57:09 2009 Subject: [Haskell-cafe] understanding HXT's insertChildrenAfter Message-ID: Playing on HXT 8.3.0 via cabal on GHC 6.10.2. While there are plenty of useful examples of extract data from XML, applying the appropriate API to transform and/or merging still baffle me. In this case, it is the insertChildrenAfter, let's try it with the following example: given 2 files --- update.xml sky is now orange fish is fresh violets are blue --- master.xml sky is blue roses are red game shipped on sunday with the intention of augment the master list with the new items: import Text.XML.HXT.Arrow import qualified Text.XML.HXT.DOM as DOM getMaster = readDocument [(a_validate,v_0)] "master.xml" >>> removeDocWhiteSpace getUpdate = readDocument [(a_validate,v_0)] "update.xml" >>> removeDocWhiteSpace selectUpdateArea = getChildren >>> hasName "news" >>> getChildren >>> hasName "page1" updateContent = insertChildrenAfter (selectUpdateArea) (getUpdate >>> getChildren >>> getChildren) main = do runX ( getMaster >>> updateContent >>> putXmlTree "-" ) instead the following tree is produced: ---XTag "/" | +---XTag "hot" | | | +---XText "sky is red" | +---XTag "hot" | | | +---XText "fish is fresh" | +---XTag "hot" | | | +---XText "violets are blue" | +---XTag "news" | +---XTag "page1" | | | +---XTag "hot" | | | | | +---XText "sky is blue" | | | +---XTag "hot" | | | +---XText "roses are red" | +---XTag "page2" | +---XTag "story" | +---XText "game shipped " Can someone give some examples of how insertChildrenAfter works? How about also some general guidelines when comes to merging/grafting XML documents. Jake From silent_stream at 126.com Tue Jul 21 03:39:59 2009 From: silent_stream at 126.com (silent_stream) Date: Tue Jul 21 03:22:39 2009 Subject: [Haskell-cafe] Re:Haskell-Cafe Digest, Vol 71, Issue 30 In-Reply-To: <20090721014345.7F0A13244A6@www.haskell.org> References: <20090721014345.7F0A13244A6@www.haskell.org> Message-ID: <9587355.243491248162000176.JavaMail.coremail@bj126app45.126.com> When I compile curl-1.3.5 on Windows xp. I run the prompt "runghc Setup.hs configure " I got the following error Setup.hs: Missing dependency on a foreign library: * Missing C library: curl 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 don't know how to fix this problem. Who knows? Please come to help me . ?2009-07-21?09:43:45?haskell-cafe-request@haskell.org???? >Send?Haskell-Cafe?mailing?list?submissions?to > haskell-cafe@haskell.org > >To?subscribe?or?unsubscribe?via?the?World?Wide?Web,?visit > http://www.haskell.org/mailman/listinfo/haskell-cafe >or,?via?email,?send?a?message?with?subject?or?body?'help'?to > haskell-cafe-request@haskell.org > >You?can?reach?the?person?managing?the?list?at > haskell-cafe-owner@haskell.org > >When?replying,?please?edit?your?Subject?line?so?it?is?more?specific >than?"Re:?Contents?of?Haskell-Cafe?digest..." > > >Today's?Topics: > >???1.?Hackage?and?version?control?(Vasili?I.?Galchin) >???2.?FFI?problem?-?possibility?of?CStringLen?overflow??(Robin?Green) >???3.?Re:?FFI?problem?-?possibility?of?CStringLen?overflow? >??????(Bulat?Ziganshin) >???4.?Re:?Hackage?and?version?control?(Magnus?Therning) >???5.?Re:?was:?Debugging?methods?for?haskell?structured data?types >??????the?right?way?in?haskell?(Jon?Fairbairn) >???6.?Re:?Hackage?and?version?control?(Bulat?Ziganshin) >???7.?Re:?Hackage?and?version?control?(Robin?Green) >???8.?Re:?Hackage?and?version?control?(Miguel?Mitrofanov) >???9.?Re:?Hackage?and?version?control?(Joe?Fredette) >??10.?Re:?Hackage?and?version?control?(Wolfgang?Jeltsch) >??11.?Re[2]:?[Haskell-cafe]?Hackage?and?version?control >??????(Bulat?Ziganshin) >??12.?Re:?ANN:?cautious-file?0.1.1:?Ways?to?write?a?file >??????cautiously,?to?avoid?data?loss?(Robin?Green) >??13.?Re:?Implicit?concatenation?in?list?comprehensions?(Roel?van?Dijk) >??14.?Re:?ANN:?cautious-file?0.1.1:?Ways?to?write?a?file >??????cautiously,?to?avoid?data?loss?(Felipe?Lessa) >??15.?Typeclass?default?implementation?in?subclasses?(Andy?Gimblett) >??16.?ICFP?contest?write-up?(Rafael?Gustavo?da?Cunha?Pereira?Pinto) >??17.?SpecConstr?difficulties?(Reiner?Pope) >??18.?Re:?Typeclass?default?implementation?in?subclasses?(Roel?van?Dijk) >??19.?ANNOUNCE:?graphviz-2999.1.0.1?(Ivan?Lazar?Miljenovic) >??20.?Re:?Implicit?concatenation?in?list?comprehensions?(Roel?van?Dijk) >??21.?RE:?Implicit?concatenation?in?list?comprehensions >??????(Sittampalam,?Ganesh) >??22.?Re:?Implicit?concatenation?in?list?comprehensions?(Roel?van?Dijk) >??23.?Re:?FFI?problem?-?possibility?of?CStringLen?overflow? >??????(Jason?Dagit) >??24.?Anglohaskell?-?wifi?signups?(Philippa?Cowderoy) >??25.?Pruning?the?Front?Page?(Thomas?DuBuisson) >??26.?Re:?Pruning?the?Front?Page?(Don?Stewart) >??27.?Re:?Implicit?concatenation?in?list?comprehensions >??????(Max?Bolingbroke) >??28.?Re:?Ambiguous?type?variable?-?help!?(phil@beadling.co.uk) >??29.?Re:?Implicit?concatenation?in?list?comprehensions >??????(Nicolas?Pouillard) >??30.?Re:?Implicit?concatenation?in?list?comprehensions?(porges@porg.es) >??31.?Re:?Pruning?the?Front?Page?(Gwern?Branwen) > > >---------------------------------------------------------------------- > >Message:?1 >Date:?Mon,?20?Jul?2009?03:26:52?-0500 >From:?"Vasili?I.?Galchin"? >Subject:?[Haskell-cafe]?Hackage?and?version?control >To:?haskell-cafe@haskell.org >Cc:?Galchin?Vasili? >Message-ID: > <5ae4f2ba0907200126j56a497earb06ae885dbb7bb81@mail.gmail.com> >Content-Type:?text/plain;?charset="iso-8859-1" > >Hello, > >?????It?seems?to?me?that?Hackage?doesn't?provide?version?control,?e.g.?check >out?and?check?in.?Am?I?incorrect? > >Kind?regards,?Vasili >--------------?next?part?-------------- >An?HTML?attachment?was?scrubbed... >URL:?http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/9a2c1cb3/attachment-0001.html > >------------------------------ > >Message:?2 >Date:?Mon,?20?Jul?2009?03:24:49?+0100 >From:?Robin?Green? >Subject:?[Haskell-cafe]?FFI?problem?-?possibility?of?CStringLen > overflow? >To:?haskell-cafe@haskell.org >Message-ID:?<20090720032449.690fdf47@fedora> >Content-Type:?text/plain;?charset=US-ASCII > >While?rewriting?cautious-file?to?use?ByteStrings?and?FFI?just?now,?I >came?across?this?potential?problem: > >Why?does?the?FFI?specification?define?CStringLen?as?(Ptr?CChar,?Int)? >As?the?FFI?specification?itself?notes,?Haskell?98?implementors?are >allowed?to?have?a?quite?small?range?for?Int?(only?up?to?2^29-1)?-?so?you >could?in?principle?have?a?very?large?String?which?cannot?be?represented >as?a?CStringLen,?or?a?very?large?CString?which?cannot?be?represented?as >a?CStringLen.?They?would?take?up?wads?of?memory,?so?this?has?probably >never?happened?yet,?but?it's?in?principle?possible,?no? > >If?so,?what?are?the?implications?of?this?for?code?correctness? >--? >Robin > > >------------------------------ > >Message:?3 >Date:?Mon,?20?Jul?2009?12:49:38?+0400 >From:?Bulat?Ziganshin? >Subject:?Re:?[Haskell-cafe]?FFI?problem?-?possibility?of?CStringLen > overflow? >To:?Robin?Green? >Cc:?haskell-cafe@haskell.org >Message-ID:?<1096519401.20090720124938@gmail.com> >Content-Type:?text/plain;?charset=us-ascii > >Hello?Robin, > >Monday,?July?20,?2009,?6:24:49?AM,?you?wrote: > >>?Why?does?the?FFI?specification?define?CStringLen?as?(Ptr?CChar,?Int)? > >1.?i?think?it?was?done?to?simplify?using?the?api >2.?hugs?usually?don't?used?for?data-massive?apps,?it's?niche?is?learning?and >quick?development > >--? >Best?regards, >?Bulat????????????????????????????mailto:Bulat.Ziganshin@gmail.com > > > >------------------------------ > >Message:?4 >Date:?Mon,?20?Jul?2009?10:03:56?+0100 >From:?Magnus?Therning? >Subject:?Re:?[Haskell-cafe]?Hackage?and?version?control >To:?"Vasili?I.?Galchin"? >Cc:?haskell-cafe@haskell.org >Message-ID: > >Content-Type:?text/plain;?charset=UTF-8 > >On?Mon,?Jul?20,?2009?at?9:26?AM,?Vasili?I.?Galchin?wrote: >>?Hello, >> >>??????????It?seems?to?me?that?Hackage?doesn't?provide?version?control,?e.g.?check >>?out?and?check?in.?Am?I?incorrect? > >Hackage?is,?AFAIU,?a?repository?where?_released_?versions?of >libraries/tools/etc?related?to?Haskell?can?be?kept.??It?is?not?fully >comparable?to?SourceForge,?Github,?or?any?other?_source?hosting_ >service. > >If?you?are?looking?for?source?hosting?then?take?a?look?at?SF,?Github, >Google?Code,?or?something?like?that.??Then?upload?_released_?versions >to?Hackage.??IIRC?there?is?also?the?possibility?of?having?a?Darcs?repo >on?community.haskell.org. > >/M > >--? >Magnus?Therning????????????????????????(OpenPGP:?0xAB4DFBA4) >magnus???therning???org??????????Jabber:?magnus???therning???org >http://therning.org/magnus?????????identi.ca|twitter:?magthe > > >------------------------------ > >Message:?5 >Date:?Mon,?20?Jul?2009?10:26:02?+0100 >From:?Jon?Fairbairn? >Subject:?[Haskell-cafe]?Re:?was:?Debugging?methods?for?haskell > structured data?types?the?right?way?in?haskell >To:?haskell-cafe@haskell.org >Message-ID:? >Content-Type:?text/plain;?charset=utf-8 > >Fernan?Bolando??writes: > >>?On?Sun,?Jul?19,?2009?at?7:40?AM,?wren?ng?thornton?wrote: >>>?Fernan?Bolando?wrote: >>>> >>>>?The?intention?is?z0?is?a?system?parameter?and?database,?it?contains?a >>>>?set?of?info?needed?to?define?a?particular?simulation >>> >>>?A?single-constructor?ADT,?especially?with?the?labeled-fields?syntax,?is >>>?pretty?close?to?C?structs;?no?need?to?reinvent?them?and?give?yourself >>>?headaches. >>> >>> >>>?Really,?the?only?thing?you?should?be?using?lists?for?is?a?variable-length >>>?sequence?of?elements?drawn?from?the?same?type?and?distinguished?only?by >>>?their?position?in?the?sequence. >> >>?This?is?the?kind?of?code?recommendations?I?was?looking. > >I'd?worked?out?a?longer?reply?over?the?weekend,?but?wren?got?there?first >(It?hadn't?occured?to?me?that?anyone?would?write?that?much?code?without >knowing?about?algebraic?types,?so?thought?something?else?was?going?on). > >I'd?like?to?add?that?thinking?about?the?C?code?for?a?programme?like?this >is?counterproductive.?If?you?are?doing?various?mathematical?operations, >it's?better?to?go?straight?from?the?mathematics?to?Haskell,?and?work?out >the?appropriate?abstractions?(in?Haskell)?for?the?operations?you?are >using.?You'll?generally?end?up?with?much?shorter?code?that?is?easier?to >maintain. > >It?might?be?worth?pointing?out?that?you?can?do?things?with?Haskell?data >structures?that?you?can't?do?conveniently?in?C.?For?example,?if?you?were >doing?something?that?involved?calculating?the?determinants?of?matrices >fairly?often,?but?you?didn't?know?in?advance?which?matrices,?you?could >define?your?own?matrix?type?like?this?(roughly): > >data?MyMatrix?t?=?MM?{theNumbers::?Matrix?t,?my_determinant::?t} > >make_matrix?m >????=?MM?{theNumbers?=?m,? >??????????my_determinant?=?determinant?m >?????????} > >and?then?use?make_matrix?whenever?you?make?a?new?matrix?and >my_determinant?whenever?you?want?a?determinant. > >Now,?although?to?a?C?programmer?this?looks?like?you?calculate?the >determinant?of?every?matrix,?laziness?means?that?you?only?calculate?the >ones?you?use,?and?calculate?them?at?most?once?for?each?matrix. > > >--? >J??n?Fairbairn?????????????????????????????????Jon.Fairbairn@cl.cam.ac.uk > > > > >------------------------------ > >Message:?6 >Date:?Mon,?20?Jul?2009?13:27:06?+0400 >From:?Bulat?Ziganshin? >Subject:?Re:?[Haskell-cafe]?Hackage?and?version?control >To:?"Vasili?I.?Galchin"? >Cc:?haskell-cafe@haskell.org >Message-ID:?<1393740130.20090720132706@gmail.com> >Content-Type:?text/plain;?charset=iso-8859-1 > >Hello?Vasili, > >Monday,?July?20,?2009,?12:26:52?PM,?you?wrote: > >>??????It?seems?to?me?that?Hackage?doesn't?provide?version?control, >>?e.g.?check?out?and?check?in.?Am?I?incorrect? > >i?recommend?you?to?use?either?codeplex?or?code.google > > >--? >Best?regards, >?Bulat????????????????????????????mailto:Bulat.Ziganshin@gmail.com > > > >------------------------------ > >Message:?7 >Date:?Mon,?20?Jul?2009?04:25:25?+0100 >From:?Robin?Green? >Subject:?Re:?[Haskell-cafe]?Hackage?and?version?control >To:?haskell-cafe@haskell.org >Message-ID:?<20090720042525.3e02b4ae@fedora> >Content-Type:?text/plain;?charset=UTF-8 > >On?Mon,?20?Jul?2009?10:03:56?+0100 >Magnus?Therning??wrote: > >>?On?Mon,?Jul?20,?2009?at?9:26?AM,?Vasili?I. >>?Galchin?wrote: >>?>?Hello, >>?> >>?>??????????It?seems?to?me?that?Hackage?doesn't?provide?version?control, >>?>?e.g.?check?out?and?check?in.?Am?I?incorrect? >>? >>?Hackage?is,?AFAIU,?a?repository?where?_released_?versions?of >>?libraries/tools/etc?related?to?Haskell?can?be?kept.??It?is?not?fully >>?comparable?to?SourceForge,?Github,?or?any?other?_source?hosting_ >>?service. >>? >>?If?you?are?looking?for?source?hosting?then?take?a?look?at?SF,?Github, >>?Google?Code,?or?something?like?that.??Then?upload?_released_?versions >>?to?Hackage.??IIRC?there?is?also?the?possibility?of?having?a?Darcs?repo >>?on?community.haskell.org. > >Yes,?and?darcs?repos?can?also?be?hosted?on?patch-tag.com. >community.haskell.org?requires?you?to?wait?for?a?volunteer?to?review >every?new?project?request.?Although,?you?don't?need?to?make?a >project?request?if?you?only?want?a?1-developer?repository.?And?by?the >way,?it?only?hosts?Haskell-related?projects,?not?arbitrary?darcs >repositories. > >patch-tag.com?doesn't?have?those?constraints. >--? >Robin > > >------------------------------ > >Message:?8 >Date:?Mon,?20?Jul?2009?13:41:40?+0400 >From:?Miguel?Mitrofanov? >Subject:?Re:?[Haskell-cafe]?Hackage?and?version?control >To:?Bulat?Ziganshin? >Cc:?"Vasili?I.?Galchin"?, > haskell-cafe@haskell.org >Message-ID:? >Content-Type:?text/plain;?charset=US-ASCII;?format=flowed > >Or?patch-tag.com > >On?20?Jul?2009,?at?13:27,?Bulat?Ziganshin?wrote: > >>?Hello?Vasili, >> >>?Monday,?July?20,?2009,?12:26:52?PM,?you?wrote: >> >>>??????It?seems?to?me?that?Hackage?doesn't?provide?version?control, >>>?e.g.?check?out?and?check?in.?Am?I?incorrect? >> >>?i?recommend?you?to?use?either?codeplex?or?code.google >> >> >>?--? >>?Best?regards, >>?Bulat????????????????????????????mailto:Bulat.Ziganshin@gmail.com >> >>?_______________________________________________ >>?Haskell-Cafe?mailing?list >>?Haskell-Cafe@haskell.org >>?http://www.haskell.org/mailman/listinfo/haskell-cafe > > > >------------------------------ > >Message:?9 >Date:?Mon,?20?Jul?2009?06:36:28?-0400 >From:?Joe?Fredette? >Subject:?Re:?[Haskell-cafe]?Hackage?and?version?control >To:?Bulat?Ziganshin? >Cc:?"Vasili?I.?Galchin"?, > haskell-cafe@haskell.org >Message-ID:?<4A6448AC.6060202@gmail.com> >Content-Type:?text/plain;?charset="iso-8859-1" > >Don't?forget?about?Patch-tag! > >Bulat?Ziganshin?wrote: >>?Hello?Vasili, >> >>?Monday,?July?20,?2009,?12:26:52?PM,?you?wrote: >> >>??? >>>??????It?seems?to?me?that?Hackage?doesn't?provide?version?control, >>>?e.g.?check?out?and?check?in.?Am?I?incorrect? >>>????? >> >>?i?recommend?you?to?use?either?codeplex?or?code.google >> >> >>??? >--------------?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/20090720/42d7f039/jfredett-0001.vcf > >------------------------------ > >Message:?10 >Date:?Mon,?20?Jul?2009?12:40:14?+0200 >From:?Wolfgang?Jeltsch? >Subject:?Re:?[Haskell-cafe]?Hackage?and?version?control >To:?haskell-cafe@haskell.org >Message-ID:?<200907201240.14760.g9ks157k@acme.softbase.org> >Content-Type:?text/plain;??charset="utf-8" > >Am?Montag,?20.?Juli?2009?05:25?schrieb?Robin?Green: >>?community.haskell.org?requires?you?to?wait?for?a?volunteer?to?review >>?every?new?project?request. > >However,?response?times?are?usually?low. > >Best?wishes, >Wolfgang > > >------------------------------ > >Message:?11 >Date:?Mon,?20?Jul?2009?14:41:25?+0400 >From:?Bulat?Ziganshin? >Subject:?Re[2]:?[Haskell-cafe]?Hackage?and?version?control >To:?Joe?Fredette? >Cc:?"Vasili?I.?Galchin"?, Bulat?Ziganshin > ,?haskell-cafe@haskell.org >Message-ID:?<121430820.20090720144125@gmail.com> >Content-Type:?text/plain;?charset=us-ascii > >Hello?Joe, > >Monday,?July?20,?2009,?2:36:28?PM,?you?wrote: > >afaik?it?provides?minimal?features,?only?VCS,?while?sitea?i?mentioned >provides?full?service?for?OSS?developer > >>?Don't?forget?about?Patch-tag! > >>?Bulat?Ziganshin?wrote: >>>?Hello?Vasili, >>> >>>?Monday,?July?20,?2009,?12:26:52?PM,?you?wrote: >>> >>>??? >>>>??????It?seems?to?me?that?Hackage?doesn't?provide?version?control, >>>>?e.g.?check?out?and?check?in.?Am?I?incorrect? >>>>????? >>> >>>?i?recommend?you?to?use?either?codeplex?or?code.google >>> >>> >>>??? > > > >--? >Best?regards, >?Bulat????????????????????????????mailto:Bulat.Ziganshin@gmail.com > > > >------------------------------ > >Message:?12 >Date:?Mon,?20?Jul?2009?06:09:50?+0100 >From:?Robin?Green? >Subject:?Re:?[Haskell-cafe]?ANN:?cautious-file?0.1.1:?Ways?to?write?a > file cautiously,?to?avoid?data?loss >To:?haskell-cafe@haskell.org >Message-ID:?<20090720060950.076176fa@fedora> >Content-Type:?text/plain;?charset=US-ASCII > >I've?since?uploaded?two?new?versions?with?the?following?changes: > >0.1.2:?Fixed?an?issue?where?it?would?clobber?symbolic?links?to?files, >which?is?usually?not?what?you?want.?Test?case?added?for?this. > >0.1.3:?ByteString?support!?FFI?is?also?now?used?under?the?hood?to?do >things?in?a?slightly?less?hacky?way. > >--? >Robin > >On?Sun,?19?Jul?2009?23:35:34?+0100 >Robin?Green??wrote: > >>?I'm?pleased?to?announce?the?first?public?release?of?cautious-file: >>? >>?http://hackage.haskell.org/package/cautious-file > > > >------------------------------ > >Message:?13 >Date:?Mon,?20?Jul?2009?13:27:57?+0200 >From:?Roel?van?Dijk? >Subject:?Re:?[Haskell-cafe]?Implicit?concatenation?in?list > comprehensions >To:?haskell-cafe? >Message-ID: > >Content-Type:?text/plain;?charset=ISO-8859-1 > >I?think?the?tuple?sections?are?a?great?idea!?It?also?makes?tuple?types >and?constructors?more?alike: > >x?::?(,)?String?Double >x?=?(,)?"Pi"?3.14159 > >I?can?also?see?some?uses?in?writing?pointfree?code.?I?would?definitely >want?this?in?a?future?GHC?(or?any?other?Haskell?compiler/interpreter) >release. > >I'm?not?so?sure?about?the?list?comprehension?concatenation.?Like >Thomas?Schilling?wrote,?it?is?only?a?bit?shorter?then?writing?it?with >the?current?syntax.?So?I'm?not?sure?if?it?is?worth?the?cost. > > >------------------------------ > >Message:?14 >Date:?Mon,?20?Jul?2009?09:02:54?-0300 >From:?Felipe?Lessa? >Subject:?Re:?[Haskell-cafe]?ANN:?cautious-file?0.1.1:?Ways?to?write?a > file cautiously,?to?avoid?data?loss >To:?haskell-cafe@haskell.org >Message-ID:?<20090720120254.GA6396@kira.casa> >Content-Type:?text/plain;?charset=us-ascii > >Nice?library! > >On?Sun,?Jul?19,?2009?at?11:35:34PM?+0100,?Robin?Green?wrote: >>?A?variant,?writeFileWithBackup,?also?allows?you?to?supply?a?custom >>?backup?computation?to?backup?old?copy(ies)?of?the?destination?file > >It?would?be?nice?to?have?the?backup?action?receive?the?file?name >as?a?parameter,?so?it?would?be?possible?to?have?a?library?of >possible?backup?strategies.?:) > >-- >Felipe. > > >------------------------------ > >Message:?15 >Date:?Mon,?20?Jul?2009?13:16:03?+0100 >From:?Andy?Gimblett? >Subject:?[Haskell-cafe]?Typeclass?default?implementation?in?subclasses >To:?haskell-cafe@haskell.org >Message-ID:?<5A40667D-984C-4F0A-A7E3-F21980B60CE9@gimbo.org.uk> >Content-Type:?text/plain;?charset=US-ASCII;?format=flowed > >Hi?all, > >This?email?is?literate?Haskell.??I?have?a?question?about?default >implementations?of?typeclasses. > >?>?{-#?LANGUAGE?TypeSynonymInstances?#-} > >?>?module?Thing?where > >?>?import?Text.PrettyPrint.HughesPJ > >Let?say?I?want?to?pretty-print?some?values,?enclosed?in?double?quotes. >The?natural?thing?to?do?(within?the?HughesPJ?pretty-printing >framework,?anyway?-?and?that's?where?I?am?in?this?problem's?wider >context)?is: > >?>?ppQuote?::?Show?a?=>?a?->?Doc >?>?ppQuote?=?doubleQuotes?.?text?.?show > >Now,?this?works?nicely?for?(say)?Int: > >?>?x?::?Int >?>?x?=?1 > >*Thing>?ppQuote?x >"1" > >But?less?nicely?for?String?and?Char,?because?their?Show?instances >already?insert?double/single?quotes?respectively: > >?>?y?::?String >?>?y?=?"hello" >?>?z?::?Char >?>?z?=?'a' > >*Thing>?ppQuote?y >""hello"" >*Thing>?ppQuote?z >"'a'" > >I?don't?want?this.??I'd?like?them?to?be?"hello"?and?"a"?respectively. > >So?I?thought?I'd?create?a?typeclass,?whose?default?implementation?is >as?above... > >?>?class?(Show?a)?=>?Quotable?a?where >?>???quote?::?a?->?Doc >?>???quote?=?ppQuote > >...?but?with?specialised?instances?for?String?and?Char?(the?former >seems?to?need?the?TypeSynonymInstances?extension?): > >?>?instance?Quotable?String?where >?>???quote?=?text?.?show?--?don't?need?the?doubleQuotes?call?for?String >?>?instance?Quotable?Char?where >?>???quote?c?=?quote?[c]?--?just?lift?it?to?String > >Unfortunately,?while?this?works?great?for?String?and?Char... > >*Thing>?quote?y >"hello" >*Thing>?quote?z >"a" > >...?the?"default?implementation"?mechanism?doesn't?work?as?I'd >expect/hope: > >*Thing>?quote?x > >:1:0: >?????No?instance?for?(Quotable?Int) >???????arising?from?a?use?of?`quote'?at?:1:0-6 >?????Possible?fix:?add?an?instance?declaration?for?(Quotable?Int) >?????In?the?expression:?quote?x >?????In?the?definition?of?`it':?it?=?quote?x > >What?I?would?_like_?would?be?for?the?compiler?to?say?"OK,?the?Quotable >class?depends?on?the?Show?class,?and?Int?is?an?instance?of?Show?so?Int >is?also?an?instance?of?Quotable,?having?the?default?implementation >(since?there?isn't?a?specialised?one?for?it)"?-?but?clearly?it >doesn't. > >Please?can?someone?tell?me?why?this?doesn't?happen,?and?if?there?is?a >way?of?making?it?happen???Also,?if?there's?a?more?sensible?way?of >attacking?this?whole?problem,?I'd?be?curious?to?hear?it. > >I?should?perhaps?add?that?this?isn't?a?huge?problem?for?me,?because?my >instances?will?in?practice?tend?to?be?String?and?Char?anyway,?and?one >can?of?course?add?Quotable?instances?for?anything?else?easily?enough?- >but?I'm?curious?now?I've?come?this?far.??:-) > >Many?thanks! > >-Andy > > > >------------------------------ > >Message:?16 >Date:?Mon,?20?Jul?2009?09:30:24?-0300 >From:?Rafael?Gustavo?da?Cunha?Pereira?Pinto > >Subject:?[Haskell-cafe]?ICFP?contest?write-up >To:?Haskell?Caf?? >Message-ID: > <351ff25e0907200530s2c998777g482bd7674ad5d85a@mail.gmail.com> >Content-Type:?text/plain;?charset="iso-8859-1" > >For?all?Portuguese?reading?haskellers,?I?am?describing?my?ICFP?2009?contest >write-up?on?my?blog.?Feel?free?to?comment. > >http://rafaelgcpp.blogspot.com/search/label/ICFP2009 > > >For?the?non-Portuguese?readers,?Google?translation?tools?do?a?lousy?job,?but >it?is?still?readable. > >Regards > >Rafael?Gustavo?da?Cunha?Pereira?Pinto >--------------?next?part?-------------- >An?HTML?attachment?was?scrubbed... >URL:?http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/30061e23/attachment-0001.html > >------------------------------ > >Message:?17 >Date:?Mon,?20?Jul?2009?22:09:09?+0930 >From:?Reiner?Pope? >Subject:?[Haskell-cafe]?SpecConstr?difficulties >To:?Haskell?Cafe?mailing?list? >Message-ID: > <4cf038ee0907200539w1676a6e7ub29350cf5025b91a@mail.gmail.com> >Content-Type:?text/plain;?charset=ISO-8859-1 > >Hi?everyone, > >I've?been?having?some?trouble?getting?SpecConstr?to?work?as?I?want?it >to.?The?following?example?(see?end?of?email)?came?up?in?some?code?I >was?playing?around?with.?The?loops?g1?and?g2?both?compute?the?same >thing:?the?maximum?element?of?the?"list"?(which?has?been?fused?away) >of?numbers?from?1?to?10. > >Since?'maximum'?is?a?foldl1?not?a?foldl,?I?use?a?strict?Maybe?type?as >an?accumulator.?The?Maybe?gets?filled?after?the?first?element?is?seen, >so?the?Maybe?is?a?Just?for?almost?the?entire?running?of?the?loop. > >It?would?be?good?to?have?this?recognised?by?SpecConstr,?to?create?an >optimised?loop?for?the?Just?case.?This?does?indeed?happen?for?g1,?but >not?for?g2. > >My?difficulty?is?that?I?am?only?able?to?produce?code?similar?to?g2, >i.e.?where?the?pattern?matching?is?in?a?separate?function,?'expose', >because?the?'expose'?function?is?implemented?in?a?type-class,?like?in >stream-fusion.?Is?there?some?way?to?keep?the?SpecConstr?while?leaving >the?'expose'?as?a?separate?function? > >Here?is?the?code: > >>?{-#?LANGUAGE?BangPatterns?#-} >> >>?module?Test(ans1,ans2)?where >> >>?import?Prelude?hiding(Maybe(..)) >> >>?data?Maybe?a?=?Just?!a?|?Nothing >> >>?Nothing?`mapp`?Just?b?=?Just?b >>?Just?a?`mapp`?Just?b?=?Just?(max?a?b) >> >>?ans1?=?g1?Nothing?(0::Int) >> >>?g1?m?!n?=?case?m?of >>????????????Nothing?->?if?n?>?10?then?m?else?g1?(m?`mapp`?Just?n)?(n+1) >>????????????Just?x?->?if?n?>?10?then?m?else?g1?(m?`mapp`?Just?n)?(n+1) >> >>?ans2?=?g2?Nothing?(0::Int) >> >>?g2?m?!n?=?expose?m?(if?n?>?10?then?m?else?g2?(m?`mapp`?Just?n)?(n+1)) >>?expose?Nothing??b?=?b >>?expose?(Just?a)?b?=?a?`seq`?b > >On?a?similar?note,?when?I?was?having?difficulties?with?this?problem,?I >started?to?wonder?if?it?would?be?possible?to?come?up?with?a?more >direct?way?to?tell?GHC,?"do?SpecConstr?on?this?variable".?From?reading >the?source?code?of?the?stream-fusion?package,?it?seems?that?the >current?way?of?doing?this?is?with?'expose'?functions?like?I?wrote >below.?Could?we?instead?have?a?{-#?SPECCONSTR?#-}?pragma,?to?be?used >on?function?arguments,?like: > >foo?{-#?SPECCONSTR?#-}?x?y?{-#?SPECCONSTR?#-}?z?=?... > >This?pragma?should?say?to?the?GHC?something?like?"ignore?conditions >H2,?H5?and?H6?of?the?SpecConstr?paper,?for?this?function?and?this >argument". > >Cheers, >Reiner > > >------------------------------ > >Message:?18 >Date:?Mon,?20?Jul?2009?14:40:26?+0200 >From:?Roel?van?Dijk? >Subject:?Re:?[Haskell-cafe]?Typeclass?default?implementation?in > subclasses >To:?Andy?Gimblett? >Cc:?haskell-cafe@haskell.org >Message-ID: > >Content-Type:?text/plain;?charset=ISO-8859-1 > >This?post?is?also?literate?haskell.?By?enabling?these?potentially >dangerous?extensions?you'll?get?the?behaviour?you?want. > >>?{-#?LANGUAGE?TypeSynonymInstances?#-} >>?{-#?LANGUAGE?UndecidableInstances?#-} >>?{-#?LANGUAGE?FlexibleInstances?#-} >>?{-#?LANGUAGE?OverlappingInstances?#-} > >>?module?Thing?where > >>?import?Text.PrettyPrint.HughesPJ > >>?ppQuote?::?Show?a?=>?a?->?Doc >>?ppQuote?=?doubleQuotes?.?text?.?show > >>?x?::?Int >>?x?=?1 > >>?y?::?String >>?y?=?"hello" >>?z?::?Char >>?z?=?'a' > >>?class?(Show?a)?=>?Quotable?a?where >>???quote?::?a?->?Doc >>???quote?=?ppQuote > >>?instance?(Show?a)?=>?Quotable?a > >>?instance?Quotable?String?where >>???quote?=?text?.?show?--?don't?need?the?doubleQuotes?call?for?String > >>?instance?Quotable?Char?where >>???quote?c?=?quote?[c]?--?just?lift?it?to?String > >Example: > >*Thing>?quote?"pi" >"pi" >*Thing>?quote?3.14159 >"3.14159" > > >------------------------------ > >Message:?19 >Date:?Mon,?20?Jul?2009?23:08:49?+1000 >From:?Ivan?Lazar?Miljenovic? >Subject:?[Haskell-cafe]?ANNOUNCE:?graphviz-2999.1.0.1 >To:?haskell@haskell.org >Cc:?haskell-cafe@haskell.org >Message-ID:?<87vdlnwlge.fsf@gmail.com> >Content-Type:?text/plain;?charset=us-ascii > >This?is?a?bug-fix?release?to?fix?the?various?Attribute-related?problems >in?the?previous?release?(2999.0.0.0)?spotted?mainly?by?Zsolt >Dollenstein.??Please?disregard?version?2999.1.0.0;?it?had?a?small?bug. >Similarly,?people?should?avoid?using?2999.0.0.0?unless?they?don't?use >any?Either-based?Attributes. > >The?problem?(which?took?me?a?while?to?realise)?was?that?whilst?I?was >using?Either?to?denote?that?an?attribute?could?take?one?of?two?different >types?of?values?(e.g.?Bool?and?String)?and?the?parsing?for?that?worked. >However,?since?I?was?using?Show?(I?know?it's?bad,?it?was?on?my?TODO, >remember?)??to?generate?the?Dot?code,?then?whenever?one?of?these?values >was?converted?then?either?Left?or?Right?would?appear,?and?GraphViz >doesn't?seem?to?like?that?for?some?reason... > >I?also?took?the?opportunity?to?define?custom?types?for?more?Attributes >(as?they?only?accept?certain?String?values).??Furthermore,?GraphViz >states?that?attributes?that?can?accept?a?boolean?value?are?set?to?True >when?the?attribute?is?listed?on?its?own;?the?library?now?does?this?even >for?those?Attributes?that?use?a?custom?type?that?combines?Bool?with >something?else.??One?other?small?change?is?that?the?Color?Attribute?now >takes?in?a?list?of?Colors;?if?you?only?want?one,?use?a?singleton?list >(it?was?either?that?or?a?custom?datatype?that?takes?either?a?single >Color?or?a?list?of?Colors...). > >Note?that?2999.1.0.0?accidentally?only?had?singleton?Color?values?for >the?Color?Attribute?rather?than?a?list,?hence?the?quick?version?bump. > >Nothing?else?has?changed?in?the?library?apart?from?the?Attributes. > >Regarding?my?request?in?the?previous?email?about?the?possible?new?layout >of?the?DotGraph?datatype: > >How?many?people?actually?build?DotGraphs?by?hand?or?pull?them?apart?by >hand???If?there?were?getNodes?::?DotGraph?->?[Node]?and?getEdges?:: >DotGraph?->?[Edge]?functions?available,?would?you?accept?an?all-in-one >data?type?that?just?contains?a?generic?list?of?statements?and?thus >follows?upstream?more?closely???Even?leaving?aside?parsing,?this?would >allow?for?greater?flexibility?for?creating?wild?and?wacky?graphs?or?for >a?monadic?interface?or?something?for?building?DotGraphs?(which?someone >has?asked?me?for,?but?which?at?the?moment?I?have?no?idea?how?to?do...). > >--? >Ivan?Lazar?Miljenovic >Ivan.Miljenovic@gmail.com >IvanMiljenovic.wordpress.com > > >------------------------------ > >Message:?20 >Date:?Mon,?20?Jul?2009?15:22:24?+0200 >From:?Roel?van?Dijk? >Subject:?Re:?[Haskell-cafe]?Implicit?concatenation?in?list > comprehensions >To:?haskell-cafe? >Message-ID: > >Content-Type:?text/plain;?charset=ISO-8859-1 > >On?Mon,?Jul?20,?2009?at?1:27?PM,?Roel?van?Dijk?wrote: >>?I?think?the?tuple?sections?are?a?great?idea!?It?also?makes?tuple?types >>?and?constructors?more?alike: >> >>?x?::?(,)?String?Double >>?x?=?(,)?"Pi"?3.14159 > >I?just?realised?this?is?already?in?GHC?:-)?But?does?you?patch?also?add >the?equivalent?for?tuple?type?annotations? > >x?::?(String,?)?Double >x?=?("Pi",?)?3.14159 > >I?am?also?wondering?what?the?following?would/should?mean: > >??(1,?,?(?,?2),?)?'a'?'b'?'c' > >Should?this?mean >??(1,?'a',?('b',?2),?'c') >or >??(1,?'a',?('c',?2),?'b') > >Intuitively?I?would?expect?the?first?option.?Just?reading?from?left?to >right.?But?it?doesn't?look?entirely?trivial. > > >------------------------------ > >Message:?21 >Date:?Mon,?20?Jul?2009?14:25:56?+0100 >From:?"Sittampalam,?Ganesh"? >Subject:?RE:?[Haskell-cafe]?Implicit?concatenation?in?list > comprehensions >To:?"haskell-cafe"? >Message-ID: > <16442B752A06A74AB4D9F9A5FF076E4B03B9F7DC@ELON17P32001A.csfb.cs-group.com> > >Content-Type:?text/plain;?charset=us-ascii > >Roel?van?Dijk?wrote: >>?On?Mon,?Jul?20,?2009?at?1:27?PM,?Roel?van >>?Dijk?wrote:? >>>?I?think?the?tuple?sections?are?a?great?idea!?It?also?makes?tuple >>>?types?and?constructors?more?alike:? >>>? >>>?x?::?(,)?String?Double >>>?x?=?(,)?"Pi"?3.14159 >>? >>?I?just?realised?this?is?already?in?GHC?:-)?But?does?you?patch?also >>?add?the?equivalent?for?tuple?type?annotations?? >>? >>?x?::?(String,?)?Double >>?x?=?("Pi",?)?3.14159 >>? >>?I?am?also?wondering?what?the?following?would/should?mean: >>? >>???(1,?,?(?,?2),?)?'a'?'b'?'c' > >I?would?expect?it?to?be?a?type?error,?since?I?think?the?following?is?the >only?sane?type?the?tuple?can?have?(assuming?numeric?literals?::?Int): > >(1,?,?(?,?2),?)?::?a?->?b?->?(Int,?a,?c?->?(c,?Int),?b) > >Ganesh > >===============================================================================? >?Please?access?the?attached?hyperlink?for?an?important?electronic?communications?disclaimer:? >?http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html? >?===============================================================================? >? > > >------------------------------ > >Message:?22 >Date:?Mon,?20?Jul?2009?15:42:08?+0200 >From:?Roel?van?Dijk? >Subject:?Re:?[Haskell-cafe]?Implicit?concatenation?in?list > comprehensions >To:?"Sittampalam,?Ganesh"? >Cc:?haskell-cafe? >Message-ID: > >Content-Type:?text/plain;?charset=ISO-8859-1 > >>>?I?am?also?wondering?what?the?following?would/should?mean: >>> >>>???(1,?,?(?,?2),?)?'a'?'b'?'c' >> >>?I?would?expect?it?to?be?a?type?error,?since?I?think?the?following?is?the >>?only?sane?type?the?tuple?can?have?(assuming?numeric?literals?::?Int): >> >>?(1,?,?(?,?2),?)?::?a?->?b?->?(Int,?a,?c?->?(c,?Int),?b) >> >>?Ganesh > >Ah?you're?completely?right!?I?would?be?applying?a?tuple?to?a?Char >which?is?nonsense. > > >------------------------------ > >Message:?23 >Date:?Mon,?20?Jul?2009?07:02:22?-0700 >From:?Jason?Dagit? >Subject:?Re:?[Haskell-cafe]?FFI?problem?-?possibility?of?CStringLen > overflow? >To:?Robin?Green? >Cc:?haskell-cafe@haskell.org >Message-ID: > >Content-Type:?text/plain;?charset="iso-8859-1" > >On?Sun,?Jul?19,?2009?at?7:24?PM,?Robin?Green??wrote: > >>?While?rewriting?cautious-file?to?use?ByteStrings?and?FFI?just?now,?I >>?came?across?this?potential?problem: >> >>?Why?does?the?FFI?specification?define?CStringLen?as?(Ptr?CChar,?Int)? > > >Do?you?think?it?was?a?typo?and?the?author(s)?meant?(Ptr?CChar,?CInt)?? > >Jason >--------------?next?part?-------------- >An?HTML?attachment?was?scrubbed... >URL:?http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/abed0080/attachment-0001.html > >------------------------------ > >Message:?24 >Date:?Mon,?20?Jul?2009?15:07:23?+0100 >From:?Philippa?Cowderoy? >Subject:?[Haskell-cafe]?Anglohaskell?-?wifi?signups >To:?haskell@haskell.org,?Haskell?cafe? >Message-ID:?<4A647A1B.7010408@flippac.org> >Content-Type:?text/plain;?charset=ISO-8859-1;?format=flowed > >Wifi?signups?are?Anglohaskell?are?now?on?the?wiki?-?please?add?your? >details?by?the?31st?of?July?if?you?want?a?wifi?account?at?MS?Research? >for?the?Friday.?Alternatively,?reply?to?this?email?with?your?full?name,? >institution,?country?of?residence?and?email?address. > >The?Anglohaskell?wiki?page?can?be?found?at? >http://www.haskell.org/haskellwiki/AngloHaskell/2009 > >There's?still?room?for?more?talks?if?anyone's?got?something?they?fancy? >giving?a?go?-?everything?from?cutting?edge?research?to?"what?I?did?with? >Haskell?on?my?holiday"?is?welcome,?as?is?everyone?from?GHC?implentors?to? >newbies?frantically?writing?Hello?World?on?their?laptop?in?the?back?row. > >--? >flippa@flippac.org > > >------------------------------ > >Message:?25 >Date:?Mon,?20?Jul?2009?11:09:40?-0700 >From:?Thomas?DuBuisson? >Subject:?[Haskell-cafe]?Pruning?the?Front?Page >To:?haskell?mailing?list? >Message-ID: > <4c44d90b0907201109v75f5427ra5aadefdf1722663@mail.gmail.com> >Content-Type:?text/plain;?charset=ISO-8859-1 > >All, >I?think?we?should?remove?unmaintained?or?refocused?implementations >from?the?haskell.org?front?page.??This?would?mean?removing: >????YHC?-?unmaintained,?hasn't?built?for?me?in?a?while >????LHC?-?Not?a?standalone?compiler?these?days?-?perhaps?should?be >linked?as?a?GHC?subproject? > >Other?than?those?I'd?propose?NHC?but?I'm?guessing?that?would?get?some >pushback?(even?though?it?currently?doesn't?build?for?me).??Before >anyone?brings?up?HUGS?I'll?just?say?that?1)?it?is?used?2)?it?builds?3) >at?least?it's?been?updated?more?recently?than?the?Haskell?langauge. > >Thomas > > >------------------------------ > >Message:?26 >Date:?Mon,?20?Jul?2009?11:12:16?-0700 >From:?Don?Stewart? >Subject:?Re:?[Haskell-cafe]?Pruning?the?Front?Page >To:?Thomas?DuBuisson? >Cc:?haskell?mailing?list? >Message-ID:?<20090720181216.GL15846@whirlpool.galois.com> >Content-Type:?text/plain;?charset=us-ascii > >thomas.dubuisson: >>?All, >>?I?think?we?should?remove?unmaintained?or?refocused?implementations >>?from?the?haskell.org?front?page.??This?would?mean?removing: >>?????YHC?-?unmaintained,?hasn't?built?for?me?in?a?while >>?????LHC?-?Not?a?standalone?compiler?these?days?-?perhaps?should?be >>?linked?as?a?GHC?subproject? >>? >>?Other?than?those?I'd?propose?NHC?but?I'm?guessing?that?would?get?some >>?pushback?(even?though?it?currently?doesn't?build?for?me).??Before >>?anyone?brings?up?HUGS?I'll?just?say?that?1)?it?is?used?2)?it?builds?3) >>?at?least?it's?been?updated?more?recently?than?the?Haskell?langauge. >>? > >I?guess?we?just?acknowledge?that?all?implementations?are?not?equal,?and >for?newbies?we?strongly?recommend?GHC?+?Haskell?Platform.?For >reference,?we?point?to?a?page?listing?all?implementations. > >This?follows?convention?(i.e.?Python,?Ruby?only?point?to?the?canonical >impls,?not?the?various?forks). > >--?Don > > >------------------------------ > >Message:?27 >Date:?Mon,?20?Jul?2009?20:14:30?+0100 >From:?Max?Bolingbroke? >Subject:?Re:?[Haskell-cafe]?Implicit?concatenation?in?list > comprehensions >To:?Roel?van?Dijk? >Cc:?haskell-cafe? >Message-ID: > <9d4d38820907201214n79cc48a8jc5e5f19af511129d@mail.gmail.com> >Content-Type:?text/plain;?charset=ISO-8859-1 > >2009/7/20?Roel?van?Dijk?: >>?I?just?realised?this?is?already?in?GHC?:-)?But?does?you?patch?also?add >>?the?equivalent?for?tuple?type?annotations? >> >>?x?::?(String,?)?Double >>?x?=?("Pi",?)?3.14159 > >It?doesn't,?and?indeed?it?would?only?work?in?the?special?case?where >your?only?missing?type?arguments?are?on?the?right?(since?we?lack >type-level?lambda,?we?can?only?accept?eta-reduced?forms).?So?it >probably?wouldn't?be?worth?it?-?it?wouldn't?allow?you?to?write >anything?significantly?shorter?than?the?existing?form?"(,)?String". > >Cheers, >Max > > >------------------------------ > >Message:?28 >Date:?Mon,?20?Jul?2009?21:26:05?+0100 >From:?phil@beadling.co.uk >Subject:?Re:?[Haskell-cafe]?Ambiguous?type?variable?-?help! >To:?gale@sefer.org >Cc:?haskell-cafe@haskell.org >Message-ID:?<47ED22E9-0828-4B19-A182-6F69DE919CC4@beadling.co.uk> >Content-Type:?text/plain;?charset=US-ASCII;?format=flowed;?delsp=yes > > >On?19?Jul?2009,?at?21:18,?Yitzchak?Gale?wrote: > >>?Hi?Phil, > >> >> >>>?I've?concocted?a?very?simple?example?to?illustrate?this?(below)?-?but >>>?it?doesn't?compile?because?ghc?complains?that?my?type?is?ambiguous?? >>>?arising >>>?from?my?use?of?'fromSeq'. >> >>?Notice?that?you?have?given?two?completely?separate?sets >>?of?instructions?of?what?to?do?depending?on?whether?Int >>?or?Double?is?selected.?You?have?not?given?any?indication >>?of?how?to?choose?between?them,?even?at?runtime.?Of?course, >>?the?compiler?doesn't?care?that?your?string?constants?"Int"?and >>?"Double"?happen?also?to?be?the?names?of?types?if?unquoted. > >I?see?now.??I'm?passing?fromSeq?a?SeqType,?but?it?has?no?way >of?knowing?if?I?want?to?process?it?as?an?Int?or?a?Double. >The?only?thing?which?is?polymorphic?is?nextSeq?as?it?must?handle >the?underlying?state?of?Int?and?Double. > >Your?result?function?handles?the?general?case?and?the?typeclass >instances?deal?with?the?specialization?depending?on?the?state's?type. > >The?printResult?function?takes?in?a?SeqType?and?then?"parses"?(for?? >want?of >a?better?word)?out?the >underlying?type?of?Int?or?Double.??It?then?calls?results?against?the?? >Int?or?Double?which >in?turn?will?invoke?the?correct?version?of?nextSeq. > > >Thank?you?very?much?for?explaining?this! > > >Phil. > >> >>?import?Control.Monad.State?--?Why?Strict??Haskell?is?lazy?by?default. >> > >Ahh,?no?reason?for?the?Strict?-?in?the?large?program?I'm?righting?it?? >is?required >because?otherwise?I?end?up?with?almighty?thunks.??But?here?it?serves?? >no?purpose. > > > >------------------------------ > >Message:?29 >Date:?Mon,?20?Jul?2009?22:25:30?+0200 >From:?Nicolas?Pouillard? >Subject:?Re:?[Haskell-cafe]?Implicit?concatenation?in?list > comprehensions >To:?Max?Bolingbroke? >Cc:?haskell-cafe? >Message-ID:?<1248121473-sup-8534@ausone.local> >Content-Type:?text/plain;?charset=UTF-8 > >Excerpts?from?Max?Bolingbroke's?message?of?Sun?Jul?19?16:58:08?+0200?2009: >>?Dear?Cafe, >>? >>?For?fun,?I?spent?a?few?hours?yesterday?implement?support?for?this >>?syntax?in?GHC,?originally?propsed?by?Koen?Claessen: >>? > >[...] > >>?P.S.?I?also?implemented?tuple?sections >>?(http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3)?which?are >>?a?lot?more?useful: > >I?vote?for?both?extensions. > >--? >Nicolas?Pouillard >http://nicolaspouillard.fr > > >------------------------------ > >Message:?30 >Date:?Tue,?21?Jul?2009?13:36:04?+1200?(NZST) >From:?porges@porg.es >Subject:?Re:?[Haskell-cafe]?Implicit?concatenation?in?list > comprehensions >To:?Roel?van?Dijk? >Cc:?haskell-cafe?,?"Sittampalam, Ganesh" > >Message-ID:? >Content-Type:?text/plain;?charset="utf-8" > >2009/7/21?Roel?van?Dijk?: >>>>?I?am?also?wondering?what?the?following?would/should?mean: >>>> >>>>????(1,?,?(?,?2),?)?'a'?'b'?'c' >>> >>>?I?would?expect?it?to?be?a?type?error,?since?I?think?the?following?is?the >>>?only?sane?type?the?tuple?can?have?(assuming?numeric?literals?::?Int): >>> >>>?(1,?,?(?,?2),?)?::?a?->?b?->?(Int,?a,?c?->?(c,?Int),?b) >>> >>>?Ganesh >> >>?Ah?you're?completely?right!?I?would?be?applying?a?tuple?to?a?Char >>?which?is?nonsense. > >You?can?kind?of?do?it?if?you?indicate?which?'field'?is?to?be?applied: > >??import?Control.Applicative > >??newtype?Fst?b?a?=?Fst?(a,b)?deriving?(Show) >??newtype?Snd?a?b?=?Snd?(a,b)?deriving?(Show) > >??instance?Functor?(Fst?b)?where >?? fmap?f?(Fst?(a,b))?=?Fst?(f?a,b) > >??instance?Functor?(Snd?a)?where >?? fmap?f?(Snd?(a,b))?=?Snd?(a,f?b) > >??f?<$$>?x?=?($x)?<$>?f > >... > >>?Fst?((,)1,3)?<$$>?2?--?no?section,?don't?have?the?patch?;) >Fst?((1,2),3) >--------------?next?part?-------------- >A?non-text?attachment?was?scrubbed... >Name:?signature.asc >Type:?application/pgp-signature >Size:?908?bytes >Desc:?OpenPGP?digital?signature >Url?:?http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/914e9c57/signature-0001.bin > >------------------------------ > >Message:?31 >Date:?Mon,?20?Jul?2009?22:02:00?-0400 >From:?Gwern?Branwen? >Subject:?Re:?[Haskell-cafe]?Pruning?the?Front?Page >To:?Thomas?DuBuisson? >Cc:?haskell?mailing?list? >Message-ID: > >Content-Type:?text/plain;?charset=UTF-8 > >On?Mon,?Jul?20,?2009?at?2:09?PM,?Thomas >DuBuisson?wrote: >>?All, >>?I?think?we?should?remove?unmaintained?or?refocused?implementations >>?from?the?haskell.org?front?page.???This?would?mean?removing: >>??????YHC?-?unmaintained,?hasn't?built?for?me?in?a?while >>??????LHC?-?Not?a?standalone?compiler?these?days?-?perhaps?should?be >>?linked?as?a?GHC?subproject? >> >>?Other?than?those?I'd?propose?NHC?but?I'm?guessing?that?would?get?some >>?pushback?(even?though?it?currently?doesn't?build?for?me).???Before >>?anyone?brings?up?HUGS?I'll?just?say?that?1)?it?is?used?2)?it?builds?3) >>?at?least?it's?been?updated?more?recently?than?the?Haskell?langauge. >> >>?Thomas > >What?about?UHC?and?JHC??They're?both?maintained?(in?their?varying >degrees),?but?I?don't?think?they?can?do?anything?but?pure?Haskell >'98*,?and?I?dunno?whether?they?could?even?compile?the?Cabal?packages >which?are/depend?only?on?Haskell?'98. > >What?should?our?criterion?be??Just?maintained??Maintained?and?at?least >able?to?compile?Haskell?'98?source??Maintained,?able?to?compile >Haskell?'98,?and?also?the?pure?Haskell?'98?subset?of?Hackage? > >I?prefer?the?last?triplet?since?it's?the?best?for?newbies?and?the >minimum?necessary?for?practicality?beyond?rolling?everything?oneself, >but?perhaps?that's?too?strict?for?everyone?else. > >*?by?which?I?mean?Haskell?'98,?the?FFI,?and?hierarchical?modules > >--? >gwern > > >------------------------------ > >_______________________________________________ >Haskell-Cafe?mailing?list >Haskell-Cafe@haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe > > >End?of?Haskell-Cafe?Digest,?Vol?71,?Issue?30 >******************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090721/2d9cb79b/attachment-0001.html From duncan.coutts at worc.ox.ac.uk Mon Jul 20 15:53:55 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jul 21 04:52:37 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> Message-ID: <1248119635.3163.32.camel@localhost> On Sun, 2009-07-19 at 23:07 +0100, Thomas Schilling wrote: > 2009/7/19 Max Bolingbroke > > > > Dear Cafe, > > > > For fun, I spent a few hours yesterday implement support for this > > syntax in GHC, originally propsed by Koen Claessen: > > > > >>> [k, "=", v, " " | (k, v) <- [("foo", "1"), ("bar", "2")] > > ["foo", "=", "1", " ", "bar", "=", "2", " "] > > Given that this can easily be simulated via: > > >>> [ x | (k, v) <- [("foo", "1"), ("bar", "2")], x <- [k, "=", v, " "]] > ["foo","=","1"," ","bar","=","2"," "] > > I believe that the added syntax (which every complete tool operating > on Haskell code would have to support) is not worth its price. Except that it's ugly compared to the proposed extension. With the extension you can put things in the same, right place: renderGhcOptions opts = ghcOptExtraPre opts -- source search path ++ [ "-i" | not (null (ghcOptSearchPath opts)) ] ++ [ "-i", dir | dir <- ghcOptSearchPath opts ] or using your syntax: ++ [ opt | dir <- ghcOptSearchPath opts | opt <- [ "-i", dir ] ] or another not-so-nice alternative: ++ concat [ [ "-i", dir ] | dir <- ghcOptSearchPath opts ] When looking down a bunch of these cases, using the extension means we can put the most important bit --- the flag names and arguments --- in the same position rather than sometime having to put them at the end in an extra generator, or having to use extra brackets and a concat. So yes you can certainly simulate it but it does not read nearly so well. Duncan From ndmitchell at gmail.com Tue Jul 21 05:26:55 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Jul 21 05:08:27 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <1248119635.3163.32.camel@localhost> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> Message-ID: <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> > Except that it's ugly compared to the proposed extension. With the > extension you can put things in the same, right place: > > renderGhcOptions opts = > ? ? ghcOptExtraPre opts > > ?-- source search path > ?++ [ "-i" ? ? ?| not (null (ghcOptSearchPath opts)) ] > ?++ [ "-i", dir | dir <- ghcOptSearchPath opts ] Following the discussions, I now support this extension too - I keep seeing more and more places in my code where it would be very useful. Thanks Neil From bulat.ziganshin at gmail.com Tue Jul 21 05:34:57 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jul 21 05:16:38 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> Message-ID: <5410563564.20090721133457@gmail.com> Hello Neil, Tuesday, July 21, 2009, 1:26:55 PM, you wrote: >> ?++ [ "-i" ? ? ?| not (null (ghcOptSearchPath opts)) ] >> ?++ [ "-i", dir | dir <- ghcOptSearchPath opts ] > Following the discussions, I now support this extension too - I keep > seeing more and more places in my code where it would be very useful. >> ?++ [ "-i" ? ? ?| not (null (ghcOptSearchPath opts)) ] >> ?++ concat [ ["-i", dir] | dir <- ghcOptSearchPath opts ] -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Tue Jul 21 12:11:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jul 21 11:53:30 2009 Subject: [Haskell-cafe] Re[2]: [Haskell] TABI 0.1: a typeful tagged cross-language calling convention In-Reply-To: <20090721153844.GA20298@kira.casa> References: <644954872.20090721175104@gmail.com> <20090721153844.GA20298@kira.casa> Message-ID: <29514685.20090721201147@gmail.com> Hello Felipe, Tuesday, July 21, 2009, 7:38:44 PM, you wrote: >> * passing complex datastructures between various languages forth >> and back, providing faster alternative to serialization approach > I've read the code and I don't see how tabi manages to do this. it's not yet implemented :))) my idea is to provide one more basic type, TABI_TABLE=6, that allows to nest TABI_MAPs recursively. also arrays of TABI_* types may be supported > It is serializing as well but it is including the type and name > information, so it seems that at best it would have the same > overhead as just serializing the data without any metadata. my first approach was to use just serialization (it was implemented in Lua sources included). but then i realized that it is monkey work - most time will be spent copying data to buffer, from buffer, searching for delimiters, processing type conversion. i'm pretty sure that C implementation of TABI_MAP will do its work (filling 3-4 words per parameter) an order of magnitude faster than serialization approach. also, serialized data anyway will be need to converted to datastructure like TABI_MAP in order to be used by calls like _str and _int for Haskell code, good optimized serialization library should have comparable speed. moreover, my current approach with malloc() calls probably makes encoding operations much slower if you have any specific needs, we can discuss it. my own needs is mainly combination of first and third clauses of quoted list, so second claim is somewhat artificial :) it is possible but only partially implemented -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From nominolo at googlemail.com Tue Jul 21 12:17:30 2009 From: nominolo at googlemail.com (Thomas Schilling) Date: Tue Jul 21 11:59:21 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <1248119635.3163.32.camel@localhost> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> Message-ID: <916b84820907210917i598f671ax6414a1bba9581859@mail.gmail.com> I'm not convinced "ugly" is a good reason to add more complexity to the language syntax. I am not aware of a good metric to measure the costs/beneficts of new syntactic constructs. Part of the costs are the number of tools that need to be adapted and the extend of their loss of utility if they are not adopted. Granted, we don't have that many tools working on Haskell code, but perhaps the feature-creep is part of the reason (cf. HaRe). Sure, the eagerness of new features added to Haskell (well, GHC mostly) is part reason of Haskell's success. Since we don't have an objective measure, all I can do is to ask people to consider that new syntax is not as cheap as it many seem to think it is. 2009/7/20 Duncan Coutts : > On Sun, 2009-07-19 at 23:07 +0100, Thomas Schilling wrote: >> 2009/7/19 Max Bolingbroke >> > >> > Dear Cafe, >> > >> > For fun, I spent a few hours yesterday implement support for this >> > syntax in GHC, originally propsed by Koen Claessen: >> > >> > >>> [k, "=", v, " " | (k, v) <- [("foo", "1"), ("bar", "2")] >> > ["foo", "=", "1", " ", "bar", "=", "2", " "] >> >> Given that this can easily be simulated via: >> >> >>> [ x | (k, v) <- [("foo", "1"), ("bar", "2")], x <- [k, "=", v, " "]] >> ["foo","=","1"," ","bar","=","2"," "] >> >> I believe that the added syntax (which every complete tool operating >> on Haskell code would have to support) is not worth its price. > > Except that it's ugly compared to the proposed extension. With the > extension you can put things in the same, right place: > > renderGhcOptions opts = > ? ? ghcOptExtraPre opts > > ?-- source search path > ?++ [ "-i" ? ? ?| not (null (ghcOptSearchPath opts)) ] > ?++ [ "-i", dir | dir <- ghcOptSearchPath opts ] > > or using your syntax: > > ?++ [ opt | dir <- ghcOptSearchPath opts > ? ? ? ? ? | opt <- [ "-i", dir ] ] > > or another not-so-nice alternative: > > ?++ concat > ? ? [ [ "-i", dir ] | dir <- ghcOptSearchPath opts ] > > > When looking down a bunch of these cases, using the extension means we > can put the most important bit --- the flag names and arguments --- in > the same position rather than sometime having to put them at the end in > an extra generator, or having to use extra brackets and a concat. > > So yes you can certainly simulate it but it does not read nearly so > well. > > Duncan > > -- Push the envelope. Watch it bend. From felipe.lessa at gmail.com Tue Jul 21 13:37:15 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Jul 21 13:18:55 2009 Subject: [Haskell-cafe] Re: [Haskell] TABI 0.1: a typeful tagged cross-language calling convention In-Reply-To: <29514685.20090721201147@gmail.com> References: <644954872.20090721175104@gmail.com> <20090721153844.GA20298@kira.casa> <29514685.20090721201147@gmail.com> Message-ID: <20090721173715.GA26270@kira.casa> On Tue, Jul 21, 2009 at 08:11:47PM +0400, Bulat Ziganshin wrote: > if you have any specific needs, we can discuss it. my own needs is > mainly combination of first and third clauses of quoted list, so > second claim is somewhat artificial :) it is possible but only > partially implemented I was just curious, because it seems to me that the only way of avoiding serialization costs would be having the same representation in memory for all languages and just passing pointers around instead of peek'ing and poke'ing everytime. Thanks, -- Felipe. From list at phaedrusdeinus.org Tue Jul 21 14:52:58 2009 From: list at phaedrusdeinus.org (John Melesky) Date: Tue Jul 21 14:35:11 2009 Subject: [Haskell-cafe] Re: [Haskell] TABI 0.1: a typeful tagged cross-language calling convention In-Reply-To: <20090721173715.GA26270@kira.casa> References: <644954872.20090721175104@gmail.com> <20090721153844.GA20298@kira.casa> <29514685.20090721201147@gmail.com> <20090721173715.GA26270@kira.casa> Message-ID: <48DAA957-A47A-4D29-A524-3A9128BB6097@phaedrusdeinus.org> On Jul 21, 2009, at 10:37 AM, Felipe Lessa wrote: > it seems to me that the only way of > avoiding serialization costs would be having the same > representation in memory for all languages and just passing > pointers around instead of peek'ing and poke'ing everytime. Alternately, a whole slew of point-to-point translators might do the trick. Haskell to Lua (and back), Lua to Ocaml (and back), Ocaml to Ruby (and back), Ruby to Lua, etc., etc. That's a great deal of overhead beyond the "canonical representation" method, but it would achieve translation without explicit serialization. -johnnnnnn From westondan at imageworks.com Tue Jul 21 15:29:18 2009 From: westondan at imageworks.com (Dan Weston) Date: Tue Jul 21 15:10:54 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <5410563564.20090721133457@gmail.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> <5410563564.20090721133457@gmail.com> Message-ID: <4A66170E.6090100@imageworks.com> Bulat Ziganshin wrote: > Hello Neil, > > Tuesday, July 21, 2009, 1:26:55 PM, you wrote: > >>> ++ [ "-i" | not (null (ghcOptSearchPath opts)) ] >>> ++ [ "-i", dir | dir <- ghcOptSearchPath opts ] > >> Following the discussions, I now support this extension too - I keep >> seeing more and more places in my code where it would be very useful. > >>> ++ [ "-i" | not (null (ghcOptSearchPath opts)) ] >>> ++ concat [ ["-i", dir] | dir <- ghcOptSearchPath opts ] [a | c ] = concat $ do { c; return [a] } [a,b | c ] = concat $ do { c; return [a,b] } This would mean that [ | c ] = concat $ do { c; return [] } The right is legal Haskell and gives []. The left is (not yet) legal. Should it be? Dan From kowey at darcs.net Tue Jul 21 17:23:12 2009 From: kowey at darcs.net (Eric Kow) Date: Tue Jul 21 17:04:46 2009 Subject: [Haskell-cafe] cheap in-repo local branches (just needs implementation) Message-ID: <20090721212311.GV9714@brighton.ac.uk> Hi everyone, Max Battcher had an idea that I thought I should post on the mailing list. The idea is about making branches in darcs. Right now, we take the view that a darcs branch is a darcs repository plain and simple. If you want to create a branch, all you have to do is darcs get (darcs get --lazy to be faster). While this is very simple, a lot of us think that it's inconvenient (one because it's slow, and two because you have to think of where to put the branch). So darcs users have been asking about in-repo branches for a while. And now, Max has come up with a way to implement them. What's nice about his approach is that it lets us keep the simplicity of darcs, while giving more demanding users a chance to work with branches. It also takes advantage of the Petr Ro?kai's Summer of Code project to make darcs faster in our daily lives and for the matter, paves the way for a possible darcs plugin system in the future. On Max's advice, I'm cross-posting to Haskell Cafe. Haskellers: here's a nice chance for you get a cool Darcs feature without not very much effort or Darcs hacking experience :-) More info on: http://bugs.darcs.net/issue555 ------------------------------------------------------------ Max's write-up ------------------------------------------------------------ Here's a quick primer: Basically, darcs >= 2.0 uses a hashed pristine store that acts as a file object cache. An interesting artifact of the pristine.hashed store, which is being pushed into a useful third-party accessible library named hashed-storage, however, is that it does (for many reasons, most co-evolutionary) resemble the git object store. There are several differences, but one of the key differences that applies to the topic at hand is that darcs generally garbage collects pristine.hashed objects much faster than git. Darcs is very quick to garbage collect old objects partly because many aren't all that useful, but mostly because the primary representation for a repository state is the patch store (and inventory), so there is only one root pointer in the pristine store. Petr, the author of the hashed-storage library, briefly discusses this in his most recent design post about the future of hashed-storage: http://mornfall.net/blog/designing_storage_for_darcs.html Here's where the primer meets the topic at hand: A darcs branch consists of three major components: an inventory store, a patch store, and a pristine store. To store multiple branches "in the same place" you need to take care of: 1) storing the alternate inventories, and 2) if you want it to be relatively fast, storing additional objects in the pristine store. (The patch store will already happily hold more patches than are referenced in the current inventory.) (1) is mostly a matter of naming alternate inventories and swapping between them. Thanks to the *ahem* git-like nature of pristine.hashed/hashed-storage: darcs could easily archive (many) more pristine objects, than it will during normal operation, in pristine.hashed and it may be as simple as storing additional, useful "root pointers" visible to hashed-storage so that it knows not to garbage collect the objects from other branches. Here's where the fun happens: It seems to me that a branch switching tool, utilizing darcs' existing repository data stores, could be built almost "purely" on top of mostly just the hashed-storage library (which has been designed for reuse), as it exists today or hopefully with only minor tweaking, and with only minimal interaction with darcs itself. That is, in-repo branching could be provided entirely, today or soon, as a second/third-party tool to darcs. (!) I think this is great from a darcs perspective: darcs itself remains conceptually simple (1 repository == 1 branch), which is something that I for one love about darcs, and doesn't need additional commands in darcs iteslf. But yet, power users (and git escapees) would have easy access to a ``darcs-branch`` tool that provides simple and powerful in-repo switching. Potentially, such a tool is also a great candidate to be an earlier adopter for the darcs library support and can help better define and enhance darcs' public API. (It's also interesting in that it mirrors that hg's support for branches is an addon, and that both hg and git have darcs-like patch queues as addons.) I think this is even better from a hashed-storage perspective: ``darcs-branch`` would be a strong (new) use case for hashed-storage as a public API. The tool would provide good incentive to keep hashed-storage's API clean, and better incentive (than darcs' normal operation) to keep hashed-storage's garbage collection and object compaction strong. (With the 'cheap' cost of in-repo branches primarily a consequence of how well hashed-storage stores the additional objects of multiple branches. As a bonus, normal darcs operations should benefit as well from the gc/compaction optimizations that darcs-branch operations may make more obvious.) At a high-level, a ``darcs-branch`` tool would provide core commands to: 1) Store the current repository state as a new branch by copying the current inventory and inserting a new pristine root for the branch. (``darcs-branch new`` or ``darcs-branch freeze``, perhaps) 2) Switch to a previously stored branch, by making the branch's inventory the new current inventory and the branch's pristine root the new current pristine root; updating the working directory as necessary. (``darcs-branch switch``) Additionally, there would be other useful management tools (``darcs-branch list``, ``darcs-branch remove`` (or unfreeze)). I think that these four commands could be done with no darcs interaction at all (unless the branch being switched to has an incomplete/lazy pristine). Useful commands that would need darcs interaction for patch management would be things like ``darcs-branch push`` to push patches between named branches (equivalent at a high level to ``darcs send -o new.dpatch --context branchB.context; darcs-branch switch branchB; darcs apply new.dpatch``), and ``darcs-branch obtain`` to obtain new in-repo local branches from an existing context file, remote/external-local repository, tag, or other matcher (that is, darcs get from one in-repo branch to a new one). I doubt that a ``darcs-branch get`` to download all of the branches other than "current" (or HEAD, if you prefer, or "main" as I prefer) of a remote repository would need any darcs interaction (downloading the inventories and then many/most/all of the pristine objects). We can bet that darcs' usual lazy patch-getting behavior should work out of the box even for multiple branches. Well, that's the general idea, at least. I believe that a willing volunteer and a bit of help from Petr could build such a tool "relatively quickly" and hopefully might even possibly work with today's darcs as it is. -- 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/20090721/201353c1/attachment.bin From jgbailey at gmail.com Tue Jul 21 19:42:19 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Tue Jul 21 19:24:11 2009 Subject: [Haskell-cafe] cheap in-repo local branches (just needs implementation) In-Reply-To: <20090721212311.GV9714@brighton.ac.uk> References: <20090721212311.GV9714@brighton.ac.uk> Message-ID: I like it. git branches are nice to work with, and they don't the conceptual pain of "creating" an new repository. Things that make them nice: * When switching branches, all your files magically update (if they have not been modified). * Easy to maintain multiple branches, say "stable" and "experimental". That helps me avoid getting clobbered by other's changes to APIs I depend on. Things that are a pain: * Comparing commits (patches) between branches. Its hard to tell what is one and what is in another. * When you have modified files, git is super picky about switching branches. * Once a remote branch is pushed to a public repo, its scary to remove it. You don't want to break somebody, but you don't want that old junk hanging around either. I don't mean to write about git, but if darcs was to have branches, thats the kind of stuff I would love to see. On Tue, Jul 21, 2009 at 2:23 PM, Eric Kow wrote: > Hi everyone, > > Max Battcher had an idea that I thought I should post on the mailing list. > > The idea is about making branches in darcs. ?Right now, we take the view that a > darcs branch is a darcs repository plain and simple. ?If you want to create a > branch, all you have to do is darcs get (darcs get --lazy to be faster). ?While > this is very simple, a lot of us think that it's inconvenient (one because it's > slow, and two because you have to think of where to put the branch). > > So darcs users have been asking about in-repo branches for a while. ?And now, > Max has come up with a way to implement them. ?What's nice about his approach > is that it lets us keep the simplicity of darcs, while giving more demanding > users a chance to work with branches. ?It also takes advantage of the Petr > Ro?kai's Summer of Code project to make darcs faster in our daily lives and for > the matter, paves the way for a possible darcs plugin system in the future. > > On Max's advice, I'm cross-posting to Haskell Cafe. ?Haskellers: here's a nice > chance for you get a cool Darcs feature without not very much effort or Darcs > hacking experience :-) > > More info on: http://bugs.darcs.net/issue555 > > ------------------------------------------------------------ > Max's write-up > ------------------------------------------------------------ > > Here's a quick primer: Basically, darcs >= 2.0 uses a hashed pristine > store that acts as a file object cache. An interesting artifact of the > pristine.hashed store, which is being pushed into a useful third-party > accessible library named hashed-storage, however, is that it does (for > many reasons, most co-evolutionary) resemble the git object store. There > are several differences, but one of the key differences that applies to > the topic at hand is that darcs generally garbage collects > pristine.hashed objects much faster than git. > > Darcs is very quick to garbage collect old objects partly because many > aren't all that useful, but mostly because the primary representation > for a repository state is the patch store (and inventory), so there is > only one root pointer in the pristine store. Petr, the author of the > hashed-storage library, briefly discusses this in his most recent design > post about the future of hashed-storage: > > http://mornfall.net/blog/designing_storage_for_darcs.html > > Here's where the primer meets the topic at hand: A darcs branch consists > of three major components: an inventory store, a patch store, and a > pristine store. To store multiple branches "in the same place" you need > to take care of: 1) storing the alternate inventories, and 2) if you > want it to be relatively fast, storing additional objects in the > pristine store. (The patch store will already happily hold more patches > than are referenced in the current inventory.) (1) is mostly a matter of > naming alternate inventories and swapping between them. Thanks to the > *ahem* git-like nature of pristine.hashed/hashed-storage: darcs could > easily archive (many) more pristine objects, than it will during normal > operation, in pristine.hashed and it may be as simple as storing > additional, useful "root pointers" visible to hashed-storage so that it > knows not to garbage collect the objects from other branches. > > Here's where the fun happens: It seems to me that a branch switching > tool, utilizing darcs' existing repository data stores, could be built > almost "purely" on top of mostly just the hashed-storage library (which > has been designed for reuse), as it exists today or hopefully with only > minor tweaking, and with only minimal interaction with darcs itself. > That is, in-repo branching could be provided entirely, today or soon, as > a second/third-party tool to darcs. (!) > > I think this is great from a darcs perspective: darcs itself remains > conceptually simple (1 repository == 1 branch), which is something that > I for one love about darcs, and doesn't need additional commands in > darcs iteslf. But yet, power users (and git escapees) would have easy > access to a ``darcs-branch`` tool that provides simple and powerful > in-repo switching. Potentially, such a tool is also a great candidate to > be an earlier adopter for the darcs library support and can help better > define and enhance darcs' public API. (It's also interesting in that it > mirrors that hg's support for branches is an addon, and that both hg and > git have darcs-like patch queues as addons.) > > I think this is even better from a hashed-storage perspective: > ``darcs-branch`` would be a strong (new) use case for hashed-storage as > a public API. The tool would provide good incentive to keep > hashed-storage's API clean, and better incentive (than darcs' normal > operation) to keep hashed-storage's garbage collection and object > compaction strong. (With the 'cheap' cost of in-repo branches primarily > a consequence of how well hashed-storage stores the additional objects > of multiple branches. As a bonus, normal darcs operations should benefit > as well from the gc/compaction optimizations that darcs-branch > operations may make more obvious.) > > At a high-level, a ``darcs-branch`` tool would provide core commands to: > > 1) Store the current repository state as a new branch by copying the > current inventory and inserting a new pristine root for the branch. > (``darcs-branch new`` or ``darcs-branch freeze``, perhaps) > > 2) Switch to a previously stored branch, by making the branch's > inventory the new current inventory and the branch's pristine root the > new current pristine root; updating the working directory as necessary. > (``darcs-branch switch``) > > Additionally, there would be other useful management tools > (``darcs-branch list``, ``darcs-branch remove`` (or unfreeze)). I think > that these four commands could be done with no darcs interaction at all > (unless the branch being switched to has an incomplete/lazy pristine). > > Useful commands that would need darcs interaction for patch management > would be things like ``darcs-branch push`` to push patches between named > branches (equivalent at a high level to ``darcs send -o new.dpatch > --context branchB.context; darcs-branch switch branchB; darcs apply > new.dpatch``), and ``darcs-branch obtain`` to obtain new in-repo local > branches from an existing context file, remote/external-local > repository, tag, or other matcher (that is, darcs get from one in-repo > branch to a new one). > > I doubt that a ``darcs-branch get`` to download all of the branches > other than "current" (or HEAD, if you prefer, or "main" as I prefer) of > a remote repository would need any darcs interaction (downloading the > inventories and then many/most/all of the pristine objects). We can bet > that darcs' usual lazy patch-getting behavior should work out of the box > even for multiple branches. > > Well, that's the general idea, at least. I believe that a willing > volunteer and a bit of help from Petr could build such a tool > "relatively quickly" and hopefully might even possibly work with today's > darcs as it is. > > -- > Eric Kow > PGP Key ID: 08AC04F9 > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkpmMb4ACgkQBUrOwgisBPlvzwCfbgyQQ/fV6QfAl4NgKJpjx7Bw > 7QYAoOEaF2XrNyqJ9tfUjvJpgc/KjkYI > =nZFr > -----END PGP SIGNATURE----- > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From felipe.lessa at gmail.com Tue Jul 21 19:43:15 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Jul 21 19:24:50 2009 Subject: [Haskell-cafe] Implicit concatenation in list comprehensions In-Reply-To: <4A66170E.6090100@imageworks.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> <5410563564.20090721133457@gmail.com> <4A66170E.6090100@imageworks.com> Message-ID: <20090721234315.GB13886@kira.casa> On Tue, Jul 21, 2009 at 12:29:18PM -0700, Dan Weston wrote: > This would mean that > > [ | c ] = concat $ do { c; return [] } > > The right is legal Haskell and gives []. The left is (not yet) > legal. Should it be? Please, please, do not allow that. People wanting [] should write []. Thanks! -- Felipe. From relapse.dev at gmx.com Tue Jul 21 21:48:38 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Tue Jul 21 21:32:36 2009 Subject: [Haskell-cafe] System.Mem.performGC leaks? Message-ID: main = forever performGC The OS reported memory usage skyrockets. If i enable +RTS -S the GC statistics show the heap "live bytes" being constant. Is it accumulating statistics even when profiling is disabled (and can you turn that off), or is there something going on with the FFI call to performGC. Compiled with "ghc -O2 -fvia-C -optc-O2 -funbox-strict-fields -threaded" btw. From relapse.dev at gmx.com Tue Jul 21 21:51:03 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Tue Jul 21 21:36:33 2009 Subject: [Haskell-cafe] Re: System.Mem.performGC leaks? In-Reply-To: References: Message-ID: Neal Alexander wrote: > Compiled with "ghc -O2 -fvia-C -optc-O2 -funbox-strict-fields -threaded" > btw. GHC 6.10.3 on 64bit windows7. From nbloomf at gmail.com Tue Jul 21 22:52:08 2009 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Tue Jul 21 22:33:38 2009 Subject: [Haskell-cafe] Simple quirk in behavior of `mod` Message-ID: <9858b5620907211952w73abe9aak53a7db6dbfa315bd@mail.gmail.com> Hello haskell-cafe; I'm fiddling with thisblog post about inverting elements of Z/(p), trying to write the inversion function in pointfree style. This led me to try executing statements like n `mod` 0 which in the ring theoretic sense should be n, at least for integers*. (MathWorld agrees. ) But Hugs gives a division by zero error! I'm more of a recreational haskell user and not too familiar with how the Prelude works. But I dug around a bit and saw this inGHC.Real: ( link ) > a `mod` b > | b == 0 = divZeroError > | a == minBound && b == (-1) = overflowError > | otherwise = a `modInt` b Is there a reason why n `mod` 0 is undefined in Haskell? Maybe this has already been considered for Haskell' and I'm just unaware. I did some digging in the archives and this discussion from 2002 is the most relevant one I could find; it is suggested there that n `mod` 0 should be an error. Thanks all- Nathan Bloomfield *- The mod function is defined in the Integral class, and I'm not even sure how to interpret that. It looks kind of like a Euclidean domain. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090721/31b031e9/attachment.html From twb at cybersource.com.au Tue Jul 21 22:40:49 2009 From: twb at cybersource.com.au (Trent W. Buck) Date: Tue Jul 21 23:21:34 2009 Subject: [Haskell-cafe] Re: cheap in-repo local branches (just needs implementation) References: <20090721212311.GV9714@brighton.ac.uk> Message-ID: <30bpnd4ez2.fsf@cybersource.com.au> Eric Kow writes: > [...] a branch switching tool, utilizing darcs' existing repository > data stores, could be built [...] today [...] as a second/third-party > tool to darcs. I heartily approve of this approach. In-repo branches are occasionally useful to me, but the "pollution" of the VCS' interface has always been a major turn-off. The proposed solution allows new users to start with a Darcs that has a one-to-one correspondence between repos and branches. When I give Darcs to someone who has been using tar(1) for version control, I do not need to explain up-front the difference between a branch and a repo. Later, when that user has developed VCS habits and is trusted to work on larger group projects, I can introduce the additional complexity of in- repo branching without overwhelming him. From dav.vire+haskell at gmail.com Wed Jul 22 02:46:08 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Jul 22 02:27:38 2009 Subject: [Haskell-cafe] Re: cheap in-repo local branches (just needs implementation) In-Reply-To: <30bpnd4ez2.fsf@cybersource.com.au> References: <20090721212311.GV9714@brighton.ac.uk> <30bpnd4ez2.fsf@cybersource.com.au> Message-ID: <4c88418c0907212346xd9b92e7n663a789bcf96b5d8@mail.gmail.com> On Wed, Jul 22, 2009 at 4:40 AM, Trent W. Buck wrote: > Later, when that user has developed VCS habits and is trusted to work on > larger group projects, I can introduce the additional complexity of in- > repo branching without overwhelming him. I went from nothing to using git, and I sincerely don't know what's overwhelming about repo branching. From dimavs at gmail.com Wed Jul 22 03:14:26 2009 From: dimavs at gmail.com (Dmitri Sosnik) Date: Wed Jul 22 02:56:02 2009 Subject: [Haskell-cafe] Re: cheap in-repo local branches (just needs implementation) In-Reply-To: <4c88418c0907212346xd9b92e7n663a789bcf96b5d8@mail.gmail.com> References: <20090721212311.GV9714@brighton.ac.uk> <30bpnd4ez2.fsf@cybersource.com.au> <4c88418c0907212346xd9b92e7n663a789bcf96b5d8@mail.gmail.com> Message-ID: <856AA701-7C9B-4D5E-91C8-8BC9FF7348ED@gmail.com> Ha, try branching and merging in SVN (it worse in CVS) :-) Git got beautiful branching. On 22/07/2009, at 4:46 PM, david48 wrote: > On Wed, Jul 22, 2009 at 4:40 AM, Trent W. > Buck wrote: > >> Later, when that user has developed VCS habits and is trusted to >> work on >> larger group projects, I can introduce the additional complexity of >> in- >> repo branching without overwhelming him. > > I went from nothing to using git, and I sincerely don't know what's > overwhelming about repo branching. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From magnus at therning.org Wed Jul 22 03:41:45 2009 From: magnus at therning.org (Magnus Therning) Date: Wed Jul 22 03:23:16 2009 Subject: [Haskell-cafe] Re: cheap in-repo local branches (just needs implementation) In-Reply-To: <4c88418c0907212346xd9b92e7n663a789bcf96b5d8@mail.gmail.com> References: <20090721212311.GV9714@brighton.ac.uk> <30bpnd4ez2.fsf@cybersource.com.au> <4c88418c0907212346xd9b92e7n663a789bcf96b5d8@mail.gmail.com> Message-ID: On Wed, Jul 22, 2009 at 7:46 AM, david48 wrote: > On Wed, Jul 22, 2009 at 4:40 AM, Trent W. Buck wrote: > >> Later, when that user has developed VCS habits and is trusted to work on >> larger group projects, I can introduce the additional complexity of in- >> repo branching without overwhelming him. > > I went from nothing to using git, and I sincerely don't know what's > overwhelming about repo branching. You just need to work with more clue-less people. It'll do _your_ head in trying to understand why they fail to understand VCS :-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From haskell at list.mightyreason.com Wed Jul 22 04:05:33 2009 From: haskell at list.mightyreason.com (Chris Kuklewicz) Date: Wed Jul 22 03:47:15 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` In-Reply-To: <9858b5620907211952w73abe9aak53a7db6dbfa315bd@mail.gmail.com> References: <9858b5620907211952w73abe9aak53a7db6dbfa315bd@mail.gmail.com> Message-ID: Nathan Bloomfield wrote: > Hello haskell-cafe; > > I'm fiddling with this > > blog post about inverting elements of Z/(p), trying to write the > inversion function in pointfree style. This led me to try executing > statements like > > n `mod` 0 > > which in the ring theoretic sense should be n, at least for integers*. > (MathWorld agrees. ) I agree that (n `mod` 0) ought to be n. Specifically divMod n 0 = (0,n) and quotRem n 0 = (0,n) In (divMod n m) the sign of the remainder is always the same as the sign of m, unless n or m is zero. In (quotRem n m) the sign of the quotient is the product of the signs of n and m, unless n or m is zero. -- Chris From jon.fairbairn at cl.cam.ac.uk Wed Jul 22 05:06:35 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Wed Jul 22 04:48:16 2009 Subject: [Haskell-cafe] Re: Implicit concatenation in list comprehensions References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> <5410563564.20090721133457@gmail.com> Message-ID: Bulat Ziganshin writes: > Hello Neil, > > Tuesday, July 21, 2009, 1:26:55 PM, you wrote: > >>> ?++ [ "-i" ? ? ?| not (null (ghcOptSearchPath opts)) ] >>> ?++ [ "-i", dir | dir <- ghcOptSearchPath opts ] > >> Following the discussions, I now support this extension too - I keep >> seeing more and more places in my code where it would be very useful. > >>> ?++ [ "-i" ? ? ?| not (null (ghcOptSearchPath opts)) ] >>> ?++ concat [ ["-i", dir] | dir <- ghcOptSearchPath opts ] That looks good enough to convince me that new syntax gains too little here. When adding stuff to the syntax you have to be very careful about interactions between forms, and possible errors. The more you add, the more likely it is that something horrible gets overlooked. And learning haskell becomes more tedious (you have to learn stuff that you'd never use because other people will). Having a fairly small amount of flexible syntax (and Haskell is already pushing the boundaries of "fairly small") together with powerful abstraction tools is far better than having a syntax so huge that no-one can see how weak the abstractions are... I keep trying, but I don't think I can finish this posting without mentioning Perl, whose aficionados have so much investment in having learned all that crap that they can't see how awful it is. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From ttencate at gmail.com Wed Jul 22 05:36:09 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Wed Jul 22 05:17:39 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` In-Reply-To: References: <9858b5620907211952w73abe9aak53a7db6dbfa315bd@mail.gmail.com> Message-ID: There are two ways of looking at the mod operator (on integers): 1. As a map from the integers Z to Z/pZ. Then n mod p is defined as: n mod p = { k | k in Z, k = n + ip for some i in Z } Instead of the set, we ususally write its smallest nonnegative element. And yes, in that sense, Z/0Z gives: n mod 0 = { k | k in Z, k = n } = { k } =~ k 2. As the remainder under division by p. Since n mod 0 would be the remainder under division by 0, this correctly gives a division by zero error. I used to think that the definitions were equivalent... apparently not. Thomas On Wed, Jul 22, 2009 at 10:05, Chris Kuklewicz wrote: > Nathan Bloomfield wrote: >> Hello haskell-cafe; >> >> I'm fiddling with this >> >> blog post about inverting elements of Z/(p), trying to write the >> inversion function in pointfree style. This led me to try executing >> statements like >> >> ? ?n `mod` 0 >> >> which in the ring theoretic sense should be n, at least for integers*. >> (MathWorld agrees. ) > > I agree that (n `mod` 0) ought to be n. ?Specifically > > divMod n 0 = (0,n) > > and > > quotRem n 0 = (0,n) > > In (divMod n m) the sign of the remainder is always the same as the sign > of m, unless n or m is zero. ?In (quotRem n m) the sign of the quotient > is the product of the signs of n and m, unless n or m is zero. > > -- > Chris > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dav.vire+haskell at gmail.com Wed Jul 22 06:23:54 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Jul 22 06:05:24 2009 Subject: [Haskell-cafe] Re: cheap in-repo local branches (just needs implementation) In-Reply-To: References: <20090721212311.GV9714@brighton.ac.uk> <30bpnd4ez2.fsf@cybersource.com.au> <4c88418c0907212346xd9b92e7n663a789bcf96b5d8@mail.gmail.com> Message-ID: <4c88418c0907220323o1ccaf77ch7da9b75078eb8be4@mail.gmail.com> On Wed, Jul 22, 2009 at 9:41 AM, Magnus Therning wrote: > On Wed, Jul 22, 2009 at 7:46 AM, david48 wrote: >> I went from nothing to using git, and I sincerely don't know what's >> overwhelming about repo branching. > You just need to work with more clue-less people. ?It'll do _your_ > head in trying to understand why they fail to understand VCS :-) I have the luck to work for a factory where we are only 3 people involved with coding, and most of the time on separate stuff :) David. From marco-oweber at gmx.de Wed Jul 22 08:28:49 2009 From: marco-oweber at gmx.de (Marc Weber) Date: Wed Jul 22 08:10:23 2009 Subject: [Haskell-cafe] what about adding a HIDE pragma ? Message-ID: <1248265048-sup-2026@nixos> I know about module Foo ( exportedFuncA, ExportedType(..) ) where exportedFuncA :: .. exportedFuncA = .. data ExportedType = ExportedType It's great that you can only export a subset of all functions defined in a module. However this kind of declaration causes some work when merging branches etc. Its not a big deal but takes time. So does it make sense to add this information using pragmas? {-# HIDE logInfo, logError #-} logInfo :: Int -> String -> (Bool, Double) logInfo = logM INFO "this.module" logError :: Int -> String -> (Bool, Double) logInfo = logM ERROR "this.module" Adding a pragma like HIDE, EXPORT is only a small change but can make a big difference in everyday life ? Can template haskell add those pragmas as well? Marc Weber From me at mornfall.net Wed Jul 22 08:42:20 2009 From: me at mornfall.net (Petr Rockai) Date: Wed Jul 22 08:23:56 2009 Subject: [Haskell-cafe] Re: cheap in-repo local branches (just needs implementation) In-Reply-To: <9c93a3a90907220428q52c35aa7u4bc7522e335aca11@mail.gmail.com> (Grant Husbands's message of "Wed, 22 Jul 2009 12:28:47 +0100") References: <20090721212311.GV9714@brighton.ac.uk> <9c93a3a90907220428q52c35aa7u4bc7522e335aca11@mail.gmail.com> Message-ID: <87skgohosz.fsf@twilight.int.mornfall.net.> Hi, Grant Husbands writes: > 1. When you unpull old patches or reorder patches, Darcs alters > existing patch files. This will break other branches that share the > same files. Not true, since the filenames are fully determined by the file content. Hashed repositories will just create a new file for the modified patch. > 2. Similarly, when you pull patches in different contexts, you end up > with slightly-different patches with the same name. Same as above. > 3. With enough unpulling on one branch, you probably break the root > for another branch, by removing the shared inventory behind the head. This can be addressed by a GC policy. It's probably not feasible with current darcs, but keeping around "root" pointers to inventories is not much different from keeping extra roots for pristine. > 4. Pushing and pulling between branches would be very hard to > implement without heavy Darcs involvement. The method in the proposal > will not work, as Darcs in either branch can't necessarily understand > the context produced by the other branch. I'm not sure I follow your argument here. The proposed thing is the exact mechanism behind "darcs push" -- grab context of remote repository, commute patches you have to a common point and create a bundle, then use apply on that bundle... > 5. Updating the working copy correctly for many branch operations > entails knowing how to handle all of the darcs patches that are > different between the branches. Even if you force the user to have no > working copy changes, what about the unversioned extra files, > especially in renamed folders? The "switch" problem wouldn't be any easier whether implemented inside or outside of darcs. This basically entails unapplying patches up to a common point and then applying missing ones. This may or may not work, depending on how much changed the working copy is. I presume we would abort without doing any changes may this break. > 6. As noted in the proposal, it's not known how to make it play nicely > with lazy fetching. I don't expect any problems here. I also don't see the original note? > 7. The branch-knowledge synchronisation requires almost as much > knowledge about how to handle remote Darcs repos as Darcs has. This is likely true. Yours, Petr. From bulat.ziganshin at gmail.com Wed Jul 22 08:53:05 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jul 22 08:42:09 2009 Subject: [Haskell-cafe] what about adding a HIDE pragma ? In-Reply-To: <1248265048-sup-2026@nixos> References: <1248265048-sup-2026@nixos> Message-ID: <1304814866.20090722165305@gmail.com> Hello Marc, Wednesday, July 22, 2009, 4:28:49 PM, you wrote: > So does it make sense to add this information using pragmas? pragmas shouldn't change program behavior or alter whether program may be compiled of course, LANGUAGE pragmas violate this law, but is considered as bug in Haskell developments rather than welcomed feature -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From tom.davie at gmail.com Wed Jul 22 09:08:15 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Jul 22 08:49:46 2009 Subject: [Haskell-cafe] what about adding a HIDE pragma ? In-Reply-To: <1304814866.20090722165305@gmail.com> References: <1248265048-sup-2026@nixos> <1304814866.20090722165305@gmail.com> Message-ID: On 22 Jul 2009, at 14:53, Bulat Ziganshin wrote: > Hello Marc, > > Wednesday, July 22, 2009, 4:28:49 PM, you wrote: > >> So does it make sense to add this information using pragmas? > > pragmas shouldn't change program behavior or alter whether program may > be compiled > > of course, LANGUAGE pragmas violate this law, but is considered as bug > in Haskell developments rather than welcomed feature Why shouldn't they? I'm not particularly in support of this idea -- it makes it less clear what is being exported by the module, but I don't get your reasoning. Bob From bulat.ziganshin at gmail.com Wed Jul 22 09:13:03 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jul 22 08:54:38 2009 Subject: [Haskell-cafe] what about adding a HIDE pragma ? In-Reply-To: References: <1248265048-sup-2026@nixos> <1304814866.20090722165305@gmail.com> Message-ID: <1815826914.20090722171303@gmail.com> Hello Thomas, Wednesday, July 22, 2009, 5:08:15 PM, you wrote: > Why shouldn't they? I'm not particularly in support of this idea -- > it makes it less clear what is being exported by the module, but I > don't get your reasoning. pragmas supposed to be some hints to compiler helping it to improve speed or debugging. program semantic shouldn't be altered when all pragmas are stripped off. otherwise, we are easily lose difference between pragmas and language itself -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From noel.kalman at googlemail.com Wed Jul 22 10:23:53 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Wed Jul 22 10:05:25 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` In-Reply-To: References: Message-ID: <4A6720F9.5020600@googlemail.com> Thomas ten Cate schrieb: > There are two ways of looking at the mod operator (on integers): > > 1. As a map from the integers Z to Z/pZ. > [...] > 2. As the remainder under division by p. > Since n mod 0 would be the remainder under division by 0, this > correctly gives a division by zero error. > > I used to think that the definitions were equivalent... apparently not. They are if you don't disallow division by zero with remainder. Namely, the definition of ?division with remainder? works as in (1). From lanny at cisco.com Wed Jul 22 11:56:34 2009 From: lanny at cisco.com (Lanny Ripple) Date: Wed Jul 22 11:38:07 2009 Subject: [Haskell-cafe] Re: Implicit concatenation in list comprehensions In-Reply-To: References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> <5410563564.20090721133457@gmail.com> Message-ID: <4A6736B2.5080004@cisco.com> Speaking as a perl programmer I find that a bit insulting. We do see how awful some of it is. perl4->perl5->perl6 have been as much about cleanup as adding functionality. And I would have thought this forum would have been more aware that after Audrey built the first perl6 interpreter basically overnight in Haskell that almost every perl aficionado around has looked at Haskell and many have learned it and that it's a major contributor to the design space of perl6. But then nobody beats a dead horse so I'll just keep laughing all the way to the bank on my perl programs. :) -ljr Jon Fairbairn wrote: > Having a fairly small amount of flexible syntax (and Haskell is already > pushing the boundaries of "fairly small") together with powerful > abstraction tools is far better than having a syntax so huge that no-one > can see how weak the abstractions are... I keep trying, but I don't > think I can finish this posting without mentioning Perl, whose > aficionados have so much investment in having learned all that crap that > they can't see how awful it is. > > From matthias.goergens at googlemail.com Wed Jul 22 12:00:38 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Jul 22 11:42:27 2009 Subject: [Haskell-cafe] Generalizing takeWhile Message-ID: I need to take some elements from the front of a list. ?However the criteria are somewhat complex. > walk f [] = [] > walk f (x:xs) = case f x > of Just g -> x : walk g xs > Nothing -> [] For each item the `predicate' f either returns Nothing, when it thinks we should not take any more elements, or return Just another `predicate' to apply to the next element. However the type system does not like my function. How can I mollify it? From kowey at darcs.net Wed Jul 22 12:13:54 2009 From: kowey at darcs.net (Eric Kow) Date: Wed Jul 22 11:55:36 2009 Subject: [Haskell-cafe] Re: [darcs-users] cheap in-repo local branches (just needs implementation) In-Reply-To: <9c93a3a90907220848vc76afd0v36735c1d70099af8@mail.gmail.com> References: <20090721212311.GV9714@brighton.ac.uk> <9c93a3a90907220428q52c35aa7u4bc7522e335aca11@mail.gmail.com> <87skgohosz.fsf@twilight.int.mornfall.net.> <9c93a3a90907220848vc76afd0v36735c1d70099af8@mail.gmail.com> Message-ID: <20090722161353.GD9714@brighton.ac.uk> On Wed, Jul 22, 2009 at 16:48:39 +0100, Grant Husbands wrote: > Overall, I'd say this just feeds back into my original point, though; > I fully expected that many points could be answered, and I think I can > raise more, given a bit of thought. (I won't unless I'm asked to, > though, as I'm trying to raise a useful point, not trying to wield > pedantry to kill a project.) I think it's quite useful that you're doing this, thanks. The hope was to solicit discussion, after all! I'd particularly appreciate it if we could summarise any results from this on the bug tracker in the end http://bugs.darcs.net/issue555 > However, take even just the above into account and things are now more > complicated. We're no longer simply switching a pristine and an > inventory here and there, we're applying and unapplying patches for > the working copy (which is non-trivial if you want to get the contexts > correct), and rolling back on failure (something even Darcs has > historically had trouble with). We're extending the added GC roots to > include the full inventory chain (and whatever else comes up). We're > doing something interesting with a new kind of context to make patch > migration between branches work. I think it will become at least as > much work as it would take to implement the right mechanisms in Darcs > itself. Another option to consider: though this may be straying from the idea of implementing a standalone tool, but it seems that darcs-branch could outsource any clever bits to the Darcs library (and that we'd have to think carefully through extensions to the Darcs library and not just hashed-storage to make this work). -- 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/20090722/1f97f28d/attachment.bin From me at mornfall.net Wed Jul 22 12:25:28 2009 From: me at mornfall.net (Petr Rockai) Date: Wed Jul 22 12:07:02 2009 Subject: [Haskell-cafe] Re: cheap in-repo local branches (just needs implementation) In-Reply-To: <9c93a3a90907220848vc76afd0v36735c1d70099af8@mail.gmail.com> (Grant Husbands's message of "Wed, 22 Jul 2009 16:48:39 +0100") References: <20090721212311.GV9714@brighton.ac.uk> <9c93a3a90907220428q52c35aa7u4bc7522e335aca11@mail.gmail.com> <87skgohosz.fsf@twilight.int.mornfall.net.> <9c93a3a90907220848vc76afd0v36735c1d70099af8@mail.gmail.com> Message-ID: <87fxcoheh3.fsf@twilight.int.mornfall.net.> Grant Husbands writes: > The original note that I should have quoted was from Max Battcher: > : Additionally, there would be other useful management tools > : (``darcs-branch list``, ``darcs-branch remove`` (or unfreeze)). I think > : that these four commands could be done with no darcs interaction at all > : (unless the branch being switched to has an incomplete/lazy pristine). Ah, OK. This is mistake on Max's part, since there's no such thing as incomplete/lazy pristine. I.e. this is a non-issue. > Overall, I'd say this just feeds back into my original point, though; > I fully expected that many points could be answered, and I think I can > raise more, given a bit of thought. (I won't unless I'm asked to, > though, as I'm trying to raise a useful point, not trying to wield > pedantry to kill a project.) Well, the problem with that point is that maybe half of your points were trivially untrue, which sort of puts a dent into the argument itself. :) > However, take even just the above into account and things are now more > complicated. We're no longer simply switching a pristine and an > inventory here and there, we're applying and unapplying patches for > the working copy (which is non-trivial if you want to get the contexts > correct), and rolling back on failure (something even Darcs has > historically had trouble with). We're extending the added GC roots to > include the full inventory chain (and whatever else comes up). We're > doing something interesting with a new kind of context to make patch > migration between branches work. I think it will become at least as > much work as it would take to implement the right mechanisms in Darcs > itself. No-one says it is going to be less or more work to do this within or outside of darcs. No doubt, some darcslib usage is quite likely (for patch application and unapplication, eg.). However, it is still relatively manageable, and in a limited form also relatively easy (but that's true of almost anything, the 80/20 rule). > There's also the strong possibility that the system would get mostly > implemented, with a few gotchas here and there and a few incomplete > features, and then there'd less impetus for writing a good, integral > branching system. You are probably overdoing the "integral" part of the equation, given that the only difference is administrative. You can import parts of darcs from outside of darcs just fine, these days. Anyway, the 80/20 problem is equivalently applicable to in-darcs as it is to out-of-darcs implementation. Yours, Petr. From felipe.lessa at gmail.com Wed Jul 22 12:44:16 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Jul 22 12:25:48 2009 Subject: [Haskell-cafe] Generalizing takeWhile In-Reply-To: References: Message-ID: <20090722164416.GB14411@kira.casa> On Wed, Jul 22, 2009 at 06:00:38PM +0200, Matthias G?rgens wrote: ] I need to take some elements from the front of a list. ?However the ] criteria are somewhat complex. ] ] > walk f [] = [] ] > walk f (x:xs) = case f x ] > of Just g -> x : walk g xs ] > Nothing -> [] ] ] For each item the `predicate' f either returns Nothing, when it thinks ] we should not take any more elements, or return Just another ] `predicate' to apply to the next element. ] ] However the type system does not like my function. How can I mollify it? It's actually simple! The problem is the type of 'f' would be type TypeOfF a = a -> Maybe (TypeOfF a) However, this type synonym isn't valid for the obvious reason (it is "infinite", I don't remember the correct name). Data types, on the other hand, may be recursive. > type TypeOfF a = a -> Maybe (TypeOfF' a) > newtype TypeOfF' a = F {unF :: TypeOfF a} and you may write your function as > walk :: TypeOfF a -> [a] -> [a] > walk _ [] = [] > walk f (x:xs) = case f x of > Just g -> x : walk (unF g) xs > Nothing -> [] Some test predicates > takeN :: Num a => a -> TypeOfF b > takeN 0 = const Nothing > takeN n = const . Just . F . takeN $ n-1 > zigZag :: (a -> Bool) -> TypeOfF a > zigZag p = go True > where go b x | p x == b = Just . F $ go (not b) > | otherwise = Nothing -- Felipe. From dagit at codersbase.com Wed Jul 22 12:45:16 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed Jul 22 12:34:40 2009 Subject: [Haskell-cafe] Generalizing takeWhile In-Reply-To: References: Message-ID: 2009/7/22 Matthias G?rgens > I need to take some elements from the front of a list. However the > criteria are somewhat complex. > > > walk f [] = [] > > walk f (x:xs) = case f x > > of Just g -> x : walk g xs > > Nothing -> [] > > For each item the `predicate' f either returns Nothing, when it thinks > we should not take any more elements, or return Just another > `predicate' to apply to the next element. > > However the type system does not like my function. How can I mollify it? At a quick glance it looks to me like the type of f is infinite. Something like: f :: a -> Maybe (a -> Maybe (a -> ...)) When I've seen people solve similar problems in the past they have introduced a data type to hide the infinite type. See for example, the solution to defining fix: http://blog.plover.com/prog/springschool95-2.html I didn't actual read that article, but it appears to explain the technique. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090722/f287490e/attachment.html From matthias.goergens at googlemail.com Wed Jul 22 13:16:30 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Jul 22 12:58:18 2009 Subject: [Haskell-cafe] Generalizing takeWhile In-Reply-To: <20090722164416.GB14411@kira.casa> References: <20090722164416.GB14411@kira.casa> Message-ID: Thanks to Jason and Felipe. I'll try that approach. From anton at appsolutions.com Wed Jul 22 13:17:20 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Wed Jul 22 12:58:51 2009 Subject: [Haskell-cafe] Generalizing takeWhile In-Reply-To: <20090722164416.GB14411@kira.casa> References: <20090722164416.GB14411@kira.casa> Message-ID: <4A6749A0.50700@appsolutions.com> Felipe Lessa wrote: > On Wed, Jul 22, 2009 at 06:00:38PM +0200, Matthias G?rgens wrote: > ] I need to take some elements from the front of a list. However the > ] criteria are somewhat complex. > ] > ] > walk f [] = [] > ] > walk f (x:xs) = case f x > ] > of Just g -> x : walk g xs > ] > Nothing -> [] > ] > ] For each item the `predicate' f either returns Nothing, when it thinks > ] we should not take any more elements, or return Just another > ] `predicate' to apply to the next element. > ] > ] However the type system does not like my function. How can I mollify it? > > It's actually simple! The problem is the type of 'f' would be > > type TypeOfF a = a -> Maybe (TypeOfF a) > > However, this type synonym isn't valid for the obvious reason (it > is "infinite", I don't remember the correct name). Data types, > on the other hand, may be recursive. > >> type TypeOfF a = a -> Maybe (TypeOfF' a) >> newtype TypeOfF' a = F {unF :: TypeOfF a} Another way to do it is to use an alternative to Maybe, defined like this: > data MaybeFun a = NoFun | Fun (a -> MaybeFun a) ...which gives this definition for walk: > walk :: (a -> MaybeFun a) -> [a] -> [a] > walk f [] = [] > walk f (x:xs) = case f x > of Fun g -> x : walk g xs > NoFun -> [] From aycan.irican at core.gen.tr Wed Jul 22 13:58:07 2009 From: aycan.irican at core.gen.tr (Aycan iRiCAN) Date: Wed Jul 22 13:40:15 2009 Subject: [Haskell-cafe] Generalizing takeWhile In-Reply-To: ("Matthias =?utf-8?Q?G=C3=B6rgens=22's?= message of "Wed, 22 Jul 2009 19:16:30 +0200") References: <20090722164416.GB14411@kira.casa> Message-ID: <878wigpplc.fsf@core.gen.tr> Matthias G?rgens writes: > Thanks to Jason and Felipe. I'll try that approach. http://www.nabble.com/There%27s-nothing-wrong-with-infinite-types!-td7713737.html Which explains the problem. -- aycan From tphyahoo at gmail.com Wed Jul 22 14:14:55 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Jul 22 13:56:24 2009 Subject: [Haskell-cafe] Generalizing takeWhile In-Reply-To: References: Message-ID: <910ddf450907221114w2ed99c50g8b370c4d60614308@mail.gmail.com> What is the use case(s) for this function? lements from the front of a list. ?However the > criteria are somewhat complex. > >> walk f [] = [] >> walk f (x:xs) = case f x >> ? ? ? ? ? ? ? ? of Just g -> x : walk g xs >> ? ? ? ? ? ? ? ? ? ?Nothing -> [] > > For each item the `predicate' f either returns Nothing, when it thinks > we should not take any more elements, or return Just another > `predicate' to apply to the next element. > > However the type system does not like my function. ?How can I mollify it? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From gladstein at gladstein.com Wed Jul 22 14:34:13 2009 From: gladstein at gladstein.com (gladstein@gladstein.com) Date: Wed Jul 22 14:15:44 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` Message-ID: <20090722113413.75469f813b58c2e0e98e8a30424d5d59.b2fbb0df6d.wbe@email03.secureserver.net> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090722/7a6e7a2d/attachment.html From simon at joyful.com Wed Jul 22 15:47:17 2009 From: simon at joyful.com (Simon Michael) Date: Wed Jul 22 15:29:00 2009 Subject: [Haskell-cafe] Re: Implicit concatenation in list comprehensions In-Reply-To: <4A6736B2.5080004@cisco.com> References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> <5410563564.20090721133457@gmail.com> <4A6736B2.5080004@cisco.com> Message-ID: It was the perl community that brought me to haskell - by their interesting choice of implementation language for Pugs - and I'm grateful to them for this among other things! From bulat.ziganshin at gmail.com Wed Jul 22 16:24:18 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jul 22 16:08:21 2009 Subject: [Haskell-cafe] Re: Implicit concatenation in list comprehensions In-Reply-To: References: <9d4d38820907190758v3db3eccx81671bd313b8c4ba@mail.gmail.com> <916b84820907191507i44a7a71fv5908bd76a521fc72@mail.gmail.com> <1248119635.3163.32.camel@localhost> <404396ef0907210226x43f3388x7b40a0643990a303@mail.gmail.com> <5410563564.20090721133457@gmail.com> <4A6736B2.5080004@cisco.com> Message-ID: <12843328.20090723002418@gmail.com> Hello Simon, Wednesday, July 22, 2009, 11:47:17 PM, you wrote: > It was the perl community that brought me to haskell - by their > interesting choice of implementation language for Pugs - for me, Pugs development tale is "Beast and Beauty" of programming world :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From vigalchin at gmail.com Thu Jul 23 00:11:50 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed Jul 22 23:53:19 2009 Subject: [Haskell-cafe] ANN: Semantic Web Message-ID: <5ae4f2ba0907222111x6eebc662od79753c684fb4b72@mail.gmail.com> I. Swish-0.2.1(Semantic Web Inference uSing Haskell) is a semantic web toolkit designed and implemented by Graham Klyne - GK@ninebynine.org: 1) http://www.ninebynine.org/RDFNotes/Swish/Intro.html 2) http://www.ninebynine.org/Software/swish-0.2.1.html I am personally very excited about Graham's work and the role of Haskell in his toolkit! II.) My role I "cabalized" Swish-0.2.1, brought namespace issues up to 6.8.2 standards and fixed many compiler warnings. There are still numerous warnings mostly related to lack of function type signatures. Swish-0.2.1 however does build and the tests that Graham wrote do run ok. Currently Swish-0.2.1 is currently hosted on Hackage but will most likely move to another site in the future. The downloader will find that there are TBDs in the swish.cabal file and other places. Please be patient. Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090722/3700d436/attachment.html From jeff at nokrev.com Thu Jul 23 01:09:07 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Thu Jul 23 00:50:34 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` In-Reply-To: <20090722113413.75469f813b58c2e0e98e8a30424d5d59.b2fbb0df6d.wbe@email03.secureserver.net> References: <20090722113413.75469f813b58c2e0e98e8a30424d5d59.b2fbb0df6d.wbe@email03.secureserver.net> Message-ID: <50c1e0910907222209l75632f50xbb56ec82e3f7aceb@mail.gmail.com> On Wed, Jul 22, 2009 at 1:34 PM, wrote: > Is the utility of having (n `mod` 0) return a value greater than the > confusion it will engender? In the 99.99% case it's an error. You wouldn't > want (n `div` 0) to return 0, I expect. > If we want these number-theoretic mod and div operations let's please put > them in a separate module. Couldn't the same be said for round-to-even, instead of rounding down like every other language? I doubt any beginners have ever expected it, but it's probably better. Jeff Wheeler From matthias.goergens at googlemail.com Thu Jul 23 01:28:55 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Jul 23 01:10:43 2009 Subject: [Haskell-cafe] Generalizing takeWhile In-Reply-To: <910ddf450907221114w2ed99c50g8b370c4d60614308@mail.gmail.com> References: <910ddf450907221114w2ed99c50g8b370c4d60614308@mail.gmail.com> Message-ID: > What is the use case(s) for this function? I often want to take one more element than takeWhile does, or only start checking the predicate after taking the first element for sure. Or both. From matthias.goergens at googlemail.com Thu Jul 23 01:37:56 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Jul 23 01:19:43 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` In-Reply-To: <50c1e0910907222209l75632f50xbb56ec82e3f7aceb@mail.gmail.com> References: <20090722113413.75469f813b58c2e0e98e8a30424d5d59.b2fbb0df6d.wbe@email03.secureserver.net> <50c1e0910907222209l75632f50xbb56ec82e3f7aceb@mail.gmail.com> Message-ID: > Couldn't the same be said for round-to-even, instead of rounding down > like every other language? I doubt any beginners have ever expected > it, but it's probably better. What do you mean with round-to-even? For rounding down there's floor. From felipe.lessa at gmail.com Thu Jul 23 01:46:32 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Jul 23 01:28:04 2009 Subject: [Haskell-cafe] Generalizing takeWhile In-Reply-To: References: <910ddf450907221114w2ed99c50g8b370c4d60614308@mail.gmail.com> Message-ID: <20090723054632.GA20908@kira.casa> On Thu, Jul 23, 2009 at 07:28:55AM +0200, Matthias G?rgens wrote: ] I often want to take one more element than takeWhile does, or only > takeWhileMore n p x | p x = Just . F $ takeWhileMore n p > | otherwise = Just . F $ takeN n ] start checking the predicate after taking the first element for sure. > plusFirst = const . Just . F ] Or both. > both = plusFirst . takeWhileMore 1 :) -- Felipe. From GK at ninebynine.org Thu Jul 23 01:43:58 2009 From: GK at ninebynine.org (Graham Klyne) Date: Thu Jul 23 01:31:44 2009 Subject: [Haskell-cafe] ANN: Semantic Web In-Reply-To: <5ae4f2ba0907222111x6eebc662od79753c684fb4b72@mail.gmail.com> References: <5ae4f2ba0907222111x6eebc662od79753c684fb4b72@mail.gmail.com> Message-ID: <4A67F89E.9060400@ninebynine.org> I'd like to thank Vasili for resurrecting this project, which I thought had all-but-died for lack of nurture (the day job, etc.). It's really nice to know that, when (I hope!) the day comes that I want to pick up my Haskell work again, it won't have completely been left behind by the many exciting developments in the Haskell platform. When I have just a little time, I'd like to help move the code into a suitable open repository. Many thanks! #g -- Vasili I. Galchin wrote: > I. Swish-0.2.1(Semantic Web Inference uSing Haskell) is a semantic web > toolkit designed and implemented by Graham Klyne - GK@ninebynine.org > : > > 1) http://www.ninebynine.org/RDFNotes/Swish/Intro.html > > 2) http://www.ninebynine.org/Software/swish-0.2.1.html > > I am personally very excited about Graham's work and the role of > Haskell in his toolkit! > > > II.) My role > > I "cabalized" Swish-0.2.1, brought namespace issues up to 6.8.2 > standards and fixed many compiler warnings. There are still numerous > warnings mostly related to lack of function type signatures. > Swish-0.2.1 however does build and the tests that Graham wrote do run > ok. Currently Swish-0.2.1 is currently hosted on Hackage but will most > likely move to another site in the future. The downloader will find that > there are TBDs in the swish.cabal file and other places. Please be patient. > > Kind regards, Vasili From max.rabkin at gmail.com Thu Jul 23 05:09:37 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Thu Jul 23 04:51:24 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` In-Reply-To: References: <20090722113413.75469f813b58c2e0e98e8a30424d5d59.b2fbb0df6d.wbe@email03.secureserver.net> <50c1e0910907222209l75632f50xbb56ec82e3f7aceb@mail.gmail.com> Message-ID: 2009/7/23 Matthias G?rgens : >> Couldn't the same be said for round-to-even, instead of rounding down >> like every other language? I doubt any beginners have ever expected >> it, but it's probably better. > > What do you mean with round-to-even? ?For rounding down there's floor. Round-to-even means x.5 gets rounded to x if x is even and x+1 if x is odd. This is sometimes known as banker's rounding. The most common alternative is round-half-up. --Max From simonpj at microsoft.com Thu Jul 23 05:51:20 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Jul 23 05:33:34 2009 Subject: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with qualified names? In-Reply-To: <2518b95d0907171556l3745912na56481698094b2dd@mail.gmail.com> References: <2518b95d0907171556l3745912na56481698094b2dd@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C34B7FA6CABB@EA-EXMSG-C334.europe.corp.microsoft.com> Can you give a concrete program to illustrate your point, please? I'm not getting it. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Evan Laforge | Sent: 17 July 2009 23:57 | To: haskell | Subject: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with | qualified names? | | Record punning is not all that useful with qualified module names. If | I write '(M.Record { M.rec_x })' it says " Qualified variable in | pattern" and if I write '(M.Record { rec_x })' it says 'Not in scope: | `rec_x''. Could it be this extension be further extended slightly so | that 'f (M.Record { M.rec_x })' will desugar to 'f (M.Record { M.rec_x | = rec_x })'? | | Similarly, RecordWildCards could support this too. | | It seems simple and useful to me... am I missing anything fatally | problematic about this? Would anyone else use it? | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From marlowsd at gmail.com Thu Jul 23 06:53:52 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Jul 23 06:35:20 2009 Subject: [Haskell-cafe] Re: System.Mem.performGC leaks? In-Reply-To: References: Message-ID: <4A684140.8010500@gmail.com> On 22/07/2009 02:51, Neal Alexander wrote: > Neal Alexander wrote: >> Compiled with "ghc -O2 -fvia-C -optc-O2 -funbox-strict-fields >> -threaded" btw. > > GHC 6.10.3 on 64bit windows7. Interesting. It's completely flat on Linux, but gobbles up about 1MB/s on Windows. I'm investigating. Cheers, Simon From matthias.goergens at googlemail.com Thu Jul 23 06:59:43 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Jul 23 06:41:29 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` In-Reply-To: References: <20090722113413.75469f813b58c2e0e98e8a30424d5d59.b2fbb0df6d.wbe@email03.secureserver.net> <50c1e0910907222209l75632f50xbb56ec82e3f7aceb@mail.gmail.com> Message-ID: > Round-to-even means x.5 gets rounded to x if x is even and x+1 if x is > odd. This is sometimes known as banker's rounding. OK. That's slightly unusual indeed. From marlowsd at gmail.com Thu Jul 23 07:13:14 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Jul 23 06:54:43 2009 Subject: [Haskell-cafe] Re: Mixing C and Haskell code in the same file In-Reply-To: <212312311.20090712222652@gmail.com> References: <212312311.20090712222652@gmail.com> Message-ID: <4A6845CA.7090801@gmail.com> On 12/07/2009 19:26, Bulat Ziganshin wrote: > Hello Maur??cio, > > Sunday, July 12, 2009, 9:11:53 PM, you wrote: > >> I did read that. It says I can use "#def" to insert >> a C definition, but there are no examples of use, and I >> could not find one. > > #def inline int signof(int x) {return x<0?-1:x>0?1:0;} > foreign import ccall safe "" > signof :: CInt -> CInt > > main = print (signof 33) > > compilation: > hsc2hs tabi.hsc > ghc --make tabi.hs tabi_hsc.c That use of "inline" doesn't have any effect since GHC 6.10, because even when using -fvia-C we're not #including the header file in the generated C code. Also that note in the docs about not using #def in library code is outdated: it should be safe to use #def in libraries now. I've fixed the docs. Cheers, Simon From asviraspossible at gmail.com Thu Jul 23 07:59:34 2009 From: asviraspossible at gmail.com (Victor Nazarov) Date: Thu Jul 23 07:41:01 2009 Subject: [Haskell-cafe] Leksah works! In-Reply-To: <4c88418c0906301441i17270ff8rbea92293cf9ffd0e@mail.gmail.com> References: <5e0214850906292215q77f12853j311ec1e327ff7208@mail.gmail.com> <24272909.post@talk.nabble.com> <4c88418c0906301441i17270ff8rbea92293cf9ffd0e@mail.gmail.com> Message-ID: On Wed, Jul 1, 2009 at 1:41 AM, david48 wrote: > > I've build leksah from a fresh darcs get, ghc is 6.10.3 with the packages : > > david@whizz:~/leksah$ ghc-pkg list > /usr/local/lib/ghc-6.10.3/./package.conf: > ? ?Cabal-1.6.0.3, GLUT-2.1.1.2, HTTP-4000.0.6, HUnit-1.2.0.3, > ? ?OpenGL-2.2.1.1, QuickCheck-1.2.0.0, array-0.2.0.0, base-3.0.3.1, > ? ?base-4.1.0.0, binary-0.5.0.1, bytestring-0.9.1.4, cairo-0.10.1, > ? ?cgi-3001.1.7.1, containers-0.2.0.1, directory-1.0.0.3, > ? ?(dph-base-0.3), (dph-par-0.3), (dph-prim-interface-0.3), > ? ?(dph-prim-par-0.3), (dph-prim-seq-0.3), (dph-seq-0.3), > ? ?editline-0.2.1.0, extensible-exceptions-0.1.1.0, fgl-5.4.2.2, > ? ?filepath-1.1.0.2, (ghc-6.10.3), ghc-prim-0.1.0.0, gio-0.10.1, > ? ?glade-0.10.1, glib-0.10.1, gtk-0.10.1, gtkglext-0.10.1, > ? ?gtksourceview2-0.10.1, haddock-2.4.2, haskell-platform-2009.2.0.1, > ? ?haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, > ? ?integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1, network-2.2.1.1, > ? ?old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, > ? ?parallel-1.1.0.1, parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, > ? ?random-1.0.0.1, regex-base-0.72.0.2, regex-compat-0.71.0.1, > ? ?regex-posix-0.72.0.3, rts-1.0, soegtk-0.10.1, stm-2.1.1.2, > ? ?svgcairo-0.10.1, syb-0.1.0.1, template-haskell-2.3.0.1, > ? ?time-1.1.2.4, time-1.1.3, unix-2.3.2.0, utf8-string-0.3.5, > ? ?xhtml-3000.2.0.1, zlib-0.5.0.0 > david@whizz:~/leksah$ > > > The OS is Kubuntu Jaunty (9.04) and GTK comes from the Jaunty repositories. > I can't build leksah: I've got: src/IDE/Completion.hs:99:26-59: Not in scope: `sourceLanguageManagerGuessLanguage' cabal: Error: some packages failed to install: leksah-0.6.1 failed during the building phase. The exception was: exit: ExitFailure 1 I have: $ ghc -V The Glorious Glasgow Haskell Compilation System, version 6.10.4 $ ghc-pkg list /usr/local/lib/ghc-6.10.4/./package.conf: Cabal-1.6.0.1, Cabal-1.6.0.3, HTTP-4000.0.7, HUnit-1.2.0.3, QuickCheck-1.2.0.0, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, binary-0.5.0.1, bytestring-0.9.1.4, cairo-0.10.1, containers-0.2.0.1, directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3), (dph-seq-0.3), extensible-exceptions-0.1.1.0, filepath-1.1.0.2, gconf-0.10.1, (ghc-6.10.4), ghc-prim-0.1.0.0, gio-0.10.1, glade-0.10.1, glib-0.10.1, gnomevfs-0.10.1, gstreamer-0.10.1, gtk-0.10.1, gtkglext-0.10.1, gtksourceview2-0.10.1, haddock-2.4.2, haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1.2, old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3, rts-1.0, soegtk-0.10.1, stm-2.1.1.2, svgcairo-0.10.1, syb-0.1.0.1, template-haskell-2.3.0.1, time-1.1.4, unix-2.3.2.0, utf8-string-0.3.5, xhtml-3000.2.0.1, zlib-0.5.2.0 /home/vir/.ghc/i386-linux-6.10.4/package.conf: Cabal-1.6.0.1, Cabal-1.6.0.3, binary-0.5.0.1, utf8-string-0.3.5 -- Victor Nazarov From simonpj at microsoft.com Thu Jul 23 08:20:05 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Jul 23 08:01:34 2009 Subject: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy? In-Reply-To: References: <0F89B332-E1F5-4BE9-BFBE-E7842FDA3DDA@strictlypositive.org> <2EB7C070-9278-4E97-B53B-CE464532B6F5@yandex.ru> <4E476AB2-19C6-45A1-A1DF-C01468412F90@yandex.ru> <952A6074-9CAA-46D7-BB07-783F0FC70DFC@cs.uu.nl> <5815F3A8-5032-489A-A4CA-1E7B56437D27@strictlypositive.org> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C34B7FA6CC1E@EA-EXMSG-C334.europe.corp.microsoft.com> | Now, I am scared. This should be regarded as a bug in generalised | newtype deriving, shouldn't it? I would expect newtype deriving to be | unable to come up with instances that cannot be written by hand. | | I would have expected people out on the streets marching to GHC | headquarters by now; how can you stay so calm? Indeed, it's a known problem: http://hackage.haskell.org/trac/ghc/ticket/1496 It's a serious problem too, because it affects type soundness. But I have been moving slowly on fixing it, because I want a proper fix not a hack. Dimitrios and I have a variety of solutions now, some of which have the flavour of what's suggested below: | > I wonder if there's a potential refinement of the kind system lurking | > here, distinguishing *, types-up-to-iso, from |*|, types-up-to- | > identity. | > That might help us to detect classes for which newtype deriving is | > inappropriate: GADTs get indexed over |*|, not *; classes of *s are | > derivable, but classes of |*|s are not. I certainly don't have a clear | > proposal just now. It looks like an important distinction: recognizing | > it somehow might buy us something. Stay tuned. Simon From yairchu at gmail.com Thu Jul 23 09:13:46 2009 From: yairchu at gmail.com (yairchu@gmail.com) Date: Thu Jul 23 08:55:11 2009 Subject: [Haskell-cafe] Re: Generalizing takeWhile In-Reply-To: <20090722164416.GB14411@kira.casa> References: <20090722164416.GB14411@kira.casa> Message-ID: <3828f07a-1294-44d7-9bf3-53d9b4ffa028@r2g2000yqm.googlegroups.com> On Jul 22, 7:44?pm, Felipe Lessa wrote: > > type TypeOfF a = a -> Maybe (TypeOfF' a) > > newtype TypeOfF' a = F {unF :: TypeOfF a} An interesting observation is that "ListT ((->) a) ()" would also do the job. If one would want to also generalize "filter" this way, a more appropriate type would be "ListT ((->) a) Bool", which could still be used for the generalized takeWhile, dropWhile, etc. You need to import Control.Monad.Reader for the Monad instance of "(- >) a". ListT here isn't the one from mtl, but rather the one from "http:// www.haskell.org/haskellwiki/ListT_done_right" or from the "generator" package in hackage. From me at mornfall.net Thu Jul 23 10:02:37 2009 From: me at mornfall.net (Petr Rockai) Date: Thu Jul 23 09:44:11 2009 Subject: [Haskell-cafe] ANN: darcs 2.3.0 Message-ID: <87prbrfqf6.fsf@twilight.int.mornfall.net.> Hello! I'd like to announce immediate availability of a new stable release of darcs, 2.3.0. There is a number of improvements and bugfixes over the previous stable release, 2.2. Moreover, work has been done to improve performance of "darcs whatsnew" for large repositories. As in the past, there are two source tarballs available. As of this release, the cabal-based build is preferred, and the autoconf build is deprecated. You can obtain the source tarballs at these addresses: * http://repos.mornfall.net/darcs/darcs-2.3.0.tar.gz * http://repos.mornfall.net/darcs/darcs-2.3.0_autoconf.tar.gz The build instructions are available in the enclosed README file in those tarballs. Moreover, if you have cabal-install available, you can install latest stable release of darcs by issuing the following commands (no tarballs needed): $ cabal update $ cabal install darcs This should give you a darcs binary in `~/.cabal/bin` -- you should probably add this to your PATH. More detailed instructions for installing on Windows are available near the end of this announcement. What's New ---------- This is a summary of important changes since the last stable release (2.2): * Lots and lots of documentation changes (Trent). * Haskeline improvements (Judah). * Cabal as default buildsystem (many contributors). * Fixes in darcs check/repair memory usage (Bertram, David). * Performance improvement in subtree record (Reinier). * New option: --summary --xml (Florian Gilcher). * New option: changes --max-count (Eric and Petr). * Fix changes --only-to-files for renames (Dmitry). * Performance fix in "darcs changes" (Benedikt). * Hardlinks on NTFS (Salvatore). * Coalesce more changes when creating rollbacks (David). * New unit test runner (Reinier). * Inclusion of darcs-shell in contrib (L?szl?, Trent). * Author name/address canonisation: .authorspellings (Simon). * Working directory index and substantial "darcs wh" optimisation (Petr). * New command: "darcs show index" (Petr). * Gzip CRC check and repair feature (Ganesh). A number of issues has been resolved since 2.2 as well. See http://bugs.darcs.net/issueN for details on bug number N. * 948 darcsman (Trent) * 1206 countable nouns (Trent) * 1285 cabal test v. cabal clean (Trent) * 1302 use resolved, not resolved-in-unstable (Trent) * 1235 obliterate --summary (Rob) * 1270 no MOTD for --xml-output (Lele) * 1311 cover more timezones (Dave) * 1292 re-encoding haskeline input (Judah) * 1313 clickable ToC and refs in PDF manual Trent) * 1310 create merged \darcsCommand{add} (Trent) * 1333 better "cannot push to current repository" warning (Petr) * 1347 (autoconf) check for unsafeMMapFile if mmap use enabled (Dave) * 1361 specify required includes for curl in cabal file (Reinier) * 1379 remove libwww support (Trent) * 1366 remove unreachable code for direct ncurses use (Trent) * 1271 do not install two copies of darcs.pdf (Trent) * 1358 encode non-ASCII characters in mail headers (Reinier) * 1393 swap "darcs mv" and "darcs move" (Trent) * 1405 improve discoverability of global author file (Trent) * 1402 don't "phone home" about bugs (Trent) * 1301 remove obsolete zsh completion scripts (Trent) * 1162 makeAbsolute is now a total function (Ben F) * 1269 setpref predist - exitcode ignored bug (Ben M) * 1415 --edit-long-comment, not --edit-description, in help (Trent) * 1413 remove duplicate documentation (Trent) * 1423 complain about empty add/remove (Trent) * 1437 Implement darcs changes --max-count (Eric) * 1430 lazy pattern matching in (-:-) from Changes command module (Dmitry) * 1434 refactor example test (Trent) * 1432 refer to %APPDATA%, not %USERPROFILE% (Trent) * 1186 give a chance to abort if user did not edit description file (Dmitry) * 1446 make amend-record -m foo replace only the patch name (Dmitry) * 1435 default to get --hashed from a darcs-1.0 source (Trent) * 1312 update and reduce build notes (Trent) * 1351 fix repository path handling on Windows (Salvatore) * 1173 support hard links on NTFS (Salvatore) * 1248 support compressed inventories for darcs-1 repos (Ganesh) * 1455 implement "darcs help environment" (Trent) The question of GHC 6.8 ----------------------- Using GHC 6.10.3 or newer is *strongly recommended*. You may compile darcs with GHC 6.8, but there are several caveats. If you are using 6.8.2 or older, please disable mmap support (pass -f-mmap to cabal install or runghc Setup configure). Note that the GHC 6.8.2 that ships with Debian Lenny is not affected and it should be safe to keep mmap enabled. It is also recommended to disable use of Hackage zlib when compiling with GHC 6.8.2 (including the Debian Lenny version): pass -f-zlib to cabal. When using zlib, we have seen occasional crashes with error messages like "openBinaryFile: file locked" -- this is a known GHC 6.8.2 bug (and is fixed in GHC 6.8.3). Last, if you are using a 64-bit system, darcs may hang when you exit a pager when compiled with GHC older than 6.10.3. Although this is harmless, it is quite inconvenient. Overall, the status of GHC 6.8 is "semi-supported": for many cases, things will work just fine, especially if you take a little extra caution with compilation flags. Installing on Windows --------------------- To install darcs on Windows systems from scratch, please download the Haskell Platform and MSYS: * http://hackage.haskell.org/platform/2009.2.0.1/HaskellPlatform-2009.2.0.1-setup.exe * http://sourceforge.net/projects/mingw/files/MSYS+Base+System/MSYS-1.0.11-rc-1.exe/download After installing both, you should have an "MSYS" icon: run MSYS and in the terminal window type (the `$` character denotes the prompt, do not repeat it): $ cabal update $ cabal install darcs -f-curl This should download, compile and install all required dependencies and also darcs itself. The resulting darcs executable will be placed into the Haskell Platform executables folder, and should be accessible from the MSYS shell (just type "darcs --version" to check). Yours, Petr. From haskell at gimbo.org.uk Thu Jul 23 10:50:11 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Thu Jul 23 10:31:43 2009 Subject: [Haskell-cafe] Re: Simple quirk in behavior of `mod` In-Reply-To: References: <20090722113413.75469f813b58c2e0e98e8a30424d5d59.b2fbb0df6d.wbe@email03.secureserver.net> <50c1e0910907222209l75632f50xbb56ec82e3f7aceb@mail.gmail.com> Message-ID: <98A1CA65-88A8-4DCD-848B-9FC64765CA5F@gimbo.org.uk> On 23 Jul 2009, at 11:59, Matthias G?rgens wrote: >> Round-to-even means x.5 gets rounded to x if x is even and x+1 if x >> is >> odd. This is sometimes known as banker's rounding. > > OK. That's slightly unusual indeed. It's meant to minimise total rounding error when rounding over large data sets; there's some discussion on wikipedia: http://en.wikipedia.org/wiki/Rounding From vanenkj at gmail.com Thu Jul 23 10:53:40 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Jul 23 10:35:06 2009 Subject: [Haskell-cafe] Haskell on a VPS Message-ID: Has any one used a service similar to (or equivelant to) Slicehost or Linode to run Haskell network applications? From jeremy at n-heptane.com Thu Jul 23 11:08:48 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Jul 23 10:50:14 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: References: Message-ID: <87eis7o2rj.wl%jeremy@n-heptane.com> At Thu, 23 Jul 2009 10:53:40 -0400, John Van Enk wrote: > > Has any one used a service similar to (or equivelant to) Slicehost or > Linode to run Haskell network applications? I have run happstack applications on vpslink and rimuhosting VPSes. (I build everything as .debs and then just install the .debs on the server. But that has nothing to do with the fact that I am using Haskell or a VPS, it's just how I roll...) Is there some reason you think running a Haskell network application would be different than any other network application when it comes to a VPS? - jeremy From vanenkj at gmail.com Thu Jul 23 11:12:09 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Jul 23 10:53:34 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: <87eis7o2rj.wl%jeremy@n-heptane.com> References: <87eis7o2rj.wl%jeremy@n-heptane.com> Message-ID: No, I just want to know if there are any gotchas in the typical VPS setups that for some strange reason wouldn't like Haskell binaries. I couldn't think of any, but I miss details some times. Thanks. On Thu, Jul 23, 2009 at 11:08 AM, Jeremy Shaw wrote: > At Thu, 23 Jul 2009 10:53:40 -0400, > John Van Enk wrote: >> >> Has any one used a service similar to (or equivelant to) Slicehost or >> Linode to run Haskell network applications? > > I have run happstack applications on vpslink and rimuhosting VPSes. (I > build everything as .debs and then just install the .debs on the > server. But that has nothing to do with the fact that I am using > Haskell or a VPS, it's just how I roll...) > > Is there some reason you think running a Haskell network application > would be different than any other network application when it comes to > a VPS? > > - jeremy > From anton at appsolutions.com Thu Jul 23 11:38:07 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Thu Jul 23 11:19:34 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: References: <87eis7o2rj.wl%jeremy@n-heptane.com> Message-ID: <4A6883DF.5020307@appsolutions.com> John Van Enk wrote: > No, I just want to know if there are any gotchas in the typical VPS > setups that for some strange reason wouldn't like Haskell binaries. I > couldn't think of any, but I miss details some times. One detail you should check is that the VPS has enough memory for the Haskell applications you intend to run. RAM tends to be the most constraining factor on cheaper VPSes, and Haskell apps aren't always the most lightweight users of RAM. (At least, mine aren't.) Anton From vanenkj at gmail.com Thu Jul 23 11:40:09 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Jul 23 11:21:36 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: <4A6883DF.5020307@appsolutions.com> References: <87eis7o2rj.wl%jeremy@n-heptane.com> <4A6883DF.5020307@appsolutions.com> Message-ID: Yeah, it crossed my mind, but since my application only uses 3MB of memory in Linux, I think I'll be ok. :) On Thu, Jul 23, 2009 at 11:38 AM, Anton van Straaten wrote: > John Van Enk wrote: >> >> No, I just want to know if there are any gotchas in the typical VPS >> setups that for some strange reason wouldn't like Haskell binaries. I >> couldn't think of any, but I miss details some times. > > One detail you should check is that the VPS has enough memory for the > Haskell applications you intend to run. ?RAM tends to be the most > constraining factor on cheaper VPSes, and Haskell apps aren't always the > most lightweight users of RAM. ?(At least, mine aren't.) > > Anton > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From anton at appsolutions.com Thu Jul 23 11:44:48 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Thu Jul 23 11:26:15 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: References: <87eis7o2rj.wl%jeremy@n-heptane.com> <4A6883DF.5020307@appsolutions.com> Message-ID: <4A688570.80804@appsolutions.com> 3MB? You're going to host "Hello World" on a VPS? ;) John Van Enk wrote: > Yeah, it crossed my mind, but since my application only uses 3MB of > memory in Linux, I think I'll be ok. :) > > On Thu, Jul 23, 2009 at 11:38 AM, Anton van > Straaten wrote: >> John Van Enk wrote: >>> No, I just want to know if there are any gotchas in the typical VPS >>> setups that for some strange reason wouldn't like Haskell binaries. I >>> couldn't think of any, but I miss details some times. >> One detail you should check is that the VPS has enough memory for the >> Haskell applications you intend to run. RAM tends to be the most >> constraining factor on cheaper VPSes, and Haskell apps aren't always the >> most lightweight users of RAM. (At least, mine aren't.) >> >> Anton >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From vanenkj at gmail.com Thu Jul 23 11:46:27 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Jul 23 11:27:54 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: <4A688570.80804@appsolutions.com> References: <87eis7o2rj.wl%jeremy@n-heptane.com> <4A6883DF.5020307@appsolutions.com> <4A688570.80804@appsolutions.com> Message-ID: It's a synchronization node for my VPN application written in Haskell. All it has to do is catch UDP packets, and keep a teeny tiny amount of state. I just don't have the resources to host that my self in a reliable way. On Thu, Jul 23, 2009 at 11:44 AM, Anton van Straaten wrote: > 3MB? ?You're going to host "Hello World" on a VPS? ?;) > > > John Van Enk wrote: >> >> Yeah, it crossed my mind, but since my application only uses 3MB of >> memory in Linux, I think I'll be ok. :) >> >> On Thu, Jul 23, 2009 at 11:38 AM, Anton van >> Straaten wrote: >>> >>> John Van Enk wrote: >>>> >>>> No, I just want to know if there are any gotchas in the typical VPS >>>> setups that for some strange reason wouldn't like Haskell binaries. I >>>> couldn't think of any, but I miss details some times. >>> >>> One detail you should check is that the VPS has enough memory for the >>> Haskell applications you intend to run. ?RAM tends to be the most >>> constraining factor on cheaper VPSes, and Haskell apps aren't always the >>> most lightweight users of RAM. ?(At least, mine aren't.) >>> >>> Anton >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> > From bos at serpentine.com Thu Jul 23 14:10:27 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu Jul 23 13:51:53 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: References: <87eis7o2rj.wl%jeremy@n-heptane.com> Message-ID: On Thu, Jul 23, 2009 at 8:12 AM, John Van Enk wrote: > No, I just want to know if there are any gotchas in the typical VPS > setups that for some strange reason wouldn't like Haskell binaries. I > couldn't think of any, but I miss details some times. > I don't know about typical VPS setups, but if your provider runs SELinux in enforcing mode, some Haskell code built with older versions of GHC will crash due to the way it uses trampolines. I believe that this is fixed in 6.10, but I haven't checked as SELinux is a blight that I always wipe out at the first opportunity. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090723/6377bc8f/attachment.html From dons at galois.com Thu Jul 23 14:09:54 2009 From: dons at galois.com (Don Stewart) Date: Thu Jul 23 13:53:29 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: References: <87eis7o2rj.wl%jeremy@n-heptane.com> Message-ID: <20090723180954.GG31199@whirlpool.galois.com> bos: > On Thu, Jul 23, 2009 at 8:12 AM, John Van Enk wrote: > > No, I just want to know if there are any gotchas in the typical VPS > setups that for some strange reason wouldn't like Haskell binaries. I > couldn't think of any, but I miss details some times. > > > I don't know about typical VPS setups, but if your provider runs SELinux in > enforcing mode, some Haskell code built with older versions of GHC will crash > due to the way it uses trampolines. I believe that this is fixed in 6.10, but I > haven't checked as SELinux is a blight that I always wipe out at the first > opportunity. Not trampolines, but adjustor thunks, no? The use of executable data. -- Don From thaldyron at gmail.com Thu Jul 23 14:35:00 2009 From: thaldyron at gmail.com (Peter Robinson) Date: Thu Jul 23 14:16:47 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: References: Message-ID: > Has any one used a service similar to (or equivalent to) Slicehost or > Linode to run Haskell network applications? Since last year I've been using a VM at bytemark.co.uk as a remote development/testing machine. Never had a problem deploying Haskell webapps there, although compiling large packages like darcs might take a while due to swapping (256mb RAM). Peter From iainspeed at gmail.com Thu Jul 23 14:43:02 2009 From: iainspeed at gmail.com (Iain Barnett) Date: Thu Jul 23 14:24:29 2009 Subject: [Haskell-cafe] n00b question: defining datatype Message-ID: Hi, I'm trying to get my head around datatypes, and wondering how I might define a simple "Task" datatype in Haskell. data Task = Task { title :: String, completed :: Bool } Ok, that's straightforward, but sometimes tasks become a list of tasks themselves data Task = Task { title :: String, completed :: Bool, subtasks :: [Task] } But that's not really right, because obviously, some tasks don't have subtasks. So I try this: data Task = Task { title :: String, completed :: Bool } | TaskWithSubtasks { title :: String, completed :: Bool, subtasks :: [Task] } It's a bit more accurate, but it's repeating things, which is ok with a simple type. Could anyone suggest a better way to define this? If I was using C#, which I'm far more familiar with, I could overload the constructor and refer to the smaller constructor. Is there a way to do that in Haskell, or am I still thinking too OOP? Iain -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090723/bcf595cb/attachment.html From jake.mcarthur at gmail.com Thu Jul 23 14:45:11 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Thu Jul 23 14:26:41 2009 Subject: [Haskell-cafe] n00b question: defining datatype In-Reply-To: References: Message-ID: <4A68AFB7.2030706@gmail.com> Iain Barnett wrote: > data Task = Task { title :: String, completed :: Bool, subtasks :: [Task] } This one looks the best to me. Remember, you can just use an empty list if the task has no subtasks. - Jake From max.rabkin at gmail.com Thu Jul 23 14:45:23 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Thu Jul 23 14:27:09 2009 Subject: [Haskell-cafe] n00b question: defining datatype In-Reply-To: References: Message-ID: On Thu, Jul 23, 2009 at 8:43 PM, Iain Barnett wrote: > data Task = Task { title :: String, completed :: Bool, subtasks :: [Task] } > But that's not really right, because obviously, some tasks don't have > subtasks. The empty list is a list. --Max From a.biurvOir4 at asuhan.com Thu Jul 23 14:47:05 2009 From: a.biurvOir4 at asuhan.com (Kim-Ee Yeoh) Date: Thu Jul 23 14:28:30 2009 Subject: [Haskell-cafe] n00b question: defining datatype In-Reply-To: References: Message-ID: <24632019.post@talk.nabble.com> Consider data Task = Task { title :: String, completed :: Bool, subtasks :: Maybe [Task] } Iain Barnett wrote: > > Hi, > I'm trying to get my head around datatypes, and wondering how I might > define > a simple "Task" datatype in Haskell. > data Task = Task { title :: String, completed :: Bool } > Ok, that's straightforward, but sometimes tasks become a list of tasks > themselves > data Task = Task { title :: String, completed :: Bool, subtasks :: [Task] > } > But that's not really right, because obviously, some tasks don't have > subtasks. So I try this: > data Task = Task { title :: String, completed :: Bool } | TaskWithSubtasks > { > title :: String, completed :: Bool, subtasks :: [Task] } > It's a bit more accurate, but it's repeating things, which is ok with a > simple type. Could anyone suggest a better way to define this? If I was > using C#, which I'm far more familiar with, I could overload the > constructor > and refer to the smaller constructor. Is there a way to do that in > Haskell, > or am I still thinking too OOP? > Iain > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/n00b-question%3A-defining-datatype-tp24631976p24632019.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Thu Jul 23 14:47:54 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jul 23 14:29:30 2009 Subject: [Haskell-cafe] n00b question: defining datatype In-Reply-To: References: Message-ID: <1261303971.20090723224754@gmail.com> Hello Iain, Thursday, July 23, 2009, 10:43:02 PM, you wrote: > data Task = Task { title :: String, completed :: Bool, subtasks :: [Task] } > But that's not really right, because obviously, some tasks don't have subtasks. don't see a problem - subtasks list may be empty -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From thomas.dubuisson at gmail.com Thu Jul 23 14:49:20 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Jul 23 14:30:46 2009 Subject: [Haskell-cafe] n00b question: defining datatype In-Reply-To: References: Message-ID: <4c44d90b0907231149m9f2dc84l6f53a6f01eb77f3@mail.gmail.com> > data Task = Task { title :: String, completed :: Bool, subtasks :: [Task] } > But that's not really right, because obviously, some tasks don't have As Jake said - that's fine and you can still pattern match on the null ([]) taskes when looking for tasks without subtaskes. > data Task = Task { title :: String, completed :: Bool } | TaskWithSubtasks { > title :: String, completed :: Bool, subtasks :: [Task] } > It's a bit more accurate, but it's repeating things, which is ok with a > simple type. Could anyone suggest a better way to define this? If I was > using C#, which I'm far more familiar with, I could overload the constructor > and refer to the smaller constructor. So do you want: data Job = Job {title :: String, completed :: Bool } data Task = Task Job | MasterTask String [Job] Tom From jake.mcarthur at gmail.com Thu Jul 23 14:58:19 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Thu Jul 23 14:39:50 2009 Subject: [Haskell-cafe] n00b question: defining datatype In-Reply-To: References: Message-ID: <4A68B2CB.4060308@gmail.com> Actually, how about this? import Data.Tree newtype Task = Task (Tree (String, Bool)) Now you already have that tree structure you wanted. - Jake From jnf at arcor.de Thu Jul 23 15:02:58 2009 From: jnf at arcor.de (jutaro) Date: Thu Jul 23 14:44:24 2009 Subject: [Haskell-cafe] Leksah works! In-Reply-To: References: <5e0214850906292215q77f12853j311ec1e327ff7208@mail.gmail.com> <24272909.post@talk.nabble.com> <4c88418c0906301441i17270ff8rbea92293cf9ffd0e@mail.gmail.com> Message-ID: <24632147.post@talk.nabble.com> This is a problem with the version of an installed gtk lib. gtk2hs does conditional compilation, and adds some procedures, when a specific version of the lib is present. You have to install gtksourceview2 in a version > 2.4.0. I wanted to add a patch for backward compatibiliy to the new 0.6 release, but it is still missing and I have absolutely no time the next weeks. J?rgen Victor Nazarov-2 wrote: > > On Wed, Jul 1, 2009 at 1:41 AM, david48 wrote: >> >> I've build leksah from a fresh darcs get, ghc is 6.10.3 with the packages >> : >> >> david@whizz:~/leksah$ ghc-pkg list >> /usr/local/lib/ghc-6.10.3/./package.conf: >> ? ?Cabal-1.6.0.3, GLUT-2.1.1.2, HTTP-4000.0.6, HUnit-1.2.0.3, >> ? ?OpenGL-2.2.1.1, QuickCheck-1.2.0.0, array-0.2.0.0, base-3.0.3.1, >> ? ?base-4.1.0.0, binary-0.5.0.1, bytestring-0.9.1.4, cairo-0.10.1, >> ? ?cgi-3001.1.7.1, containers-0.2.0.1, directory-1.0.0.3, >> ? ?(dph-base-0.3), (dph-par-0.3), (dph-prim-interface-0.3), >> ? ?(dph-prim-par-0.3), (dph-prim-seq-0.3), (dph-seq-0.3), >> ? ?editline-0.2.1.0, extensible-exceptions-0.1.1.0, fgl-5.4.2.2, >> ? ?filepath-1.1.0.2, (ghc-6.10.3), ghc-prim-0.1.0.0, gio-0.10.1, >> ? ?glade-0.10.1, glib-0.10.1, gtk-0.10.1, gtkglext-0.10.1, >> ? ?gtksourceview2-0.10.1, haddock-2.4.2, haskell-platform-2009.2.0.1, >> ? ?haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, >> ? ?integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1, network-2.2.1.1, >> ? ?old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, >> ? ?parallel-1.1.0.1, parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, >> ? ?random-1.0.0.1, regex-base-0.72.0.2, regex-compat-0.71.0.1, >> ? ?regex-posix-0.72.0.3, rts-1.0, soegtk-0.10.1, stm-2.1.1.2, >> ? ?svgcairo-0.10.1, syb-0.1.0.1, template-haskell-2.3.0.1, >> ? ?time-1.1.2.4, time-1.1.3, unix-2.3.2.0, utf8-string-0.3.5, >> ? ?xhtml-3000.2.0.1, zlib-0.5.0.0 >> david@whizz:~/leksah$ >> >> >> The OS is Kubuntu Jaunty (9.04) and GTK comes from the Jaunty >> repositories. >> > I can't build leksah: I've got: > > src/IDE/Completion.hs:99:26-59: > Not in scope: `sourceLanguageManagerGuessLanguage' > cabal: Error: some packages failed to install: > leksah-0.6.1 failed during the building phase. The exception was: > exit: ExitFailure 1 > > I have: > $ ghc -V > The Glorious Glasgow Haskell Compilation System, version 6.10.4 > > $ ghc-pkg list > /usr/local/lib/ghc-6.10.4/./package.conf: > Cabal-1.6.0.1, Cabal-1.6.0.3, HTTP-4000.0.7, HUnit-1.2.0.3, > QuickCheck-1.2.0.0, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, > binary-0.5.0.1, bytestring-0.9.1.4, cairo-0.10.1, > containers-0.2.0.1, directory-1.0.0.3, (dph-base-0.3), > (dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3), > (dph-prim-seq-0.3), (dph-seq-0.3), extensible-exceptions-0.1.1.0, > filepath-1.1.0.2, gconf-0.10.1, (ghc-6.10.4), ghc-prim-0.1.0.0, > gio-0.10.1, glade-0.10.1, glib-0.10.1, gnomevfs-0.10.1, > gstreamer-0.10.1, gtk-0.10.1, gtkglext-0.10.1, > gtksourceview2-0.10.1, haddock-2.4.2, haskell-src-1.0.1.3, > haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1, > mtl-1.1.0.2, network-2.2.1.2, old-locale-1.0.0.1, old-time-1.0.0.2, > packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1, > pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, > regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3, > rts-1.0, soegtk-0.10.1, stm-2.1.1.2, svgcairo-0.10.1, syb-0.1.0.1, > template-haskell-2.3.0.1, time-1.1.4, unix-2.3.2.0, > utf8-string-0.3.5, xhtml-3000.2.0.1, zlib-0.5.2.0 > /home/vir/.ghc/i386-linux-6.10.4/package.conf: > Cabal-1.6.0.1, Cabal-1.6.0.3, binary-0.5.0.1, utf8-string-0.3.5 > > > -- > Victor Nazarov > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Leksah-works%21-tp24266240p24632147.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From iainspeed at gmail.com Thu Jul 23 15:17:34 2009 From: iainspeed at gmail.com (Iain Barnett) Date: Thu Jul 23 14:59:00 2009 Subject: [Haskell-cafe] n00b question: defining datatype In-Reply-To: <4A68B2CB.4060308@gmail.com> References: <4A68B2CB.4060308@gmail.com> Message-ID: Ok, thanks to everyone, that's certainly answered my question and given me some more avenues to pursue. I can see now that because I can pattern match against the empty list it's not really a problem to have it there. I didn't realise I could use Maybe in the constructor because it's a monad, but that's good because I was wondering about the best way to make a nullable value. That Data.Tree module looks interesting too! It does seem to be a naturally recursive type, but I'm still trying to become easy with that sort of thought :) Thanks for all the help, it's nice to get a bit of feedback when still getting used to things. Iain -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090723/f50479ef/attachment.html From anton at appsolutions.com Thu Jul 23 15:18:50 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Thu Jul 23 15:00:16 2009 Subject: [Haskell-cafe] n00b question: defining datatype In-Reply-To: <24632019.post@talk.nabble.com> References: <24632019.post@talk.nabble.com> Message-ID: <4A68B79A.8030208@appsolutions.com> Kim-Ee Yeoh wrote: > Consider > > data Task = Task { title :: String, completed :: Bool, subtasks :: Maybe > [Task] } Note that unless you have some meaning in mind for the difference between a subtask value of Nothing vs. (Just []), the Maybe is redundant. Anton From wren at freegeek.org Thu Jul 23 20:54:29 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Jul 23 20:35:59 2009 Subject: [Haskell-cafe] Pattern matching with where free variables can be used more than once In-Reply-To: <1F7CB4ED-3747-46B2-B26D-F4C1417BC7C3@cs.otago.ac.nz> References: <7f55268a0907171135j76e41da4h3036f04b85416dc3@mail.gmail.com> <1F7CB4ED-3747-46B2-B26D-F4C1417BC7C3@cs.otago.ac.nz> Message-ID: <4A690645.5030103@freegeek.org> Richard O'Keefe wrote: > On Jul 18, 2009, at 6:35 AM, Christopher Done wrote: > [non-linear patterns] > > This kind of matching is provided in Prolog and Erlang. > Neither of them lets the user define equality. > > We find the same issue with > n+k patterns (e.g., n+1 as a pattern) > l++r patterns (e.g., "prefix"++tail) > (x,x) patterns (hidden ==) > > In each case, the question is "what if the Prelude's version > of the explicit or implied function is not in scope?" (For > n+k patterns, is the relevant function "+" or is it ">=" and "-"? > For l++r patterns, is it "++", or "null", "head", and "tail"?) > > My preferred answer would be to say "the only functions in > scope in a pattern are constructors; these aren't functions, > they're syntax, and they always relate to the Prelude." > > The Haskell' community's preferred answer seems to be > "avoid the question, ban the lot of them." > > It's fair to say that any such pattern _can_ be rewritten to > something Haskell can handle; it's also fair to say that the > result is often less readable, but that a rewrite may reduce > the pain. Also, there was a big long thread about non-linear patterns a couple months back. The conclusion of which was "yes we could, but it would cause civil war". Some like that kind of sugar, some strongly dislike it, some wonder where it will all end, and some say just go use Curry already :3 -- Live well, ~wren From wren at freegeek.org Thu Jul 23 21:01:23 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Jul 23 20:42:51 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances In-Reply-To: References: <20090717191433.GA19514@pudlak.name> Message-ID: <4A6907E3.6070208@freegeek.org> John Lask wrote: > Can anyone explain the theoretical reason for this limitation, ie other > than it is a syntactical restriction, what would it take to lift this > restriction ? There are a couple of theoretical concerns, mainly that full type-level lambdas can lead down a rocky path (though simple combinators like `flip` and `const` are fine, and that's all we'd need for most cases). But by and large it's just a syntactic restriction. -- Live well, ~wren From wren at freegeek.org Thu Jul 23 21:11:33 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Jul 23 20:53:03 2009 Subject: [Haskell-cafe] Re: FFI to double constants, printf In-Reply-To: <850AEF5B-0A35-4720-A8A2-4055AD4EAF0B@ece.cmu.edu> References: <850AEF5B-0A35-4720-A8A2-4055AD4EAF0B@ece.cmu.edu> Message-ID: <4A690A45.5070209@freegeek.org> Brandon S. Allbery KF8NH wrote: > On Jul 17, 2009, at 22:27 , Maur? cio wrote: >> Is there maybe some way to check if a double or >> long double do have a "proper" value? > > > isNaN :: a -> Bool > True if the argument is an IEEE "not-a-number" (NaN) value > > isInfinite :: a -> Bool > True if the argument is an IEEE infinity or negative infinity > > isDenormalized :: a -> Bool > True if the argument is too small to be represented in normalized format > > isNegativeZero :: a -> Bool > True if the argument is an IEEE negative zero > > isIEEE :: a -> Bool > True if the argument is an IEEE floating point number > > (in Prelude, even. Class RealFloat) But don't trust the Prelude in Hugs (Sept2006)! The isInfinite and isNaN methods are hard-coded to answer False, ignoring the argument entirely. The logfloat package has the module Hugs.RealFloat[1] which provides correct versions (defaulting to the Prelude definitions for non-Hugs compilers). [1] http://hackage.haskell.org/packages/archive/logfloat/0.12.0.1/doc/html/Hugs-RealFloat.html -- Live well, ~wren From dave at zednenem.com Thu Jul 23 22:14:57 2009 From: dave at zednenem.com (David Menendez) Date: Thu Jul 23 21:56:22 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances In-Reply-To: <4A6907E3.6070208@freegeek.org> References: <20090717191433.GA19514@pudlak.name> <4A6907E3.6070208@freegeek.org> Message-ID: <49a77b7a0907231914k16b2634cs13514097ce841b3d@mail.gmail.com> On Thu, Jul 23, 2009 at 9:01 PM, wren ng thornton wrote: > John Lask wrote: >> >> Can anyone explain the theoretical reason for this limitation, ie other >> than it is a syntactical restriction, what would it take to lift this >> restriction ? > > There are a couple of theoretical concerns, mainly that full type-level > lambdas can lead down a rocky path (though simple combinators like `flip` > and `const` are fine, and that's all we'd need for most cases). But by and > large it's just a syntactic restriction. I wouldn't say it's "just" a syntactic restriction. I'm pretty sure unrestricted type lambdas are incompatible with Haskell's class system. Otherwise, you might end up with Functor instances for /\b. (a,b) and /\a. (a,b), at which point fmap (+1) (1,2) is ambiguous. -- Dave Menendez From simonpj at microsoft.com Fri Jul 24 03:30:03 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Fri Jul 24 03:11:35 2009 Subject: [Haskell-cafe] Don't miss CUFP Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C34CB4AFEFB5@EA-EXMSG-C334.europe.corp.microsoft.com> Hey, guys, This list has zillions of people who use Haskell for day-to-day work. So you might want to come to the now-annual workshop for Commercial Users of Functional Programming (CUFP) http://cufp.galois.com 4 Sept 2009, Edinburgh Speakers from companies including Facebook, Barclays Capital, and EDF Trading, using Haskell, Scala, F#, among others. Better still, CUFP is preceded and followed by a day of developer-focused tutorials: Developer Tracks on Functional Programming http://www.defun2009.info/blog/ 3 and 5 Sept, Edinburgh Tutorials covering tools and libraries in Erlang, OCaml, Scala, PLT Scheme, and more. And if that isn't enough, all this is co-located with International Conference on Functional Programming (ICFP) Haskell Symposium ML Workshop Generic Programming Workshop Erlang Workshop Haskell Implementors Workshop Such a cornucopia of delights. It'll be fun. But you do have to register: http://www.cs.nott.ac.uk/~gmh/icfp09.html Simon From michael.oswald at siemens.com Fri Jul 24 05:41:41 2009 From: michael.oswald at siemens.com (Michael Oswald) Date: Fri Jul 24 06:56:26 2009 Subject: [Haskell-cafe] Static linking Message-ID: Hello, I wrote a small installer program which configures and installs some software packages. In order to be able to let it run on a different machine, where I possibly don't have the needed shared libraries, I tried to link it statically, following this advice: http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Deployin g_statically_linked_applications However I get some linking errors: ghc --make Installer.hs -static -optl-static /usr/lib/ghc-6.10.3/unix-2.3.2.0/libHSunix-2.3.2.0.a(User__143.o)(.text+0xf1): In function `s7Tu_info': : warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../../libedit.a(readline.o)(.text+0x7b 2): In function `username_completion_function': /home/oswald/build/libedit-20090610-3.0/src/readline.c:1467:0: warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking src/dlmalloc.c:2486:0: undefined reference to `pthread_mutex_lock' /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x132):src/dlmalloc.c:2493: undefined reference to `pthread_mutex_unlock' /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x184):src/dlmalloc.c:2490: undefined reference to `pthread_mutex_init' /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x227): In function `ffi_closure_free': Because of the undefined references to pthread_mutex_lock I then tried various versions of ghc --make Installer.hs -static -optl-static -lpthread -lrt and reordered the -l switches, but neither combination helped. I always get the same error. Does somebody know how to correctly specify the pthread library for this? lg, Michael From marcin.kosiba at gmail.com Fri Jul 24 07:56:49 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Fri Jul 24 07:38:24 2009 Subject: [Haskell-cafe] Static linking In-Reply-To: References: Message-ID: <200907241356.55094.marcin.kosiba@gmail.com> On Friday 24 July 2009, Michael Oswald wrote: > Hello, > > > I wrote a small installer program which configures and installs some > software packages. In order to be able to let it run on a different > machine, where I possibly don't have the needed shared libraries, I tried > to link it statically, following this advice: > > http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Dep >loyin g_statically_linked_applications > > However I get some linking errors: > > ghc --make Installer.hs -static -optl-static > > /usr/lib/ghc-6.10.3/unix-2.3.2.0/libHSunix-2.3.2.0.a(User__143.o)(.text+0xf >1): > > In function `s7Tu_info': > : warning: Using 'getgrnam_r' in statically linked applications requires at > > runtime the shared libraries from the glibc version used for linking > /usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../../libedit.a(readline.o)(.text >+0x7b 2): > > In function `username_completion_function': > /home/oswald/build/libedit-20090610-3.0/src/readline.c:1467:0: > warning: Using 'getpwent' in statically linked applications requires > at runtime the shared libraries from the glibc version used for linking > > src/dlmalloc.c:2486:0: undefined reference to `pthread_mutex_lock' > /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x132):src/dlmalloc.c:2493: > undefined reference to `pthread_mutex_unlock' > /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x184):src/dlmalloc.c:2490: > undefined reference to `pthread_mutex_init' > /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x227): In function > `ffi_closure_free': > > > Because of the undefined references to pthread_mutex_lock I then > tried various versions of > > ghc --make Installer.hs -static -optl-static -lpthread -lrt > > and reordered the -l switches, but neither combination helped. I always get > the same error. > > Does somebody know how to correctly specify the pthread library for this? Hi, Try: ghc --make Installer.hs -static -optl-static -optl-pthread If that doesn't work, you can always do a ghc -v, find the command it uses for linking, modify it and run it manually. 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/20090724/d14a33dd/attachment-0001.bin From michael.oswald at siemens.com Fri Jul 24 08:09:16 2009 From: michael.oswald at siemens.com (Michael Oswald) Date: Fri Jul 24 07:50:51 2009 Subject: [Haskell-cafe] Re: Static linking References: <200907241356.55094.marcin.kosiba@gmail.com> Message-ID: Marcin Kosiba gmail.com> writes: > Try: > ghc --make Installer.hs -static -optl-static -optl-pthread > Ah, that fixed it. Thanks a lot! > If that doesn't work, you can always do a ghc -v, find the command it uses for > linking, modify it and run it manually. Peter suggested this, but I ran into other problems. But since it works now, I'm happy with it! Thanks again! lg, Michael From kirby81 at gmail.com Fri Jul 24 08:25:48 2009 From: kirby81 at gmail.com (Salvatore Insalaco) Date: Fri Jul 24 08:07:12 2009 Subject: [Haskell-cafe] ANN: darcs 2.3.0 In-Reply-To: <87prbrfqf6.fsf@twilight.int.mornfall.net.> References: <87prbrfqf6.fsf@twilight.int.mornfall.net.> Message-ID: <5a376f550907240525i632c1b0bv3d24447a553a778b@mail.gmail.com> Great! Just a little note: MSYS isn't required to install Darcs with cabal on Windows, just to develop or run tests. From me at mornfall.net Fri Jul 24 09:45:43 2009 From: me at mornfall.net (Petr Rockai) Date: Fri Jul 24 09:27:12 2009 Subject: [Haskell-cafe] Re: ANN: darcs 2.3.0 In-Reply-To: <5a376f550907240525i632c1b0bv3d24447a553a778b@mail.gmail.com> (Salvatore Insalaco's message of "Fri, 24 Jul 2009 14:25:48 +0200") References: <87prbrfqf6.fsf@twilight.int.mornfall.net.> <5a376f550907240525i632c1b0bv3d24447a553a778b@mail.gmail.com> Message-ID: <87ljmefb3s.fsf@twilight.int.mornfall.net.> Salvatore Insalaco writes: > Great! Just a little note: MSYS isn't required to install Darcs with > cabal on Windows, just to develop or run tests. Oh, good to know. I had no idea you could use cmd.exe to run cabal and darcs and that it would work. Yours, Petr. From hamish at firestream.co.uk Fri Jul 24 09:52:39 2009 From: hamish at firestream.co.uk (Hamish Mackenzie) Date: Fri Jul 24 09:34:01 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 Message-ID: Hi, Just a quick note to let people know we released a new version of Leksah this week. Thanks for the help and feedback on the previous version. We have done our best to add the features we thought were most pressing. Please give it a go and let us know what features you would like to see most in the future. http://leksah.org/ __ What's New __ * Integrated GHCi based debugging * Multi-window support (View -> Detach) * Improved layout control (drag & drop and nesting) * Regular expression find and replace * Grep files in the current package * Improved Mac OS X integration __ Known Bugs and Problems __ * The package editor works only for cabal files without configurations. * MS Windows: The check for external modifications of source files does?not work. * MS Windows: Interruption of a background build does not work. * Navigation in Trace history does not work. Mac OSX users can install using Mac Ports as usual or use the provided Intel binary (tested on Leopard only). http://leksah.org/Leksah-0.6.1.0.dmg Hamish From tom.davie at gmail.com Fri Jul 24 09:57:12 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Jul 24 09:38:37 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: References: Message-ID: <90D12C5A-36D5-42E0-9358-970A765E7064@gmail.com> On 24 Jul 2009, at 15:52, Hamish Mackenzie wrote: > Hi, > > Just a quick note to let people know we released a new version of > Leksah this week. Thanks for the help and feedback on the previous > version. We have done our best to add the features we thought were > most pressing. > > Please give it a go and let us know what features you would like to > see most in the future. > > http://leksah.org/ > > __ What's New __ > * Integrated GHCi based debugging > * Multi-window support (View -> Detach) > * Improved layout control (drag & drop and nesting) > * Regular expression find and replace > * Grep files in the current package > * Improved Mac OS X integration > > __ Known Bugs and Problems __ > * The package editor works only for cabal files without > configurations. > * MS Windows: The check for external modifications of source files > does not work. > * MS Windows: Interruption of a background build does not work. > * Navigation in Trace history does not work. > > Mac OSX users can install using Mac Ports as usual or use the provided > Intel binary (tested on Leopard only). > http://leksah.org/Leksah-0.6.1.0.dmg The new detach feature is great, it makes it much more usable for OS X users, but there's a small problem ? if you detach the main source window (from the default config), you end up with a window containing just the package management/documentation stuff, which is great, but I'd like to be able to shrink it down. You can't unfortunately because of the toolbar. Would it be possible to move the toolbar onto the document windows rather than the package window. From leimy2k at gmail.com Fri Jul 24 10:50:17 2009 From: leimy2k at gmail.com (David Leimbach) Date: Fri Jul 24 10:31:40 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: References: Message-ID: <3e1162e60907240750s54e42de2nadb0c0a9d95ce768@mail.gmail.com> The Mac Binary is a great addition! :-) Thanks! On Fri, Jul 24, 2009 at 6:52 AM, Hamish Mackenzie wrote: > Hi, > > Just a quick note to let people know we released a new version of > Leksah this week. Thanks for the help and feedback on the previous > version. We have done our best to add the features we thought were > most pressing. > > Please give it a go and let us know what features you would like to > see most in the future. > > http://leksah.org/ > > __ What's New __ > * Integrated GHCi based debugging > * Multi-window support (View -> Detach) > * Improved layout control (drag & drop and nesting) > * Regular expression find and replace > * Grep files in the current package > * Improved Mac OS X integration > > __ Known Bugs and Problems __ > * The package editor works only for cabal files without configurations. > * MS Windows: The check for external modifications of source files > does not work. > * MS Windows: Interruption of a background build does not work. > * Navigation in Trace history does not work. > > Mac OSX users can install using Mac Ports as usual or use the provided > Intel binary (tested on Leopard only). > http://leksah.org/Leksah-0.6.1.0.dmg > > Hamish > _______________________________________________ > 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/20090724/ba9558fa/attachment.html From marlowsd at gmail.com Fri Jul 24 11:21:08 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Jul 24 11:02:33 2009 Subject: [Haskell-cafe] Re: System.Mem.performGC leaks? In-Reply-To: <4A684140.8010500@gmail.com> References: <4A684140.8010500@gmail.com> Message-ID: <4A69D164.2060109@gmail.com> On 23/07/2009 11:53, Simon Marlow wrote: > On 22/07/2009 02:51, Neal Alexander wrote: >> Neal Alexander wrote: >>> Compiled with "ghc -O2 -fvia-C -optc-O2 -funbox-strict-fields >>> -threaded" btw. >> >> GHC 6.10.3 on 64bit windows7. > > Interesting. It's completely flat on Linux, but gobbles up about 1MB/s > on Windows. I'm investigating. Found it - there was a CriticalSection being re-initialised at each GC. Cheers, Simon From atomb at galois.com Fri Jul 24 11:29:16 2009 From: atomb at galois.com (Aaron Tomb) Date: Fri Jul 24 11:10:41 2009 Subject: [Haskell-cafe] Re: [Haskell] ANN: yices 0.0.0.1 - Haskell programming interface to Yices SMT solver In-Reply-To: References: Message-ID: <4205D443-BA32-41DB-89CB-6F3233903354@galois.com> You may want to take a look at this, as well: http://www.sivity.net/projects/smt-yices Aaron On Jul 23, 2009, at 5:32 PM, Ahn, Ki Yung wrote: > http://hackage.haskell.org/package/yices > > Incomplete (no bitvectors) syntax, parser, and inter > process communication to Yices from Haskell through pipe. > Purpose for building and using this library was to generate > test cases from constraints that SMT solvers can solve. I > only used it for that particular purpose, so the code in > general is not yet fully tested. Use at your own risk and > error reports are welcomed. See http://yices.csl.sri.com/ > for further information on Yices. > > Note: this package does not include Yices. You should get it from the > Yices homepage and install it before using this library. > > @ If you already have a better API for Yices or other SMT solvers, and > if you can open the source please upload it to hacakage. That would > be > great help for some people. > > -- > Ahn, Ki Yung > > _______________________________________________ > Haskell mailing list > Haskell@haskell.org > http://www.haskell.org/mailman/listinfo/haskell -- Aaron Tomb Galois, Inc. (http://www.galois.com) atomb@galois.com Phone: (503) 626-6616 ext. 156 Fax: (503) 350-0833 From hamish at firestream.co.uk Fri Jul 24 12:01:49 2009 From: hamish at firestream.co.uk (Hamish Mackenzie) Date: Fri Jul 24 11:43:12 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: <90D12C5A-36D5-42E0-9358-970A765E7064@gmail.com> References: <90D12C5A-36D5-42E0-9358-970A765E7064@gmail.com> Message-ID: 2009/7/25 Thomas Davie : > The new detach feature is great, it makes it much more usable for OS X > users, but there's a small problem ? if you detach the main source window > (from the default config), you end up with a window containing just the > package management/documentation stuff, which is great, but I'd like to be > able to shrink it down. ?You can't unfortunately because of the toolbar. > ?Would it be possible to move the toolbar onto the document windows rather > than the package window. Try this... start with the default layout (rm ~/.leksah/Current.session) click on the Modules tab (make sure it says Modules in the status bar) View -> Collapse (this will combine the two panes on the right into one) View -> Detach (this will detach them leaving the main toolbar behind) Hamish From thomas.dubuisson at gmail.com Fri Jul 24 12:33:00 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Fri Jul 24 12:14:23 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: References: Message-ID: <4c44d90b0907240933veaecbb0qb4a7419b3e1ff818@mail.gmail.com> "Now updating metadata ..." Why does it need more than 3GB of RAM at this point (I have 4GB and see 70% going to Leksah before I kill it)? I didn't point it at _that_ much Haskell code to parse though. Does it read everything into some bloated internal format before parsing? Thomas On Fri, Jul 24, 2009 at 6:52 AM, Hamish Mackenzie wrote: > Hi, > > Just a quick note to let people know we released a new version of > Leksah this week. ?Thanks for the help and feedback on the previous > version. ?We have done our best to add the features we thought were > most pressing. > > Please give it a go and let us know what features you would like to > see most in the future. > > http://leksah.org/ > > __ What's New __ > ?* Integrated GHCi based debugging > ?* Multi-window support (View -> Detach) > ?* Improved layout control (drag & drop and nesting) > ?* Regular expression find and replace > ?* Grep files in the current package > ?* Improved Mac OS X integration > > __ Known Bugs and Problems __ > ?* The package editor works only for cabal files without configurations. > ?* MS Windows: The check for external modifications of source files > does?not work. > ?* MS Windows: Interruption of a background build does not work. > ?* Navigation in Trace history does not work. > > Mac OSX users can install using Mac Ports as usual or use the provided > Intel binary (tested on Leopard only). > http://leksah.org/Leksah-0.6.1.0.dmg > > Hamish > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tom.davie at gmail.com Fri Jul 24 12:46:47 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Jul 24 12:28:14 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: References: <90D12C5A-36D5-42E0-9358-970A765E7064@gmail.com> Message-ID: <6543BE5E-5755-44B8-A6C0-509EBFF88BD7@gmail.com> On 24 Jul 2009, at 18:01, Hamish Mackenzie wrote: > 2009/7/25 Thomas Davie : >> The new detach feature is great, it makes it much more usable for >> OS X >> users, but there's a small problem ? if you detach the main source >> window >> (from the default config), you end up with a window containing just >> the >> package management/documentation stuff, which is great, but I'd >> like to be >> able to shrink it down. You can't unfortunately because of the >> toolbar. >> Would it be possible to move the toolbar onto the document windows >> rather >> than the package window. > > Try this... > start with the default layout (rm ~/.leksah/Current.session) > click on the Modules tab (make sure it says Modules in the status bar) > View -> Collapse (this will combine the two panes on the right into > one) > View -> Detach (this will detach them leaving the main toolbar behind) Perfect :) Leksah is looking really rather impressive, I look forward to seeing what else you do with it. Bob From dons at galois.com Fri Jul 24 14:08:51 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 24 13:52:19 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: <4c44d90b0907240933veaecbb0qb4a7419b3e1ff818@mail.gmail.com> References: <4c44d90b0907240933veaecbb0qb4a7419b3e1ff818@mail.gmail.com> Message-ID: <20090724180851.GB4547@whirlpool.galois.com> thomas.dubuisson: > "Now updating metadata ..." How many packages do you have installed? :-) > Why does it need more than 3GB of RAM at this point (I have 4GB and > see 70% going to Leksah before I kill it)? I didn't point it at > _that_ much Haskell code to parse though. Does it read everything > into some bloated internal format before parsing? From tobsan at gmail.com Fri Jul 24 14:11:12 2009 From: tobsan at gmail.com (Tobias Olausson) Date: Fri Jul 24 13:52:35 2009 Subject: [Haskell-cafe] QuickCheck behaving strange Message-ID: <65c9dbea0907241111h375fd005s60bead97b65c3c3f@mail.gmail.com> Hey Guys! I was writing a small implementation of the earliest-end-first algorithm for the Interval Scheduling problem just now. When I was done, I thought it would be a nice thing to have a QuickCheck property for my code. This is what I came up with: -- Intervals are just triplets type Interval a t = (a,t,t) end :: Interval a t -> t end (_,_,t) = t begin :: Interval a t -> t begin (_,t,_) = t And so the property: prop_schedule :: Ord t => [Interval a t] -> Bool prop_schedule [] = True prop_schedule [a] = True prop_schedule (x:y:ys) = end x <= begin y && prop_schedule (y:ys) Essentially, it looks up wheather the given list is "sorted" (given the constraints of the problem). However, in this property I forgot to add that the lists should have been run through my algorithm, which I noticed only after this strange problem appeared: *Interval> quickCheck prop_schedule +++ OK, passed 100 tests. How come QuickCheck passes 100 tests of random lists? One would think that at least one of the generated lists would be unsorted. It also passes 1000 and even 10000 tests. It also seems that changing the type helps: prop_schedule :: [Interval a Int] -> Bool ... *Interval> quickCheck prop_schedule *** Failed! Falsifiable (after 5 tests and 1 shrink): [((),0,0),((),-1,0)] -- Tobias Olausson tobsan@gmail.com From felipe.lessa at gmail.com Fri Jul 24 14:29:32 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Jul 24 14:11:02 2009 Subject: [Haskell-cafe] QuickCheck behaving strange In-Reply-To: <65c9dbea0907241111h375fd005s60bead97b65c3c3f@mail.gmail.com> References: <65c9dbea0907241111h375fd005s60bead97b65c3c3f@mail.gmail.com> Message-ID: <20090724182932.GA12037@kira.casa> On Fri, Jul 24, 2009 at 08:11:12PM +0200, Tobias Olausson wrote: > prop_schedule :: Ord t => [Interval a t] -> Bool > prop_schedule [] = True > prop_schedule [a] = True > prop_schedule (x:y:ys) = end x <= begin y && prop_schedule (y:ys) [..] > How come QuickCheck passes 100 tests of random lists? One would think that > at least one of the generated lists would be unsorted. It also passes > 1000 and even > 10000 tests. Probably it was defaulting to 'Interval () ()'. Try to do :s -Wall on your GHCi prompt to see when these things happen. -- Felipe. From dagit at codersbase.com Fri Jul 24 14:33:50 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri Jul 24 14:15:11 2009 Subject: [Haskell-cafe] QuickCheck behaving strange In-Reply-To: <20090724182932.GA12037@kira.casa> References: <65c9dbea0907241111h375fd005s60bead97b65c3c3f@mail.gmail.com> <20090724182932.GA12037@kira.casa> Message-ID: On Fri, Jul 24, 2009 at 11:29 AM, Felipe Lessa wrote: > On Fri, Jul 24, 2009 at 08:11:12PM +0200, Tobias Olausson wrote: > > prop_schedule :: Ord t => [Interval a t] -> Bool > > prop_schedule [] = True > > prop_schedule [a] = True > > prop_schedule (x:y:ys) = end x <= begin y && prop_schedule (y:ys) > [..] > > How come QuickCheck passes 100 tests of random lists? One would think > that > > at least one of the generated lists would be unsorted. It also passes > > 1000 and even > > 10000 tests. > > Probably it was defaulting to 'Interval () ()'. Try to do Cases like this make me feel as though the instance of Ord for () was a mistake. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090724/96f7beca/attachment.html From tobsan at gmail.com Fri Jul 24 14:41:50 2009 From: tobsan at gmail.com (Tobias Olausson) Date: Fri Jul 24 14:23:13 2009 Subject: [Haskell-cafe] QuickCheck behaving strange In-Reply-To: <20090724182932.GA12037@kira.casa> References: <65c9dbea0907241111h375fd005s60bead97b65c3c3f@mail.gmail.com> <20090724182932.GA12037@kira.casa> Message-ID: <65c9dbea0907241141t4e12ff76v61c4f9f0cc68c87f@mail.gmail.com> It seems this was the case, thank you! /Tobias 2009/7/24 Felipe Lessa : > On Fri, Jul 24, 2009 at 08:11:12PM +0200, Tobias Olausson wrote: >> prop_schedule :: Ord t => [Interval a t] -> Bool >> prop_schedule [] ? ? ? ?= True >> prop_schedule [a] ? ? ? = True >> prop_schedule (x:y:ys) ?= end x <= begin y && prop_schedule (y:ys) > [..] >> How come QuickCheck passes 100 tests of random lists? One would think that >> at least one of the generated lists would be unsorted. It also passes >> 1000 and even >> 10000 tests. > > Probably it was defaulting to 'Interval () ()'. ?Try to do > > ? :s -Wall > > on your GHCi prompt to see when these things happen. > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Tobias Olausson tobsan@gmail.com From thomas.dubuisson at gmail.com Fri Jul 24 14:44:26 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Fri Jul 24 14:25:48 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: <20090724180851.GB4547@whirlpool.galois.com> References: <4c44d90b0907240933veaecbb0qb4a7419b3e1ff818@mail.gmail.com> <20090724180851.GB4547@whirlpool.galois.com> Message-ID: <4c44d90b0907241144i50ff18e8n5657a90d2b323c10@mail.gmail.com> On Fri, Jul 24, 2009 at 11:08 AM, Don Stewart wrote: > thomas.dubuisson: >> "Now updating metadata ..." > > How many packages do you have installed? :-) > 90 packages - so no more than most other devs I think. From miguelimo38 at yandex.ru Fri Jul 24 14:58:45 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Jul 24 14:40:09 2009 Subject: [Haskell-cafe] QuickCheck behaving strange In-Reply-To: References: <65c9dbea0907241111h375fd005s60bead97b65c3c3f@mail.gmail.com> <20090724182932.GA12037@kira.casa> Message-ID: <7AE0D791-30FB-4527-BAA1-D4FFEDBC5B89@yandex.ru> I've felt a bit stupid using instance Monoid ()... but it seemed quite natural. On 24 Jul 2009, at 22:33, Jason Dagit wrote: > > > On Fri, Jul 24, 2009 at 11:29 AM, Felipe Lessa > wrote: > On Fri, Jul 24, 2009 at 08:11:12PM +0200, Tobias Olausson wrote: > > prop_schedule :: Ord t => [Interval a t] -> Bool > > prop_schedule [] = True > > prop_schedule [a] = True > > prop_schedule (x:y:ys) = end x <= begin y && prop_schedule (y:ys) > [..] > > How come QuickCheck passes 100 tests of random lists? One would > think that > > at least one of the generated lists would be unsorted. It also > passes > > 1000 and even > > 10000 tests. > > Probably it was defaulting to 'Interval () ()'. Try to do > > Cases like this make me feel as though the instance of Ord for () > was a mistake. > > Jason > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From bit at mutantlemon.com Fri Jul 24 15:13:29 2009 From: bit at mutantlemon.com (Bit Connor) Date: Fri Jul 24 14:54:52 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: References: <87eis7o2rj.wl%jeremy@n-heptane.com> Message-ID: <6205bd290907241213o6211ac49g18135d0944b915d4@mail.gmail.com> On Thu, Jul 23, 2009 at 6:12 PM, John Van Enk wrote: > No, I just want to know if there are any gotchas in the typical VPS > setups that for some strange reason wouldn't like Haskell binaries. I > couldn't think of any, but I miss details some times. There used to be problems with ghci running under the virtualization software Xen on x86_64 which is a common setup for VPS. As far as I can tell these problems have been resolved. http://hackage.haskell.org/trac/ghc/ticket/2512 http://hackage.haskell.org/trac/ghc/ticket/2063 From hjgtuyl at chello.nl Fri Jul 24 15:16:15 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Fri Jul 24 14:57:38 2009 Subject: [Haskell-cafe] Re:Haskell-Cafe Digest, Vol 71, Issue 30 In-Reply-To: <9587355.243491248162000176.JavaMail.coremail@bj126app45.126.com> References: <20090721014345.7F0A13244A6@www.haskell.org> <9587355.243491248162000176.JavaMail.coremail@bj126app45.126.com> Message-ID: On Tue, 21 Jul 2009 09:39:59 +0200, silent_stream wrote: > When I compile curl-1.3.5 on Windows xp. I run the prompt "runghc > Setup.hs configure " I got the following error > Setup.hs: Missing dependency on a foreign library: > * Missing C library: curl > 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 don't know how to fix this problem. Who knows? Please come to help me . This message means that the curl package depends on the curl package written in C; to get the C curl package, go to http://curl.haxx.se/download.html and download the proper package (for example http://curl.haxx.se/download/curl-7.19.5-win32-ssl-sspi.zip ) and unpack it into a directory with no space in the path name, e.g.: C:\temp\curl-7.19.5 If you do not have MingW/MSYS installed, do it now[1], you will need it for other packages as well. Open a DOS shell and go to the curl C package directory, give command: make ; it will take several minutes to build. Copy the contents of directory C:\temp\curl-7.19.5\include\curl to a directory where you collect .h files for linking, e.g.: C:\usr\local\include\curl Copy the contents of directory C:\temp\curl-7.19.5\lib\.libs to a directory where you collect library files for linking, e.g.: C:\usr\local\lib\curl To let the compiler find the necessary files, set environment variables: set C_INCLUDE_PATH=C:\usr\local\include set LIBRARY_PATH=C:\usr\local\lib;C:\usr\local\lib\curl Now you will be able to compile the Haskell curl package. [1] http://www.haskell.org/haskellwiki/Windows#Tools_for_compilation -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From wren at freegeek.org Fri Jul 24 16:47:09 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Jul 24 16:28:36 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances In-Reply-To: <49a77b7a0907231914k16b2634cs13514097ce841b3d@mail.gmail.com> References: <20090717191433.GA19514@pudlak.name> <4A6907E3.6070208@freegeek.org> <49a77b7a0907231914k16b2634cs13514097ce841b3d@mail.gmail.com> Message-ID: <4A6A1DCD.8090503@freegeek.org> David Menendez wrote: > wren ng thornton wrote: >> John Lask wrote: >>> Can anyone explain the theoretical reason for this limitation, ie other >>> than it is a syntactical restriction, what would it take to lift this >>> restriction ? >> >> There are a couple of theoretical concerns, mainly that full type-level >> lambdas can lead down a rocky path (though simple combinators like `flip` >> and `const` are fine, and that's all we'd need for most cases). But by and >> large it's just a syntactic restriction. > > I wouldn't say it's "just" a syntactic restriction. I'm pretty sure > unrestricted type lambdas are incompatible with Haskell's class > system. Otherwise, you might end up with Functor instances for /\b. > (a,b) and /\a. (a,b), at which point fmap (+1) (1,2) is ambiguous. This is essentially the same problem as arises with overlapping instances. It is a new version of that problem since it introduces new places for overlapping (by highlighting the fact that instances on a *->* kind are actually instances on type-level lambdas), but the problem isn't exactly a new one. A tweak of the overlap detector should be able to catch these too; eta expand and check for overlap of the type-level terms. The definition of "overlap" is somewhat different since it must respect abstraction, but it's not too much different than the current version. It is still possible to use type signatures to clear things up, albeit much uglier than usual. If we were to head down the road of type-level lambdas then we would want some mechanism for making it easier to deal with bifunctors like (,) and similar issues. The easiest thing, perhaps, would be to expose some of the explicit type passing that happens in the System F core[1], though we'd want to massage the dictionary-passing so that we could say things like (fmap @A) to mean the fmap of the instance for A. So yes, implementing type-level lambdas is more than just changing the parser (so more than "just" syntax), but provided the right restrictions on what type-level lambdas are acceptable I don't think there are any substantial theoretical issues (so I'd say it's just syntax, rather than theoretical concerns). And these restrictions are the obvious ones, mainly blocking recursion to prevent the compiler from hanging or generating infinite types. [1] In System F the capital-lambda binder is used for the term-level abstraction of passing type representations. So for example we have, id :: forall a. a -> a id = /\a. \(x::a). x Thus, the forall keyword is serving as the type-level abstraction. Perhaps this is suboptimal syntax, but it is the standard. We could, of course, have both a term-level /\ and a type-level /\ where the latter is the type of the former (since the namespaces are separate) though that's also dubious. Capital-pi is the canonical type-level abstraction, though that evokes the idea of dependent types which are much more complex. -- Live well, ~wren From thomas.dubuisson at gmail.com Fri Jul 24 16:52:06 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Fri Jul 24 16:33:27 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: <4c44d90b0907241144i50ff18e8n5657a90d2b323c10@mail.gmail.com> References: <4c44d90b0907240933veaecbb0qb4a7419b3e1ff818@mail.gmail.com> <20090724180851.GB4547@whirlpool.galois.com> <4c44d90b0907241144i50ff18e8n5657a90d2b323c10@mail.gmail.com> Message-ID: <4c44d90b0907241352g70fc2a88u1383afacea4fd162@mail.gmail.com> BTW, it works better when I don't give it a directory with numerous branches of Xen and the Linux kernel - somewhat unfortunate that this causes massive memory use. Now to figure out how to get it to properly configure/build projects! Thomas On Fri, Jul 24, 2009 at 11:44 AM, Thomas DuBuisson wrote: > On Fri, Jul 24, 2009 at 11:08 AM, Don Stewart wrote: >> thomas.dubuisson: >>> "Now updating metadata ..." >> >> How many packages do you have installed? :-) >> > > 90 packages - so no more than most other devs I think. > From dons at galois.com Fri Jul 24 17:01:45 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 24 16:45:11 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: <4c44d90b0907241352g70fc2a88u1383afacea4fd162@mail.gmail.com> References: <4c44d90b0907240933veaecbb0qb4a7419b3e1ff818@mail.gmail.com> <20090724180851.GB4547@whirlpool.galois.com> <4c44d90b0907241144i50ff18e8n5657a90d2b323c10@mail.gmail.com> <4c44d90b0907241352g70fc2a88u1383afacea4fd162@mail.gmail.com> Message-ID: <20090724210145.GF4547@whirlpool.galois.com> Oh, so it is scanning all the files and not finalizing them? thomas.dubuisson: > BTW, it works better when I don't give it a directory with numerous > branches of Xen and the Linux kernel - somewhat unfortunate that this > causes massive memory use. Now to figure out how to get it to > properly configure/build projects! > > Thomas > > On Fri, Jul 24, 2009 at 11:44 AM, Thomas > DuBuisson wrote: > > On Fri, Jul 24, 2009 at 11:08 AM, Don Stewart wrote: > >> thomas.dubuisson: > >>> "Now updating metadata ..." > >> > >> How many packages do you have installed? :-) > >> > > > > 90 packages - so no more than most other devs I think. > > From thomas.dubuisson at gmail.com Fri Jul 24 17:30:11 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Fri Jul 24 17:11:32 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: <20090724210145.GF4547@whirlpool.galois.com> References: <4c44d90b0907240933veaecbb0qb4a7419b3e1ff818@mail.gmail.com> <20090724180851.GB4547@whirlpool.galois.com> <4c44d90b0907241144i50ff18e8n5657a90d2b323c10@mail.gmail.com> <4c44d90b0907241352g70fc2a88u1383afacea4fd162@mail.gmail.com> <20090724210145.GF4547@whirlpool.galois.com> Message-ID: <4c44d90b0907241430k289dcdf8xca0f4fd67ba3e253@mail.gmail.com> Don Stewart wrote: > Oh, so it is scanning all the files and not finalizing them? That's the implication, but I can't seem to trigger the case short of [re]moving the .leksah directory and redoing the config that way... when I do that... A brief black-box view of it shows that it opens and closes all the files quite quickly (observed via lsof) then the CPU is pegged for a while (and I notice it's single threaded - any plans to process this stuff in parallel?). It remains pegged as the memory use gradually climbs up in steps of ~ 6% it looks like. Eventually I kill it before it becomes all knowing and breaks into our nuclear command and control under the name of 'SkyNet'. Thomas > > thomas.dubuisson: >> BTW, it works better when I don't give it a directory with numerous >> branches of Xen and the Linux kernel - somewhat unfortunate that this >> causes massive memory use. ?Now to figure out how to get it to >> properly configure/build projects! >> >> Thomas >> >> On Fri, Jul 24, 2009 at 11:44 AM, Thomas >> DuBuisson wrote: >> > On Fri, Jul 24, 2009 at 11:08 AM, Don Stewart wrote: >> >> thomas.dubuisson: >> >>> "Now updating metadata ..." >> >> >> >> How many packages do you have installed? :-) >> >> >> > >> > 90 packages - so no more than most other devs I think. >> > > From dons at galois.com Fri Jul 24 17:35:22 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 24 17:18:47 2009 Subject: [Haskell-cafe] ANN: Leksah 0.6 In-Reply-To: <4c44d90b0907241430k289dcdf8xca0f4fd67ba3e253@mail.gmail.com> References: <4c44d90b0907240933veaecbb0qb4a7419b3e1ff818@mail.gmail.com> <20090724180851.GB4547@whirlpool.galois.com> <4c44d90b0907241144i50ff18e8n5657a90d2b323c10@mail.gmail.com> <4c44d90b0907241352g70fc2a88u1383afacea4fd162@mail.gmail.com> <20090724210145.GF4547@whirlpool.galois.com> <4c44d90b0907241430k289dcdf8xca0f4fd67ba3e253@mail.gmail.com> Message-ID: <20090724213522.GI4547@whirlpool.galois.com> thomas.dubuisson: > Don Stewart wrote: > > Oh, so it is scanning all the files and not finalizing them? > > That's the implication, but I can't seem to trigger the case short of > [re]moving the .leksah directory and redoing the config that way... > when I do that... > > A brief black-box view of it shows that it opens and closes all the > files quite quickly (observed via lsof) then the CPU is pegged for a > while (and I notice it's single threaded - any plans to process this > stuff in parallel?). It remains pegged as the memory use gradually > climbs up in steps of ~ 6% it looks like. Eventually I kill it before > it becomes all knowing and breaks into our nuclear command and control > under the name of 'SkyNet'. Yeah, I've had similar issues (but I have upwards of 500 packages installed). From hjgtuyl at chello.nl Fri Jul 24 19:09:15 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Fri Jul 24 18:50:38 2009 Subject: [Haskell-cafe] Re: Curl error message In-Reply-To: References: <20090721014345.7F0A13244A6@www.haskell.org> <9587355.243491248162000176.JavaMail.coremail@bj126app45.126.com> Message-ID: On Fri, 24 Jul 2009 21:16:15 +0200, Henk-Jan van Tuyl wrote: > On Tue, 21 Jul 2009 09:39:59 +0200, silent_stream > wrote: > >> When I compile curl-1.3.5 on Windows xp. I run the prompt "runghc >> Setup.hs configure " I got the following error >> Setup.hs: Missing dependency on a foreign library: >> * Missing C library: curl >> 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 don't know how to fix this problem. Who knows? Please come to help me >> . > > This message means that the curl package depends on the curl package > written in C; > to get the C curl package, go to http://curl.haxx.se/download.html and > download the > proper package (for example > http://curl.haxx.se/download/curl-7.19.5-win32-ssl-sspi.zip > ) and unpack it into a directory with no space in the path name, e.g.: > C:\temp\curl-7.19.5 > > If you do not have MingW/MSYS installed, do it now[1], you will need it > for > other packages as well. > > Open a DOS shell and go to the curl C package directory, give command: > make > ; it will take several minutes to build. > Copy the contents of directory > C:\temp\curl-7.19.5\include\curl > to a directory where you collect .h files for linking, e.g.: > C:\usr\local\include\curl > Copy the contents of directory > C:\temp\curl-7.19.5\lib\.libs > to a directory where you collect library files for linking, e.g.: > C:\usr\local\lib\curl > > To let the compiler find the necessary files, set environment variables: > set C_INCLUDE_PATH=C:\usr\local\include > set LIBRARY_PATH=C:\usr\local\lib;C:\usr\local\lib\curl > > Now you will be able to compile the Haskell curl package. > > > [1] http://www.haskell.org/haskellwiki/Windows#Tools_for_compilation > > The Haskell curl package must also be in a directory without spaces in the name; the script used for installation cannot handle spaces in path. After moving the package to C:\temp, the package installs. -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From iavor.diatchki at gmail.com Fri Jul 24 19:48:48 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Fri Jul 24 19:30:10 2009 Subject: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with qualified names? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C34B7FA6CABB@EA-EXMSG-C334.europe.corp.microsoft.com> References: <2518b95d0907171556l3745912na56481698094b2dd@mail.gmail.com> <638ABD0A29C8884A91BC5FB5C349B1C34B7FA6CABB@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <5ab17e790907241648x77999baft925cac5d9af116d7@mail.gmail.com> Hello, I think that Even refers to an example like this: module A where data A = A { a :: Int } The following works: {-# LANGUAGE NamedFieldPuns #-} module B where import A f (A { a }) = a However, if we import "A" qualified, then punning does not seem to work: {-# LANGUAGE NamedFieldPuns #-} module B where import qualified A f (A.A { a }) = a This results in: Not in scope: `a' {-# LANGUAGE NamedFieldPuns #-} module B where import qualified A f (A.A { A.a }) = a This results in: Qualified variable in pattern: A.a Even is suggesting that instead of reporting an error, in the second case we could use the translation: f (A.A { A.a }) = a --> f (A.A { A.a = a }) (i.e., when punning occurs with a qualified name, use just the unqualified part of the name in the pattern) Hope that this helps, -Iavor On Thu, Jul 23, 2009 at 12:51 PM, Simon Peyton-Jones wrote: > Can you give a concrete program to illustrate your point, please? ?I'm not getting it. > > Simon > > | -----Original Message----- > | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On > | Behalf Of Evan Laforge > | Sent: 17 July 2009 23:57 > | To: haskell > | Subject: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with > | qualified names? > | > | Record punning is not all that useful with qualified module names. ?If > | I write '(M.Record { M.rec_x })' it says " Qualified variable in > | pattern" and if I write '(M.Record { rec_x })' it says 'Not in scope: > | `rec_x''. ?Could it be this extension be further extended slightly so > | that 'f (M.Record { M.rec_x })' will desugar to 'f (M.Record { M.rec_x > | = rec_x })'? > | > | Similarly, RecordWildCards could support this too. > | > | It seems simple and useful to me... am I missing anything fatally > | problematic about this? ?Would anyone else use it? > | _______________________________________________ > | Haskell-Cafe mailing list > | Haskell-Cafe@haskell.org > | http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jeremy at n-heptane.com Fri Jul 24 22:10:19 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Jul 24 21:51:41 2009 Subject: [Haskell-cafe] Haskell on a VPS In-Reply-To: References: Message-ID: <87k51x7bsk.wl%jeremy@n-heptane.com> At Thu, 23 Jul 2009 10:53:40 -0400, John Van Enk wrote: > > Has any one used a service similar to (or equivelant to) Slicehost or > Linode to run Haskell network applications? Ok, I discovered an issue with some VPSes. There are two virtualization technologies in common use, OpenVZ and Xen. With Xen you can have swap, but with OpenVZ you don't. In my experience, apps compiled with GHC like to allocate a lot of virtual memory that they don't really seem to use. With Xen that is not a big deal, if you allocate memory, but don't actually use it, that's ok, because in theory it could be swapped out if you actually did use it. But with OpenVZ, just allocating the memory counts against your memory quota, even if you aren't actually using it for anything. So, in practice, I think you will get a lot more milege out of your VPS memory if you use Xen instead of OpenVZ, even if you never *actually* swap to disk on the Xen platform. There is some more information here: http://hostingfu.com/article/xen-or-openvz - jeremy From relapse.dev at gmx.com Sat Jul 25 00:18:52 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Sat Jul 25 00:02:46 2009 Subject: [Haskell-cafe] Re: System.Mem.performGC leaks? In-Reply-To: <4A69D164.2060109@gmail.com> References: <4A684140.8010500@gmail.com> <4A69D164.2060109@gmail.com> Message-ID: Simon Marlow wrote: > On 23/07/2009 11:53, Simon Marlow wrote: >> On 22/07/2009 02:51, Neal Alexander wrote: >>> Neal Alexander wrote: >>>> Compiled with "ghc -O2 -fvia-C -optc-O2 -funbox-strict-fields >>>> -threaded" btw. >>> >>> GHC 6.10.3 on 64bit windows7. >> >> Interesting. It's completely flat on Linux, but gobbles up about 1MB/s >> on Windows. I'm investigating. > > Found it - there was a CriticalSection being re-initialised at each GC. > > Cheers, > Simon Cool, thanks for checking it out. From gemini at live.ca Sat Jul 25 02:55:34 2009 From: gemini at live.ca (Futari) Date: Sat Jul 25 02:36:54 2009 Subject: [Haskell-cafe] YAHT Question about Exercise 4.8 Message-ID: <24655087.post@talk.nabble.com> Hi, I was trying to use the solution given, but I don't know how to use it... How do I create something that is of type List? data List a = Nil | Cons a (List a) >From the previous examples, I was thinking something like Cons 'a' 'b' 'c' would create a list ['a','b','c'] but it gave me errors... help please, thanks. -- View this message in context: http://www.nabble.com/YAHT-Question-about-Exercise-4.8-tp24655087p24655087.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ivan.miljenovic at gmail.com Sat Jul 25 02:58:08 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Sat Jul 25 02:39:33 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.1.0.2 Message-ID: <87tz11p7un.fsf@gmail.com> This is a bug release that fixes a bug spotted by Srihari Ramanathan where the Dot representation of Color values were double-quoted when they shouldn't have been. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From rmm-haskell at z.odi.ac Sat Jul 25 03:00:16 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Sat Jul 25 02:41:40 2009 Subject: [Haskell-cafe] YAHT Question about Exercise 4.8 In-Reply-To: <24655087.post@talk.nabble.com> References: <24655087.post@talk.nabble.com> Message-ID: <723C3CCD-5E11-466C-8AC2-D90A1D9D8C55@z.odi.ac> Cons 'a' (Cons 'b' (Cons 'c' Nil)) equivalent to 'a' : ('b' : ('c' : [])) using Haskell's normal list type. -Ross On Jul 25, 2009, at 2:55 AM, Futari wrote: > > Hi, I was trying to use the solution given, but I don't know how to > use it... > How do I create something that is of type List? > > data List a = Nil | Cons a (List a) > >> From the previous examples, I was thinking something like Cons 'a' >> 'b' 'c' > would create a list ['a','b','c'] but it gave me errors... help > please, > thanks. > > > -- > View this message in context: http://www.nabble.com/YAHT-Question-about-Exercise-4.8-tp24655087p24655087.html > Sent from the Haskell - Haskell-Cafe mailing list archive at > Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gwern0 at gmail.com Sat Jul 25 03:04:17 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Jul 25 02:45:38 2009 Subject: [Haskell-cafe] YAHT Question about Exercise 4.8 In-Reply-To: <24655087.post@talk.nabble.com> References: <24655087.post@talk.nabble.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Sat, Jul 25, 2009 at 2:55 AM, Futari wrote: > Hi, I was trying to use the solution given, but I don't know how to use it... > How do I create something that is of type List? > > data List a = Nil | Cons a (List a) > > >From the previous examples, I was thinking something like Cons 'a' 'b' 'c' > would create a list ['a','b','c'] but it gave me errors... help please, > thanks. Think about what Cons 'a' 'b' 'c' means. You're trying to pass Cons three arguments - Cons x y z. But your definition of Cons says it takes *2* arguments. Clearly there's a contradiction here. Now, your first argument to Cons can be anything; in this case, it's 'a', which is a Char. So the second argument must be List a, which has exactly two alternatives: either Nil, or another Cons... eventually we must bottom out at Nil. The simplest example would be Cons 'a' Nil, which evaluates to Cons 'a' Nil it :: List Char But we could substitute in another Cons, for Cons 'a' (Cons 'b' ...?). We could terminate the list here with a Nil, but we'll go one more deep: Cons 'a' (Cons 'b' (Cons 'c' Nil)), which will again evaluate correctly to it :: List Char - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkpqrlIACgkQvpDo5Pfl1oJi7QCgiRXILcu8P4ka76BE7tjXeekT 5ycAn3pno8Gh6YGSboV/039gbIfpoYHS =4V5w -----END PGP SIGNATURE----- From bulat.ziganshin at gmail.com Sat Jul 25 03:16:10 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jul 25 02:57:37 2009 Subject: [Haskell-cafe] YAHT Question about Exercise 4.8 In-Reply-To: <24655087.post@talk.nabble.com> References: <24655087.post@talk.nabble.com> Message-ID: <994859209.20090725111610@gmail.com> Hello Futari, Saturday, July 25, 2009, 10:55:34 AM, you wrote: > data List a = Nil | Cons a (List a) this definition says that Nil is a valid list. also it says that Cons 'a' (xxx) is a valid list as long as xxx is a valid list, so Cons 'c' (Nil) would be a valid list too. continuing to use second rule we may get the following: Cons 'a' (Cons 'b' (Cons 'c' (Nil))) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From adnorm at gmail.com Sat Jul 25 10:08:20 2009 From: adnorm at gmail.com (Matthew) Date: Sat Jul 25 09:49:43 2009 Subject: [Haskell-cafe] Memoized game-tree evaluation Message-ID: I'm working on defining a data type for representing game-trees for chess or other two-person board games. My plan is to memoize the evaluations of a game-state at each depth so that values don't need to be recomputed for future moves. Here's the definition I'm using so far: data GameState = GameState {color :: Color, board :: Board} data GameTree = GameTree {state :: GameState, values :: [Int], branches :: [GameTree]} genGameTree :: GameState -> GameTree genGameTree st | finalState st = GameTree st (repeat (evalState st)) [] | otherwise = GameTree st vs bs where bs = map genGameTree (nextStates st) vs = (evalState st) : map (\d -> (optimize (color st)) (map ((!!d) . values) bs)) [0..] optimize Black = minimum optimize White = maximum I'd like to rewrite the generation of "vs" to evaluate using alpha- beta cutoffs, but I'm having trouble coming up with a way to do so without losing memoization. I don't know if my failures so far are because ab-pruning is necessarily incompatible with memoization, or if I simply haven't found the right insight yet. Can anyone suggest a solution, or convince me there isn't one? Thanks in advance. From felipe.lessa at gmail.com Sat Jul 25 10:30:13 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Jul 25 10:11:39 2009 Subject: [Haskell-cafe] Memoized game-tree evaluation In-Reply-To: References: Message-ID: <20090725143013.GA12039@kira.casa> On Sat, Jul 25, 2009 at 10:08:20AM -0400, Matthew wrote: > I'm working on defining a data type for representing game-trees > for chess or other two-person board games. My plan is to > memoize the evaluations of a game-state at each depth so that > values don't need to be recomputed for future moves. My suggestion is that it probably isn't worth it. You'll consume so much memory that your performance will actually get a lot worse than if you recomputed everything everytime. Well, at least for chess this is true. -- Felipe. From szekeres at iii.hu Sat Jul 25 18:02:43 2009 From: szekeres at iii.hu (=?UTF-8?Q?Szekeres_Istv=C3=A1n?=) Date: Sat Jul 25 17:44:04 2009 Subject: [Haskell-cafe] Can sub-classes inheriting instances of parent class? Message-ID: Hi, I'm trying to do something like the following: class Foo a where doit :: (String -> IO ()) -> a -> IO () instance Foo Int where doit f = f . show instance Foo Char where doit f = f . (:[]) So now I have a "doit" function for Ints and Chars, that takes a function and does the IO with the given function. Now I could define function p as p :: (Foo a) => a -> IO () p = doit putStrLn so I could do main = do p 3 p 'X' in main, but I would like to compeltely hide the fact from p that it somehow belongs to the Foo class, so I would like to do something like this: class Foo a => Bar a where p2 :: a -> IO () p2 = doit putStrln but, though Foo Int and Foo Char are defined, Bar Int and Bar Char are not defined automatically, so given this class definition I will not be able to call p2 3 and p2 'X' Is there still some way to do something like this? Thanks, Istvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090725/a300e6b4/attachment.html From johan.tibell at gmail.com Sun Jul 26 02:21:00 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun Jul 26 02:02:37 2009 Subject: [Haskell-cafe] Recompiling Hackage to estimate the impact of a change [Was: StricterLabelledFieldSyntax] Message-ID: <90889fe70907252321g372d21cduc2bfb655a114e48c@mail.gmail.com> On Sun, Jul 26, 2009 at 3:34 AM, Ian Lynagh wrote: > Hi all, > > I've made a ticket and proposal page for making the labelled field > syntax stricter, e.g. making this illegal: > > data A = A {x :: Int} > > y :: Maybe A > y = Just A {x = 5} > > and requiring this instead: > > data A = A {x :: Int} > > y :: Maybe A > y = Just (A {x = 5}) > > http://hackage.haskell.org/trac/haskell-prime/ticket/132 > > http://hackage.haskell.org/trac/haskell-prime/wiki/StricterLabelledFieldSyntax > In general, I think it would be a good idea to provide some statistics of how many packages would break as the result of a backwards incompatible change. Without that data I find it hard to do a cost-benefit analysis. So I hereby suggest that we make a recompile of Hackage a requirement for any breaking language changes. I understand that it might not be that easy to recompile all of Hackage at the moment so we should try to come up with some step-by-step instructions on how to do it. In the future it would be nice to have a little script that does it and spits out some statistics. Cheers, Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090726/cb387148/attachment.html From dons at galois.com Sun Jul 26 02:25:12 2009 From: dons at galois.com (Don Stewart) Date: Sun Jul 26 02:08:32 2009 Subject: [Haskell-cafe] Recompiling Hackage to estimate the impact of a change [Was: StricterLabelledFieldSyntax] In-Reply-To: <90889fe70907252321g372d21cduc2bfb655a114e48c@mail.gmail.com> References: <90889fe70907252321g372d21cduc2bfb655a114e48c@mail.gmail.com> Message-ID: <20090726062512.GA23329@whirlpool.galois.com> johan.tibell: > > In general, I think it would be a good idea to provide some statistics of how > many packages would break as the result of a backwards incompatible change. > Without that data I find it hard to do a cost-benefit analysis. So I hereby > suggest that we make a recompile of Hackage a requirement for any breaking > language changes. I understand that it might not be that easy to recompile all > of Hackage at the moment so we should try to come up with some step-by-step > instructions on how to do it. In the future it would be nice to have a little > script that does it and spits out some statistics. Agreed. And it should be required as part of release processes for GHC. Duncan has described the process of building large amounts of Hackage, http://blog.well-typed.com/2009/03/regression-testing-with-hackage/ We used this prior to the ghc 6.10 release to find a few interesting type system bugs, and get in steps for what breaks and why, ultimately easing the upgrade process so that it affected only a couple of percent of packages. So, +1, let's take advantage of this centralization to improve overall quality standards. -- Don From briqueabraque at yahoo.com Sun Jul 26 10:51:58 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sun Jul 26 10:33:33 2009 Subject: [Haskell-cafe] Re: Recompiling Hackage to estimate the impact of a change [Was: StricterLabelledFieldSyntax] In-Reply-To: <20090726062512.GA23329@whirlpool.galois.com> References: <90889fe70907252321g372d21cduc2bfb655a114e48c@mail.gmail.com> <20090726062512.GA23329@whirlpool.galois.com> Message-ID: >> In general, I think it would be a good idea to provide some statistics of how >> many packages would break as the result of a backwards incompatible change. > Agreed. And it should be required as part of release processes for GHC. One possible alternative, or complementary, action would be automating some kind of pool or voting from hackage packages maintainers. This would give a more informative answer than just breaks/doesn't break. The example that startted this thread would certainly break some packages, but I believe 99% of maintainers would say they could fix their code for compatibility before a new compiler release. (Even without voting, an automatic e-mail about language changes could be sent to maintainers, as many may even not beeing doing Haskell anymore. That could include some link to easily remove their e-mail from any package maintenance.) Maur?cio From igloo at earth.li Sun Jul 26 11:24:10 2009 From: igloo at earth.li (Ian Lynagh) Date: Sun Jul 26 11:05:27 2009 Subject: [Haskell-cafe] Recompiling Hackage to estimate the impact of a change [Was: StricterLabelledFieldSyntax] In-Reply-To: <90889fe70907252321g372d21cduc2bfb655a114e48c@mail.gmail.com> References: <90889fe70907252321g372d21cduc2bfb655a114e48c@mail.gmail.com> Message-ID: <20090726152410.GA21389@matrix.chaos.earth.li> On Sun, Jul 26, 2009 at 08:21:00AM +0200, Johan Tibell wrote: > On Sun, Jul 26, 2009 at 3:34 AM, Ian Lynagh wrote: > > > http://hackage.haskell.org/trac/haskell-prime/wiki/StricterLabelledFieldSyntax > > > > In general, I think it would be a good idea to provide some statistics of > how many packages would break as the result of a backwards incompatible > change. Without that data I find it hard to do a cost-benefit analysis. To some extent you are right, and if we had an easy to to get those stats when I would be in favour of doing so. But it is important to remember that a count of packages that break won't tell you how hard it would be to fix them. For example, the complete diff needed to fix old-time for StricterLabelledFieldSyntax was: - toClockTime cal{ctMonth=month', ctYear=year'} + toClockTime $ cal{ctMonth=month', ctYear=year'} Thanks Ian From igloo at earth.li Sun Jul 26 11:30:23 2009 From: igloo at earth.li (Ian Lynagh) Date: Sun Jul 26 11:11:39 2009 Subject: [Haskell-cafe] Recompiling Hackage to estimate the impact of a change [Was: StricterLabelledFieldSyntax] In-Reply-To: <20090726062512.GA23329@whirlpool.galois.com> References: <90889fe70907252321g372d21cduc2bfb655a114e48c@mail.gmail.com> <20090726062512.GA23329@whirlpool.galois.com> Message-ID: <20090726153023.GB21389@matrix.chaos.earth.li> On Sat, Jul 25, 2009 at 11:25:12PM -0700, Donald Bruce Stewart wrote: > johan.tibell: > > > > In general, I think it would be a good idea to provide some statistics of how > > many packages would break as the result of a backwards incompatible change. > > Agreed. And it should be required as part of release processes for GHC. > > Duncan has described the process of building large amounts of Hackage, > > http://blog.well-typed.com/2009/03/regression-testing-with-hackage/ That process requires too much effort. IIRC it took more than a day of actual human time to get the package list set up etc, and requires you to make some non-obvious decisions along the way. I think a better process would be more along the lines of: for p in $packages cabal install p rollback? except smarter, so that it doesn't try to install packages that it has already installed as a dependency of something else. Thanks Ian From chrisdone at googlemail.com Sun Jul 26 11:54:29 2009 From: chrisdone at googlemail.com (Christopher Done) Date: Sun Jul 26 11:36:06 2009 Subject: [Haskell-cafe] Pattern matching with where free variables can be used more than once In-Reply-To: <1F7CB4ED-3747-46B2-B26D-F4C1417BC7C3@cs.otago.ac.nz> References: <7f55268a0907171135j76e41da4h3036f04b85416dc3@mail.gmail.com> <1F7CB4ED-3747-46B2-B26D-F4C1417BC7C3@cs.otago.ac.nz> Message-ID: <7f55268a0907260854o657d8934v7d425b19dbf7f18c@mail.gmail.com> Well, as I said previously, in reply to Wolfgang, forget the (==) and/or Eq instance; just use the constructors. You don't need an Eq instance for them. You have the expression: foo (a,b) and the definition: foo (X,X) = .. Let's say the predicate for checking that the value of `a' matches X is Predicate A. Likewise, for foo (x,x) = ... We can use Predicate A to compare `a' and `b', for determining whether the (x,x) pattern succeeds. 2009/7/18 Richard O'Keefe > > On Jul 18, 2009, at 6:35 AM, Christopher Done wrote: > [non-linear patterns] > > This kind of matching is provided in Prolog and Erlang. > Neither of them lets the user define equality. > > We find the same issue with > n+k patterns (e.g., n+1 as a pattern) > l++r patterns (e.g., "prefix"++tail) > (x,x) patterns (hidden ==) > > In each case, the question is "what if the Prelude's version > of the explicit or implied function is not in scope?" (For > n+k patterns, is the relevant function "+" or is it ">=" and "-"? > For l++r patterns, is it "++", or "null", "head", and "tail"?) > > My preferred answer would be to say "the only functions in > scope in a pattern are constructors; these aren't functions, > they're syntax, and they always relate to the Prelude." > > The Haskell' community's preferred answer seems to be > "avoid the question, ban the lot of them." > > It's fair to say that any such pattern _can_ be rewritten to > something Haskell can handle; it's also fair to say that the > result is often less readable, but that a rewrite may reduce > the pain. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090726/513554ee/attachment.html From niklas.broberg at gmail.com Sun Jul 26 15:00:07 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Jul 26 14:41:24 2009 Subject: [Haskell-cafe] ANN: haskell-src-exts-1.1.0 Message-ID: Fellow Haskelleers, I'm pleased to announce the release of haskell-src-exts-1.1.0, bringing you tuple sections, comments, and a few bug fixes. haskell-src-exts is a package for Haskell source code manipulation. In particular it defines an abstract syntax tree representation, and a parser and pretty-printer to convert between this representation and String. It handles (almost) all syntactic extensions to the Haskell 98 standard implemented by GHC, and the parsing can be parametrised on what extensions to recognise. haskell-src-exts 1.1.0: =================== * Adds rudimentary support for retaining comments while parsing a source document. The support currently comes in the following form: - The module Language.Haskell.Exts.Comments defines a datatype Comment with two constructors denoting single-line (--) and multi-line ({- -}) comments. - The Parseable class is extended with a function 'parseWithComments :: Parseable ast => ParseMode -> String -> ParseResult (ast, [Comment])' which simply returns all comments as a list alongside the AST. There are also specialised versions for the usual suspects. Example run: HSE> parseExpWithComments defaultParseMode "1 + {- comment -} 4 -- end\n" ParseOk (InfixApp (Lit (Int 1)) (QVarOp (UnQual (Symbol "+"))) (Lit (Int 4)),[Mu ltiLine (SrcLoc {srcFilename = ".hs", srcLine = 1, srcColumn = 3}) " co mment ",SingleLine (SrcLoc {srcFilename = ".hs", srcLine = 1, srcColumn = 19}) " end"]) This first release of comment support is as seen very rudimentary, but I'm releasing it early in the hope that people who need features tied to this will start looking at what's there and send me comments on what further support they would like to see and consider missing. * Support for TupleSections: * Fixes a bug where the statements of a list comprehension were returned in the wrong order (oops!). * Fixes a bug where function definitions were printed incorrectly when using PPOffsideRule - thanks to Mathieu Boespflug for the patch. * Fixes the broken 'cabal test' - thanks to Robin Green for the entire test runner support! Cheers and Happy Haskelling, /Niklas From johan.tibell at gmail.com Sun Jul 26 15:48:01 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun Jul 26 15:29:37 2009 Subject: [Haskell-cafe] Recompiling Hackage to estimate the impact of a change [Was: StricterLabelledFieldSyntax] In-Reply-To: <20090726152410.GA21389@matrix.chaos.earth.li> References: <90889fe70907252321g372d21cduc2bfb655a114e48c@mail.gmail.com> <20090726152410.GA21389@matrix.chaos.earth.li> Message-ID: <90889fe70907261248j1e8cbd70k5e4ef7f656c67055@mail.gmail.com> On Sun, Jul 26, 2009 at 5:24 PM, Ian Lynagh wrote: > On Sun, Jul 26, 2009 at 08:21:00AM +0200, Johan Tibell wrote: > > On Sun, Jul 26, 2009 at 3:34 AM, Ian Lynagh wrote: > > > > > > http://hackage.haskell.org/trac/haskell-prime/wiki/StricterLabelledFieldSyntax > > > > > > > In general, I think it would be a good idea to provide some statistics of > > how many packages would break as the result of a backwards incompatible > > change. Without that data I find it hard to do a cost-benefit analysis. > > To some extent you are right, and if we had an easy to to get those > stats when I would be in favour of doing so. > > But it is important to remember that a count of packages that break > won't tell you how hard it would be to fix them. For example, the > complete diff needed to fix old-time for StricterLabelledFieldSyntax > was: > > - toClockTime cal{ctMonth=month', ctYear=year'} > + toClockTime $ cal{ctMonth=month', ctYear=year'} Right. So once you know what breaks you can investigate why and, as a part of the language change proposal, show how easy/hard it would be to fix breakages. I'm not arguing against breaking changes but for using the available data to make decisions. For example, when a redesign of haskell.org was brought up a while back the discussion could have greatly benefited from looking at web server logs to give valuable insight into user behavior on the site. -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090726/1f4e3fbe/attachment.html From pitekus at gmail.com Sun Jul 26 16:27:41 2009 From: pitekus at gmail.com (=?UTF-8?Q?Grzegorz_Chrupa=C5=82a?=) Date: Sun Jul 26 16:08:59 2009 Subject: [Haskell-cafe] Data.Binary.encode slower than show In-Reply-To: References: Message-ID: <73f919100907261327g2b74d58y454e49324f2faf67@mail.gmail.com> Hi all, I have a piece of code where I'm serializing a datastructure with the following type [(Int, (Map DType (IntMap Int)))], using Binary.encode The thing is it is very slow: actually quite a bit slower than just using show. This seems rather suspicious. Any idea what could be going on? import qualified Data.Map as Map import qualified Data.IntMap as IntMap import Data.IntMap ((!)) import Vector import Atom import Control.Monad.State import Indexing (indexBy) import Data.List (foldl') import System import System.IO import Debug.Trace import qualified Data.Binary as Binary import qualified Data.ByteString.Lazy as BS data DType = Fol | For | Sol | Sor deriving (Eq,Enum,Ord,Show,Read) instance Binary.Binary DType where ? ?get = do x <- Binary.get ? ? ? ? ? ? return (toEnum x) ? ?put x = Binary.put (fromEnum x) type Word = Int type Count = Int type WordMap = IntMap.IntMap find = IntMap.findWithDefault IntMap.empty distReps :: ? ?Map.Map (Word,Word) Count ? ? ? ? ? ?-> [(Int, (Map.Map DType (WordMap Count)))] distReps bidict = ? ?let bigrams = Map.toList bidict ? ? ? ?for = indexBy id bigrams ? ? ? ?fol = indexBy swap bigrams ? ? ? ?ws ?= map (fst . fst) bigrams ? ? ? ?r = flip map ws ? ? ? ? ? ?$ \w -> (w,Map.fromList [ (Fol , find w fol) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?, (For , find w for) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?, (Sol , sox for fol w ) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?, (Sor , sox fol for w ) ]) ? ?in trace (show $ r == r) ?r sox :: WordMap (WordMap Count) ? ?-> WordMap (WordMap Count) ? ?-> Word ? ?-> WordMap Count sox fox foy w = ? ?let xs = IntMap.keys (find w fox) ? ? ? ?f !z x = let xv = find x foy ? ? ? ? ? ? ? ? in xv == xv `seq` z `plus` xv ? ?in foldl' f IntMap.empty xs swap (!a,!b) = (b,a) readBigrams = fmap (map (\ [w,w',c] -> ((w,w'),read c)) ? ? ? ? ? ? ? ?. map words ? ? ? ? ? ? ? ? ? ? ?. lines ) ? ? ? ? ? ? ?getContents main = do ?[f] <- getArgs ?bigrams <- readBigrams ?let (bigrams',as) = flip runState empty (atomize bigrams) ? ? ?dr = distReps (Map.fromList bigrams') ?write f dr ?hPutStrLn stderr "Done this" ?write (f++".atom") as --write f d = ?writeFile f (show d) write f d = BS.writeFile f (Binary.encode d) atomize xs = mapM f xs ? ?where f ((w,w'),!i) = do ? ? ? ? ? ?!i_w <- toAtom w' ? ? ? ? ? ?!i_w' <- toAtom w ? ? ? ? ? ?let r = ((i_w,i_w'),i) ? ? ? ? ? ?r == r `seq` return r -- Grzegorz From patai_gergely at fastmail.fm Sun Jul 26 16:46:15 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sun Jul 26 16:27:31 2009 Subject: [Haskell-cafe] ANN: Elerea version 1.x.x Message-ID: <1248641175.1305.1326866767@webmail.messagingengine.com> Hi all, Having taken a short break from my profiling project, I updated my little FRP library called Elerea [1] along with the runnable example programs [2]. The interface was changed into a monadic-applicative hybrid that distinguishes stateful and stateless combinators for safety reasons. Since this is a major change, this release bears a new major version number. Most importantly, the latcher was removed due to various practical issues, and it is replaced by much better behaved stateless higher-order constructs. The library is capable of handling arbitrary higher-order signals, e.g. dynamic collections of signals, as shown by the renewed breakout example (which used to cheat so far by treating the state of the brick collection as a single value). I intend to write some tutorials later, but feel free to experiment until then. Gergely [1] http://hackage.haskell.org/package/elerea [2] http://hackage.haskell.org/package/elerea-examples -- http://www.fastmail.fm - The professional email service From peteg42 at gmail.com Sun Jul 26 21:12:59 2009 From: peteg42 at gmail.com (Peter Gammie) Date: Sun Jul 26 20:54:20 2009 Subject: [Haskell-cafe] TBC: Testing By Convention Message-ID: <3334B0E1-592F-4860-8E03-08AB8C944183@gmail.com> Hello, Mark and I would like to announce our test harness, which has features complementary to existing harnesses. TBC provides two main features: - It attempts to compile and run all tests, even if some do not compile or run. - Aspiring to the write-it-once principle, tests following conventions require a lot less boilerplate. It is at an embryonic stage of development, and would greatly benefit from feedback and/or patches. :-) Hackage: http://hackage.haskell.org/package/TBC git: http://github.com/peteg/TBC/ Enjoy! cheers peter -- http://peteg.org/ From linker.m.lin at gmail.com Sun Jul 26 22:50:39 2009 From: linker.m.lin at gmail.com (Linker) Date: Sun Jul 26 22:31:55 2009 Subject: [Haskell-cafe] Is a bug? Message-ID: Hi,All! I find out that diff between GHC and Hugs: GHC: *Prelude> sqrt 3+4+9 14.732050807568877 Prelude> sqrt 16 4.0 Prelude> sqrt $3+4+9 14.732050807568877* Hugs:*Hugs> sqrt $ 3+4+9* *4.0* *Hugs> sqrt 3+4+9* *14.7320508075689* Which one is right? Thanks. -- Regards, Linker Lin linker.m.lin@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090726/f86227e2/attachment.html From linker.m.lin at gmail.com Sun Jul 26 22:54:53 2009 From: linker.m.lin at gmail.com (Linker) Date: Sun Jul 26 22:36:08 2009 Subject: [Haskell-cafe] Re: Is a bug? In-Reply-To: References: Message-ID: Sorry.I defined a function : *GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help* *Loading package ghc-prim ... linking ... done.* *Loading package integer ... linking ... done.* *Loading package base ... linking ... done.* *Prelude> sqrt $ 3 + 4 + 9* *4.0* *Prelude> let f $ x = f x* *Prelude> sqrt $ 3 + 4 + 9* *14.732050807568877* *Prelude>* On Mon, Jul 27, 2009 at 10:50, Linker wrote: > Hi,All! > I find out that diff between GHC and Hugs: > GHC: > > *Prelude> sqrt 3+4+9 > 14.732050807568877 > Prelude> sqrt 16 > 4.0 > Prelude> sqrt $3+4+9 > 14.732050807568877* > > Hugs: *Hugs> sqrt $ 3+4+9* > *4.0* > *Hugs> sqrt 3+4+9* > *14.7320508075689* > > Which one is right? > Thanks. > > > -- > Regards, > Linker Lin > linker.m.lin@gmail.com > > -- Regards, Linker Lin linker.m.lin@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090726/344544b4/attachment.html From dan.doel at gmail.com Sun Jul 26 23:04:06 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sun Jul 26 22:45:24 2009 Subject: [Haskell-cafe] Re: Is a bug? In-Reply-To: References: Message-ID: <200907262304.06933.dan.doel@gmail.com> On Sunday 26 July 2009 10:54:53 pm Linker wrote: > Sorry.I defined a function : > > *GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help* > *Loading package ghc-prim ... linking ... done.* > *Loading package integer ... linking ... done.* > *Loading package base ... linking ... done.* > *Prelude> sqrt $ 3 + 4 + 9* > *4.0* > *Prelude> let f $ x = f x* > *Prelude> sqrt $ 3 + 4 + 9* > *14.732050807568877* > *Prelude>* Unless otherwise specified, operators receive precedence (I think) infixl 9. The ($) in the prelude is infixr 0, so sqrt $ 3 + 4 + 9 = sqrt (3 + 4 + 9) When you define your own ($) in that session, you don't give a corresponding fixity declaration, so infixl 9 is assumed. Thus your second expression parses thusly: sqrt $ 3 + 4 + 9 = (sqrt 3) + 4 + 9 You can give fixity declarations in lets and wheres, so: let infixr 0 $ ; f $ x = f x should act the same as the prelude-defined operator. -- Dan From goofyheadedpunk at gmail.com Mon Jul 27 00:01:22 2009 From: goofyheadedpunk at gmail.com (Brian Troutwine) Date: Sun Jul 26 23:42:36 2009 Subject: [Haskell-cafe] A Question of Restriction Message-ID: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> Hello all. I would like to define a data type that is the super-set of several types and then each of the proper subset types. For example: data Foo = One | Two | Three | Four data Odd = One | Three data Even = Two | Four This, of course, does not work. It seems that such a thing should possible to express entirely in the type system, but I cannot think of how. Would someone be so kind as to explain how this sort of thing can be accomplished? Thanks, Brian From rmm-haskell at z.odi.ac Mon Jul 27 00:11:03 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Sun Jul 26 23:52:21 2009 Subject: [Haskell-cafe] A Question of Restriction In-Reply-To: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> Message-ID: <2C405AC1-F7F2-4459-8775-6941A27D7906@z.odi.ac> I've seen this expressed with GADTs (which I guess many things can), though I'm not sure if it's the best way, and I'm no type system wizard. If I recall correctly, this use is normally called phantom types. {-# LANGUAGE EmptyDataDecls, GADTs #-} data Even data Odd data Foo a where One :: Foo Odd Two :: Foo Even Three :: Foo Odd Four :: Foo Even Then you can write functions that accept only evens: f :: Foo Even -> ... or only odds: f :: Foo Odd -> ... or either: f :: Foo a -> ... Hope that helps, -Ross On Jul 27, 2009, at 12:01 AM, Brian Troutwine wrote: > Hello all. > > I would like to define a data type that is the super-set of several > types and then each of the proper subset types. For example: > > data Foo = One | Two | Three | Four > data Odd = One | Three > data Even = Two | Four > > This, of course, does not work. It seems that such a thing should > possible to express entirely in the type system, but I cannot think of > how. Would someone be so kind as to explain how this sort of thing can > be accomplished? > > Thanks, > Brian > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From felipe.lessa at gmail.com Mon Jul 27 00:14:07 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Jul 26 23:55:30 2009 Subject: [Haskell-cafe] A Question of Restriction In-Reply-To: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> Message-ID: <20090727041407.GA28014@kira.casa> On Sun, Jul 26, 2009 at 09:01:22PM -0700, Brian Troutwine wrote: > Hello all. > > I would like to define a data type that is the super-set of several > types and then each of the proper subset types. For example: > data Foo = O !Odd | E !Even > data Odd = One | Three > data Even = Two | Four > > This, of course, does not work. It seems that such a thing should > possible to express entirely in the type system, but I cannot think of > how. Would someone be so kind as to explain how this sort of thing can > be accomplished? Do you have any reason not to do the above? -- Felipe. From alexander.dunlap at gmail.com Mon Jul 27 00:26:14 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Mon Jul 27 00:07:49 2009 Subject: [Haskell-cafe] TBC: Testing By Convention In-Reply-To: <3334B0E1-592F-4860-8E03-08AB8C944183@gmail.com> References: <3334B0E1-592F-4860-8E03-08AB8C944183@gmail.com> Message-ID: <57526e770907262126k172c6cb0u1b4dd726865913a9@mail.gmail.com> On Sun, Jul 26, 2009 at 6:12 PM, Peter Gammie wrote: > Hello, > > Mark and I would like to announce our test harness, which has features > complementary to existing harnesses. > > TBC provides two main features: > - It attempts to compile and run all tests, even if some do not compile or > run. > - Aspiring to the write-it-once principle, tests following conventions > require a lot less boilerplate. > > It is at an embryonic stage of development, and would greatly benefit from > feedback and/or patches. :-) > > Hackage: http://hackage.haskell.org/package/TBC > git: http://github.com/peteg/TBC/ > > Enjoy! > > cheers > peter > > -- > http://peteg.org/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Can it return an exit status based on whether or not all tests passed? If not, that would be a very useful feature that I have not seen in any other testing frameworks. Alex From goofyheadedpunk at gmail.com Mon Jul 27 01:03:20 2009 From: goofyheadedpunk at gmail.com (Brian Troutwine) Date: Mon Jul 27 00:44:34 2009 Subject: [Haskell-cafe] A Question of Restriction In-Reply-To: <20090727041407.GA28014@kira.casa> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> <20090727041407.GA28014@kira.casa> Message-ID: <971980cc0907262203t1f7be39ds4e0d72166be89350@mail.gmail.com> > Do you have any reason not to do the above? Yes, the subset types that I wish to define are not clean partitions, though my example does suggest this. Let's say that the definition of Foo is now data Foo = One | Two | Three | Four | Five | Six while Odd and Even remain the same. I would further like to define Triangular, which I will do incorrectly for consistency. data Triangular = One | Three | Six I could not accommodate this definition using your scheme, correct? Thanks, Brian On Sun, Jul 26, 2009 at 9:14 PM, Felipe Lessa wrote: > On Sun, Jul 26, 2009 at 09:01:22PM -0700, Brian Troutwine wrote: >> Hello all. >> >> I would like to define a data type that is the super-set of several >> types and then each of the proper subset types. For example: >> > > data Foo = O !Odd | E !Even > >> ? ?data Odd = One | Three >> ? ?data Even = Two | Four >> >> This, of course, does not work. It seems that such a thing should >> possible to express entirely in the type system, but I cannot think of >> how. Would someone be so kind as to explain how this sort of thing can >> be accomplished? > > Do you have any reason not to do the above? > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From kyagrd at gmail.com Mon Jul 27 01:28:03 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Mon Jul 27 01:09:38 2009 Subject: [Haskell-cafe] Re: A Question of Restriction In-Reply-To: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> Message-ID: Brian Troutwine wrote: > Hello all. > > I would like to define a data type that is the super-set of several > types and then each of the proper subset types. For example: > > data Foo = One | Two | Three | Four > data Odd = One | Three > data Even = Two | Four > > This, of course, does not work. It seems that such a thing should > possible to express entirely in the type system, but I cannot think of > how. Would someone be so kind as to explain how this sort of thing can > be accomplished? You might want to look at Johan Nordlander's O'Haskell. It's a dialect of Haskell with such subtyping, designed and implemented while ago. Recently there was a proposal (but not an implementation yet) of subtyping data types in general with recursion and including GADTs http://portal.acm.org/citation.cfm?id=1411286.1411297 (I want to work on this again some time later again). But neither of these work is not implemented as an extension feature in major Haskell implementations like GHC or Hugs. I want to push this work further some time later on. FYI, there exist a functional language which you can express this kind of idea though. For example, in OCaml, you can use polymorphic variants. From peteg42 at gmail.com Mon Jul 27 01:32:14 2009 From: peteg42 at gmail.com (Peter Gammie) Date: Mon Jul 27 01:13:35 2009 Subject: [Haskell-cafe] TBC: Testing By Convention In-Reply-To: <57526e770907262126k172c6cb0u1b4dd726865913a9@mail.gmail.com> References: <3334B0E1-592F-4860-8E03-08AB8C944183@gmail.com> <57526e770907262126k172c6cb0u1b4dd726865913a9@mail.gmail.com> Message-ID: <4F9B3277-3524-46E2-BA23-A7397FFE03F0@gmail.com> On 27/07/2009, at 2:26 PM, Alexander Dunlap wrote: > Can it return an exit status based on whether or not all tests passed? > If not, that would be a very useful feature that I have not seen in > any other testing frameworks. It could, and that's probably true of the other harnesses out there. The git repo for TBC now has this feature; it's a bit of a hack as some of the functions in Cabal that TBC uses have overly restrictive types. cheers peter From DekuDekuplex at Yahoo.com Mon Jul 27 02:30:21 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Jul 27 02:11:51 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> Message-ID: On Thu, 16 Jul 2009 13:38:14 +1200, "Richard O'Keefe" wrote: > >On Jul 15, 2009, at 5:25 PM, Benjamin L.Russell wrote: >> it interesting that you should use the biological term "disease"; >> according to a post [1] entitled "Re: Re: Smalltalk Data Structures >> and Algorithms," by K. K. Subramaniam, dated "Mon, 29 Jun 2009 >> 11:25:34 +0530," on the squeak-beginners mailing list (see >> http://lists.squeakfoundation.org/pipermail/beginners/2009-June/006270.html) >> , >>> Concepts in Squeak [a dialect and implementation of Smalltalk] have >> their origins >>> in biology rather than in computational math.... > >That posting is wrong. > >Smalltalk's roots are very firmly planted in Lisp, >with perhaps a touch of Logo (which also had its roots in Lisp). >The classic Smalltalk-76 paper even contains a meta-circular >interpreter, which I found reminiscent of the old Lisp one. >The "biological" metaphor in Smalltalk is actually a SOCIAL >metaphor: sending and receiving messages, and a "social" >model of agents with memory exchanging messages naturally >leads to anthropomorphisms.... Incidentally, just for the record, in response to my forwarding your claim, Alan Kay, the inventor of Smalltalk, just refuted your refutation [1] (see http://lists.squeakfoundation.org/pipermail/beginners/2009-July/006331.html); _viz._: >I most definitely still think of OOP at its best as being "biological". -- Benjamin L. Russell [1] Kay, Alan. "[Newbies] Re: Smalltalk Data Structures and Algorithms." The Beginners Archives. Squeak.org. 24 July 2009. 27 July 2009. . -- 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 phil at kantaka.co.uk Mon Jul 27 03:13:11 2009 From: phil at kantaka.co.uk (Philip Armstrong) Date: Mon Jul 27 02:54:26 2009 Subject: [Haskell-cafe] Data.Binary.encode slower than show In-Reply-To: <73f919100907261327g2b74d58y454e49324f2faf67@mail.gmail.com> References: <73f919100907261327g2b74d58y454e49324f2faf67@mail.gmail.com> Message-ID: <20090727071311.GA6229@kantaka.co.uk> On Sun, Jul 26, 2009 at 10:27:41PM +0200, Grzegorz Chrupa?a wrote: >Hi all, >I have a piece of code where I'm serializing a datastructure with the >following type [(Int, (Map DType (IntMap Int)))], using Binary.encode >The thing is it is very slow: actually quite a bit slower than just using >show. >This seems rather suspicious. Any idea what could be going on? Does Map serialisation still require flattening the map to a List? Phil -- http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt From magicloud.magiclouds at gmail.com Mon Jul 27 03:52:36 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon Jul 27 03:33:52 2009 Subject: [Haskell-cafe] Is there a sample code for hdbus? Message-ID: <3bd412d40907270052jb7a757bxa11358bddf731815@mail.gmail.com> Hi, Although I have used dbus with ruby a little, but still, I do not understand hdbus's APIs.... Is there any sample that I could learn? Thanks. -- ??????? ??????? From gleb.alexeev at gmail.com Mon Jul 27 04:31:13 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Mon Jul 27 04:12:50 2009 Subject: [Haskell-cafe] Re: A Question of Restriction In-Reply-To: <971980cc0907262203t1f7be39ds4e0d72166be89350@mail.gmail.com> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> <20090727041407.GA28014@kira.casa> <971980cc0907262203t1f7be39ds4e0d72166be89350@mail.gmail.com> Message-ID: Brian Troutwine wrote: >> Do you have any reason not to do the above? > > Yes, the subset types that I wish to define are not clean partitions, > though my example does suggest this. Let's say that the definition of > Foo is now > > data Foo = One | Two | Three | Four | Five | Six > > while Odd and Even remain the same. I would further like to define > Triangular, which I will do incorrectly for consistency. > > data Triangular = One | Three | Six > > I could not accommodate this definition using your scheme, correct? > A variation on scheme proposed by Ross Mellgren earlier in this thread. It's a bit tedious but allows for definition of arbitrary subsets thus it may work for you: {-# LANGUAGE GADTs, EmptyDataDecls #-} data One data Two data Three data Four data Foo a where FOne :: Foo One FTwo :: Foo Two FThree :: Foo Three FFour :: Foo Four class IsEven a instance IsEven Two instance IsEven Four class IsOdd a instance IsOdd One instance IsOdd Three class IsLessThanThree a instance IsLessThanThree One instance IsLessThanThree Two quux :: IsEven a => Foo a -> String quux FTwo = "2" quux FFour = "4" bzzt :: IsLessThanThree a => Foo a -> String bzzt FOne = "1" bzzt FTwo = "2" From wss at cs.nott.ac.uk Mon Jul 27 05:37:10 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Mon Jul 27 05:18:25 2009 Subject: [Haskell-cafe] A Question of Restriction In-Reply-To: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> Message-ID: <35B36AF3-0AE5-4DFD-A263-13FDE330E94C@cs.nott.ac.uk> Hi Brian, If I understand you correctly, you've run into the "Expression Problem". Phil Wadler posed the problem in a widely-cited e-mail, formulating it much more clearly than I ever could: http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt There are lots of ways to tackle this problem in Haskell - just google "Expression Problem Haskell". My (completely biased) personal favourite is: http://www.cse.chalmers.se/~wouter/Publications/DataTypesALaCarte.pdf Hope this helps, Wouter From waldmann at imn.htwk-leipzig.de Mon Jul 27 11:58:11 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Mon Jul 27 11:39:30 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution Message-ID: <4A6DCE93.5020700@imn.htwk-leipzig.de> While browsing Haskell-Prime I found this: http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution This is not some April Fool's day hoax? Because, it might actually turn Haskell into a somewhat usable (and marketable) language ... well, you know what I mean. Is there 'ghc -XTypeDirectedNameResolution' yet? - J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090727/54261360/signature.bin From bulat.ziganshin at gmail.com Mon Jul 27 12:03:14 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jul 27 11:44:35 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <4A6DCE93.5020700@imn.htwk-leipzig.de> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> Message-ID: <125957493.20090727200314@gmail.com> Hello Johannes, Monday, July 27, 2009, 7:58:11 PM, you wrote: > While browsing Haskell-Prime I found this: > http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution haskell-prime is future haskell standard now in development and on this wiki anyone can write his proposals without any actual implementation -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From waldmann at imn.htwk-leipzig.de Mon Jul 27 12:10:57 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Mon Jul 27 11:52:15 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <125957493.20090727200314@gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <125957493.20090727200314@gmail.com> Message-ID: <4A6DD191.8010600@imn.htwk-leipzig.de> > this wiki anyone can write his proposals [...] sure, but this "anyone" is "simponpj" ... -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090727/813ec724/signature.bin From cgibbard at gmail.com Mon Jul 27 12:29:45 2009 From: cgibbard at gmail.com (Cale Gibbard) Date: Mon Jul 27 12:10:58 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <4A6DCE93.5020700@imn.htwk-leipzig.de> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> Message-ID: <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> 2009/7/27 Johannes Waldmann : > While browsing Haskell-Prime I found this: > http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution > > This is not some April Fool's day hoax? Because, it might actually > turn Haskell into a somewhat usable (and marketable) language ... > well, you know what I mean. You would be arguing against it then? ;) > Is there 'ghc -XTypeDirectedNameResolution' yet? I'm pretty sure there is not. I don't really care for this proposal because it involves yet more overloading of (.) which rather annoys me. Composition is by far the most common infix operator in my code, and I consider its choice for module qualification a minor, but irritating mistake. (It makes composition chains with qualified names just that much harder to scan with your eyes.) There was a great related idea on #haskell the other day: Make explicit qualification unnecessary whenever there is a *unique* choice of module qualifications from those imported which would make the expression typecheck. Ambiguities would still need to be qualified, but I feel that this would eliminate 99% of all ugly qualified names from code. It would be especially good in the case of infix operators, which as far as I know, nobody actually enjoys qualifying explicitly. I can see some corner cases where this might lead to a combinatorial explosion of possible qualifications to try, however, I have a feeling that such cases wouldn't really happen in practice. It is admittedly a bit like a very restricted sort of ad-hoc polymorphism, but given that the modules are compiled separately, I think the actual interactions with the workings of the type system are not really very significant. (It's just like you tried each set of possible qualifications, compiling the whole thing each time, and checking to see if there's a unique way to get the module to compile.) This would mean that if we had, say, Data.List, Data.Map and Data.Set imported, and there was an occurrence of insert that happened to be applied to a couple of values and then something known to be a Map, it would behave as if you'd written Data.Map.insert, because that's the only thing which could possibly make sense. If there were ambiguity about which insert you meant, it would still be an error, and you might have to qualify it explicitly. What do people think of this idea? Personally, it really annoys me whenever I'm forced to give explicit module qualifications, and I think this would really help. It would also subsume the DisambiguateRecordFields extension rather handily. - Cale From jules at jellybean.co.uk Mon Jul 27 12:37:02 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Jul 27 12:18:17 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <4A6DD7AE.8000702@jellybean.co.uk> Cale Gibbard wrote: > What do people think of this idea? Personally, it really annoys me > whenever I'm forced to give explicit module qualifications, and I > think this would really help. It would also subsume the > DisambiguateRecordFields extension rather handily. > A disadvantage - and this is not a "No" vote, just a remark - is that when trying to debug the expression: foo bar baz quux if I type ":t bar" I will presumably get an ambiguity error, and I may have no easy way of working out *which* bar was actually intended in this line of code. I don't know how much of a burden this is, but it feels like a burden to writing/debugging/understanding code. Jules From john at n-brain.net Mon Jul 27 12:43:34 2009 From: john at n-brain.net (John A. De Goes) Date: Mon Jul 27 12:24:51 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <9C5F003D-AC50-4ABF-8302-640C5AED15F0@n-brain.net> I've spoken in favor of this many times before. But there are many who think, "Every function you write should have a unique name." Talk about needless clutter. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Jul 27, 2009, at 10:29 AM, Cale Gibbard wrote: > What do people think of this idea? Personally, it really annoys me > whenever I'm forced to give explicit module qualifications, and I > think this would really help. It would also subsume the > DisambiguateRecordFields extension rather handily. From cgibbard at gmail.com Mon Jul 27 12:52:38 2009 From: cgibbard at gmail.com (Cale Gibbard) Date: Mon Jul 27 12:33:54 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <4A6DD7AE.8000702@jellybean.co.uk> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <4A6DD7AE.8000702@jellybean.co.uk> Message-ID: <89ca3d1f0907270952y44ae51e0qf9a969bf5950c10c@mail.gmail.com> 2009/7/27 Jules Bean : > Cale Gibbard wrote: >> >> What do people think of this idea? Personally, it really annoys me >> whenever I'm forced to give explicit module qualifications, and I >> think this would really help. It would also subsume the >> DisambiguateRecordFields extension rather handily. >> > > A disadvantage - and this is not a "No" vote, just a remark - is that when > trying to debug the expression: > > foo bar baz quux > > if I type ":t bar" I will presumably get an ambiguity error, and I may have > no easy way of working out *which* bar was actually intended in this line of > code. > > I don't know how much of a burden this is, but it feels like a burden to > writing/debugging/understanding code. > > Jules > There certainly do seem like some cases where it would help the person reading the code to qualify which module you meant, so clearly if it's not very obvious which selection of modules produces the unique way to get things to typecheck, that's not very good. Perhaps there should at least be the restriction that there must exist a chain of individual choices made where there was a unique possibility at each step. This ensures that you never have to backtrack in deciding which modules things are intended to come from. Of course, in cases where it's still not obvious, it'd still be possible to make the qualification explicit. The goal is to eliminate the need to explicitly qualify in the cases where it's entirely obvious what the qualification should be. - Cale From dagit at codersbase.com Mon Jul 27 12:57:05 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Jul 27 12:38:19 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: On Mon, Jul 27, 2009 at 9:29 AM, Cale Gibbard wrote: > 2009/7/27 Johannes Waldmann : > > While browsing Haskell-Prime I found this: > > > http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution > > > > This is not some April Fool's day hoax? Because, it might actually > > turn Haskell into a somewhat usable (and marketable) language ... > > well, you know what I mean. > > You would be arguing against it then? ;) > > > Is there 'ghc -XTypeDirectedNameResolution' yet? > > I'm pretty sure there is not. > > I don't really care for this proposal because it involves yet more > overloading of (.) which rather annoys me. Composition is by far the > most common infix operator in my code, and I consider its choice for > module qualification a minor, but irritating mistake. (It makes > composition chains with qualified names just that much harder to scan > with your eyes.) > > There was a great related idea on #haskell the other day: Make > explicit qualification unnecessary whenever there is a *unique* choice > of module qualifications from those imported which would make the > expression typecheck. Ambiguities would still need to be qualified, > but I feel that this would eliminate 99% of all ugly qualified names > from code. It would be especially good in the case of infix operators, > which as far as I know, nobody actually enjoys qualifying explicitly. My biggest fear is that of usability. If I understand you correctly, then as you change module imports you change the meaning of the code in potentially non-obvious ways. So this isn't too different than using unqualified imports and flipping between two modules that export the same function. Except that as you increase the 'automatic'ness of it, it has the potential to trip up people. I think what is the worse case is, you add a module import and suddenly you have an error in code that was previously compiling. Suddenly the auto-disambiguate stops working in a chunk of code that was fine before. When working with code that others have written this would confuse me. I think I would then start using qualified imports everywhere just to "work around" this feature :) Yes, I realize it would be an extension, but it would be an extension that I suspect I would try to avoid. > > What do people think of this idea? Personally, it really annoys me > whenever I'm forced to give explicit module qualifications, and I > think this would really help. It would also subsume the > DisambiguateRecordFields extension rather handily. I like explicit module qualifications more or less. I certainly don't mind reading them and I don't care if it takes 2 seconds longer to type something. You asked for my thoughts and there they are :) Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090727/fd6ec956/attachment.html From gue.schmidt at web.de Mon Jul 27 13:09:28 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Jul 27 12:50:57 2009 Subject: [Haskell-cafe] Retiring forkIO Message-ID: Hi, I'd like to retire forkIO and friends by using Delimited Continuations instead. Am I dead wrong here in my understanding of Delimited Continuations or can I pursue in this direction? The most immediate use for this is actully GUI problems where I'd use del-conts in place of forkIO for long-running computations because once I forkIO the computation so as not to block the UI thread I cannot call GUI code from the end of that thread. Well I can but then the app crashes because of single threading issues. G?nther From cgibbard at gmail.com Mon Jul 27 13:10:45 2009 From: cgibbard at gmail.com (Cale Gibbard) Date: Mon Jul 27 12:51:59 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <89ca3d1f0907271010r359baf22q6a1e66a4d91fd8a2@mail.gmail.com> 2009/7/27 Jason Dagit : > > > On Mon, Jul 27, 2009 at 9:29 AM, Cale Gibbard wrote: >> >> 2009/7/27 Johannes Waldmann : >> > While browsing Haskell-Prime I found this: >> > >> > http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution >> > >> > This is not some April Fool's day hoax? Because, it might actually >> > turn Haskell into a somewhat usable (and marketable) language ... >> > well, you know what I mean. >> >> You would be arguing against it then? ;) >> >> > Is there 'ghc -XTypeDirectedNameResolution' yet? >> >> I'm pretty sure there is not. >> >> I don't really care for this proposal because it involves yet more >> overloading of (.) which rather annoys me. Composition is by far the >> most common infix operator in my code, and I consider its choice for >> module qualification a minor, but irritating mistake. (It makes >> composition chains with qualified names just that much harder to scan >> with your eyes.) >> >> There was a great related idea on #haskell the other day: Make >> explicit qualification unnecessary whenever there is a *unique* choice >> of module qualifications from those imported which would make the >> expression typecheck. Ambiguities would still need to be qualified, >> but I feel that this would eliminate 99% of all ugly qualified names >> from code. It would be especially good in the case of infix operators, >> which as far as I know, nobody actually enjoys qualifying explicitly. > > My biggest fear is that of usability. > > If I understand you correctly, then as you change module imports you change > the meaning of the code in potentially non-obvious ways.? So this isn't too > different than using unqualified imports and flipping between two modules > that export the same function.? Except that as you increase the > 'automatic'ness of it, it has the potential to trip up people. Well, yes, but only insofar as you can already cause that to happen. Simply adding a new module import might force you to qualify some names, as you mention below (and as it can already force you to do), but will never cause the meaning to otherwise change, since it's not doing something like picking the first module which works (which would really be bad). It's only fixing the qualification in places where there's *exactly one* qualification that would work. Similarly, removing a module import will not cause the meaning to change, supposing that the module still compiles, and if you can do that, you can still be certain that nothing from that module was being used. Of course, put the two together in one step, and you can change semantics arbitrarily, but that's already the case, and I don't think that's necessarily something to be avoided. > I think what is the worse case is, you add a module import and suddenly you > have an error in code that was previously compiling.? Suddenly the > auto-disambiguate stops working in a chunk of code that was fine before. > When working with code that others have written this would confuse me.? I > think I would then start using qualified imports everywhere just to "work > around" this feature :) You can already import a module and suddenly need to disambiguate expressions where a name gets used. This just relieves you of that responsibility sometimes. Consider the case where you have a module with a bunch of uses of stuff from Data.List and the Prelude, and you decide that you need Data.Map for a new function. If you import Data.Map, all of a sudden, you need to qualify half of the Prelude and Data.List stuff or it would be ambiguous. (Or import Data.Map qualified.) > Yes, I realize it would be an extension, but it would be an extension that I > suspect I would try to avoid. > >> >> What do people think of this idea? Personally, it really annoys me >> whenever I'm forced to give explicit module qualifications, and I >> think this would really help. It would also subsume the >> DisambiguateRecordFields extension rather handily. > > I like explicit module qualifications more or less.? I certainly don't mind > reading them and I don't care if it takes 2 seconds longer to type > something.? You asked for my thoughts and there they are :) Well, thanks :) I do think some thought has to be put into limiting the power of it, so that we don't end up with situations where only a computer could figure out what's going on. - Cale From dons at galois.com Mon Jul 27 13:10:01 2009 From: dons at galois.com (Don Stewart) Date: Mon Jul 27 12:53:15 2009 Subject: [Haskell-cafe] Retiring forkIO In-Reply-To: References: Message-ID: <20090727171001.GC30193@whirlpool.galois.com> gue.schmidt: > Hi, > > I'd like to retire forkIO and friends by using Delimited Continuations > instead. Am I dead wrong here in my understanding of Delimited > Continuations or can I pursue in this direction? > > The most immediate use for this is actully GUI problems where I'd use > del-conts in place of forkIO for long-running computations because once I > forkIO the computation so as not to block the UI thread I cannot call GUI > code from the end of that thread. Well I can but then the app crashes > because of single threading issues. > Can you provide some examples of how you'd rewrite forkIO code to use del-conts? -- Don From gue.schmidt at web.de Mon Jul 27 13:19:32 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Jul 27 13:00:48 2009 Subject: [Haskell-cafe] Retiring forkIO In-Reply-To: <20090727171001.GC30193@whirlpool.galois.com> References: <20090727171001.GC30193@whirlpool.galois.com> Message-ID: Hi Don, no I can't, I have no clue how to do that. :) There is Olegs ZFS and he has written all his code without any use of forkIO, so I know it's possible, I just haven't been able to translate it to my problem. G?nther Am 27.07.2009, 19:10 Uhr, schrieb Don Stewart : > gue.schmidt: >> Hi, >> >> I'd like to retire forkIO and friends by using Delimited Continuations >> instead. Am I dead wrong here in my understanding of Delimited >> Continuations or can I pursue in this direction? >> >> The most immediate use for this is actully GUI problems where I'd use >> del-conts in place of forkIO for long-running computations because once >> I >> forkIO the computation so as not to block the UI thread I cannot call >> GUI >> code from the end of that thread. Well I can but then the app crashes >> because of single threading issues. >> > > Can you provide some examples of how you'd rewrite forkIO code to use > del-conts? > > -- Don From waldmann at imn.htwk-leipzig.de Mon Jul 27 14:09:33 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Mon Jul 27 13:50:57 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <4A6DED5D.6020000@imn.htwk-leipzig.de> about qualified imports and TDNR: for x.f to work (as in the proposal), the name f must be in scope (that is, be imported unqualified)? That would be bad (unqualified imports should be discouraged). In Java, the methods of a type are automatically in scope, e.g., the ".bitCount()" works without any "import": System.out.println ( java.math.BigInteger.TEN.bitCount() ); see JLS 15.12.1 item 1.3 ("in all other cases...") J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090727/72bcde62/signature.bin From conal at conal.net Mon Jul 27 14:23:07 2009 From: conal at conal.net (Conal Elliott) Date: Mon Jul 27 14:04:42 2009 Subject: [Haskell-cafe] 'cabal install lhs2tex' fails for me on os x -- help please Message-ID: Fails during configuration: bash-3.2$ cabal install lhs2tex Resolving dependencies... [1 of 1] Compiling Main ( /tmp/lhs2tex-1.1423397/lhs2tex-1.14/Setup.hs, /tmp/lhs2tex-1.1423397/lhs2tex-1.14/dist/setup/Main.o ) Linking /tmp/lhs2tex-1.1423397/lhs2tex-1.14/dist/setup/setup ... Configuring lhs2tex-1.14... cabal: Error: some packages failed to install: lhs2tex-1.14 failed during the configure step. The exception was: exit: ExitFailure 11 Note that the the first module to be compiled is Main. On my linux machine, Main is the *last* of several modules to be compiled. Here's my failure log: http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3096#a3096 . If instead I use ./configure and make, i get errors due to use of the old Exception API: ... [17 of 19] Compiling FileNameUtils ( FileNameUtils.lhs, FileNameUtils.o ) FileNameUtils.lhs:81:35: Ambiguous type variable `b' in the constraint: `GHC.Exception.Exception b' arising from a use of `catch' at FileNameUtils.lhs:(81,35)-(89,60) Probable fix: add a type signature that fixes these type variable(s) ... Suggestions greatly appreciated! - Conal -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090727/d14eac43/attachment.html From dons at galois.com Mon Jul 27 14:22:42 2009 From: dons at galois.com (Don Stewart) Date: Mon Jul 27 14:05:59 2009 Subject: [Haskell-cafe] 'cabal install lhs2tex' fails for me on os x -- help please In-Reply-To: References: Message-ID: <20090727182242.GF30193@whirlpool.galois.com> conal: > Fails during configuration: > > bash-3.2$ cabal install lhs2tex > Resolving dependencies... > [1 of 1] Compiling Main ( /tmp/lhs2tex-1.1423397/lhs2tex-1.14/ > Setup.hs, /tmp/lhs2tex-1.1423397/lhs2tex-1.14/dist/setup/Main.o ) > Linking /tmp/lhs2tex-1.1423397/lhs2tex-1.14/dist/setup/setup ... > Configuring lhs2tex-1.14... > cabal: Error: some packages failed to install: > lhs2tex-1.14 failed during the configure step. The exception was: > exit: ExitFailure 11 > > Note that the the first module to be compiled is Main. On my linux machine, > Main is the *last* of several modules to be compiled. > > Here's my failure log: http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3096# > a3096 . > > If instead I use ./configure and make, i get errors due to use of the old > Exception API: > > ... > [17 of 19] Compiling FileNameUtils ( FileNameUtils.lhs, FileNameUtils.o > ) > > FileNameUtils.lhs:81:35: > Ambiguous type variable `b' in the constraint: > `GHC.Exception.Exception b' > arising from a use of `catch' at FileNameUtils.lhs:(81,35)-(89,60) > Probable fix: add a type signature that fixes these type variable(s) > ... > > Suggestions greatly appreciated! Via cabal: --constraint='base<4' or replace Control.Exception with Control.OldException or add 'base < 4' to the depends in the .cabal file. -- Don From allbery at ece.cmu.edu Mon Jul 27 14:41:47 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Jul 27 14:23:23 2009 Subject: [Haskell-cafe] 'cabal install lhs2tex' fails for me on os x -- help please In-Reply-To: References: 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/20090727/587ca8f2/PGP.bin From conal at conal.net Mon Jul 27 14:44:08 2009 From: conal at conal.net (Conal Elliott) Date: Mon Jul 27 14:25:42 2009 Subject: [Haskell-cafe] 'cabal install lhs2tex' fails for me on os x -- help please In-Reply-To: <20090727182242.GF30193@whirlpool.galois.com> References: <20090727182242.GF30193@whirlpool.galois.com> Message-ID: > > Via cabal: > > --constraint='base<4' > > or replace Control.Exception with Control.OldException > > or add 'base < 4' to the depends in the .cabal file. > Thanks, Don. Trying your first suggestion, I get the same result for the first and third method, and a ghc panic on cat_evals for the second method. All happening in ghc-6.10.3 installed via the Haskell Platform last week on OS X. bash-3.2$ cabal install lhs2tex --constraint='base<4' Resolving dependencies... [1 of 1] Compiling Main ( /tmp/lhs2tex-1.1424460/lhs2tex-1.14/Setup.hs, /tmp/lhs2tex-1.1424460/lhs2tex-1.14/dist/setup/Main.o ) Linking /tmp/lhs2tex-1.1424460/lhs2tex-1.14/dist/setup/setup ... Configuring lhs2tex-1.14... cabal: Error: some packages failed to install: lhs2tex-1.14 failed during the configure step. The exception was: exit: ExitFailure 11 Still fishy about compiling Main first. Now I'll edit add the '< 4' constraint on base, giving the same result: bash-3.2$ dirs ~/cabal bash-3.2$ cabal unpack lhs2tex Unpacking lhs2tex-1.14... bash-3.2$ cd lhs2tex-1.14 [lhs2tex.cabal edit happens here] bash-3.2$ cabal install Resolving dependencies... [1 of 1] Compiling Main ( Setup.hs, dist/setup/Main.o ) Linking ./dist/setup/setup ... Configuring lhs2tex-1.14... cabal: Error: some packages failed to install: lhs2tex-1.14 failed during the configure step. The exception was: exit: ExitFailure 11 Note that on linux, the package compiles without changing the base constraint. I don't know how. Finally, use explicit ./configure & make: bash-3.2$ ./configure bash: ./configure: Permission denied bash-3.2$ sh configure checking for ghc... /usr/bin/ghc checking for hugs... no checking for a BSD-compatible install... /usr/bin/install -c checking whether ln -s works... yes checking for mv... /bin/mv checking for cp... /bin/cp checking for rm... /bin/rm checking for mkdir... /bin/mkdir checking for touch... /usr/bin/touch checking for diff... /usr/bin/diff checking for grep... /usr/bin/grep checking for sed... /usr/bin/sed checking for sort... /usr/bin/sort checking for uniq... /usr/bin/uniq checking for find... /usr/bin/find checking for latex... /usr/local/texlive/2008/bin/universal-darwin/latex checking for pdflatex... /usr/local/texlive/2008/bin/universal-darwin/pdflatex checking for xdvi... /usr/local/texlive/2008/bin/universal-darwin/xdvi checking for gv... no checking for dvips... /usr/local/texlive/2008/bin/universal-darwin/dvips checking for kpsewhich... /usr/local/texlive/2008/bin/universal-darwin/kpsewhich checking for a texmf tree... /usr/local/texlive/2008/../texmf-local checking for texmf.cnf... yes checking for the polytable package... /usr/local/texlive/2008/texmf-dist/tex/latex/polytable/polytable.sty checking for version of polytable... 0.8.2 checking whether polytable needs to be installed... no checking for mktexlsr... /usr/local/texlive/2008/bin/universal-darwin/mktexlsr configure: creating ./config.status config.status: creating config.mk config.status: creating Version.lhs config.status: creating lhs2TeX.1 config.status: creating doc/InteractiveHugs.lhs config.status: creating doc/InteractivePre.lhs Configuration succesfully completed. Say make to compile and build documentation make bin to compile the binary only make install to (compile and) install [edit happens here, changing Control.Exception to Control.OldException.] bash-3.2$ ./configure bash: ./configure: Permission denied bash-3.2$ sh configure checking for ghc... /usr/bin/ghc checking for hugs... no checking for a BSD-compatible install... /usr/bin/install -c checking whether ln -s works... yes checking for mv... /bin/mv checking for cp... /bin/cp checking for rm... /bin/rm checking for mkdir... /bin/mkdir checking for touch... /usr/bin/touch checking for diff... /usr/bin/diff checking for grep... /usr/bin/grep checking for sed... /usr/bin/sed checking for sort... /usr/bin/sort checking for uniq... /usr/bin/uniq checking for find... /usr/bin/find checking for latex... /usr/local/texlive/2008/bin/universal-darwin/latex checking for pdflatex... /usr/local/texlive/2008/bin/universal-darwin/pdflatex checking for xdvi... /usr/local/texlive/2008/bin/universal-darwin/xdvi checking for gv... no checking for dvips... /usr/local/texlive/2008/bin/universal-darwin/dvips checking for kpsewhich... /usr/local/texlive/2008/bin/universal-darwin/kpsewhich checking for a texmf tree... /usr/local/texlive/2008/../texmf-local checking for texmf.cnf... yes checking for the polytable package... /usr/local/texlive/2008/texmf-dist/tex/latex/polytable/polytable.sty checking for version of polytable... 0.8.2 checking whether polytable needs to be installed... no checking for mktexlsr... /usr/local/texlive/2008/bin/universal-darwin/mktexlsr configure: creating ./config.status config.status: creating config.mk config.status: creating Version.lhs config.status: creating lhs2TeX.1 config.status: creating doc/InteractiveHugs.lhs config.status: creating doc/InteractivePre.lhs Configuration succesfully completed. Say make to compile and build documentation make bin to compile the binary only make install to (compile and) install bash-3.2$ make [...] /usr/bin/grep "^%include " Main.lhs | /usr/bin/sed -e 's,^%include ,Main.tex : ,' | /usr/bin/sort | /usr/bin/uniq > Main.ld; \ /bin/cp Main.ld Main.ldd; \ /usr/bin/sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$//' -e '/^$/ d' -e 's/$/ :/' < Main.ldd >> Main.ld; \ /bin/rm -f Main.ldd /usr/bin/ghc -O --make -o lhs2TeX Main.lhs [ 1 of 19] Compiling Document ( Document.lhs, Document.o ) [ 2 of 19] Compiling Auxiliaries ( Auxiliaries.lhs, Auxiliaries.o ) [ 3 of 19] Compiling StateT ( StateT.lhs, StateT.o ) [ 4 of 19] Compiling Verbatim ( Verbatim.lhs, Verbatim.o ) [ 5 of 19] Compiling Value ( Value.lhs, Value.o ) [ 6 of 19] Compiling FiniteMap ( FiniteMap.lhs, FiniteMap.o ) [ 7 of 19] Compiling TeXCommands ( TeXCommands.lhs, TeXCommands.o ) [ 8 of 19] Compiling HsLexer ( HsLexer.lhs, HsLexer.o ) [ 9 of 19] Compiling TeXParser ( TeXParser.lhs, TeXParser.o ) [10 of 19] Compiling Parser ( Parser.lhs, Parser.o ) [11 of 19] Compiling Directives ( Directives.lhs, Directives.o ) [12 of 19] Compiling Typewriter ( Typewriter.lhs, Typewriter.o ) [13 of 19] Compiling MathCommon ( MathCommon.lhs, MathCommon.o ) [14 of 19] Compiling MathPoly ( MathPoly.lhs, MathPoly.o ) [15 of 19] Compiling NewCode ( NewCode.lhs, NewCode.o ) [16 of 19] Compiling Math ( Math.lhs, Math.o ) [17 of 19] Compiling FileNameUtils ( FileNameUtils.lhs, FileNameUtils.o ) [18 of 19] Compiling Version ( Version.lhs, Version.o ) [19 of 19] Compiling Main ( Main.lhs, Main.o ) ghc: panic! (the 'impossible' happened) (GHC version 6.10.3 for i386-apple-darwin): cat_evals base:GHC.Arr.Array{d rau} [ww{v aFwM} [lid], ww1{v aFwN} [lid], ww2{v aFwO} [lid]] [!, !, _, _] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug make: *** [lhs2TeX] Error 1 bash-3.2$ Hm! Gremlins. - Conal On Mon, Jul 27, 2009 at 11:22 AM, Don Stewart wrote: > conal: > > Fails during configuration: > > > > bash-3.2$ cabal install lhs2tex > > Resolving dependencies... > > [1 of 1] Compiling Main ( > /tmp/lhs2tex-1.1423397/lhs2tex-1.14/ > > Setup.hs, /tmp/lhs2tex-1.1423397/lhs2tex-1.14/dist/setup/Main.o ) > > Linking /tmp/lhs2tex-1.1423397/lhs2tex-1.14/dist/setup/setup ... > > Configuring lhs2tex-1.14... > > cabal: Error: some packages failed to install: > > lhs2tex-1.14 failed during the configure step. The exception was: > > exit: ExitFailure 11 > > > > Note that the the first module to be compiled is Main. On my linux > machine, > > Main is the *last* of several modules to be compiled. > > > > Here's my failure log: > http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3096# > > a3096 . > > > > If instead I use ./configure and make, i get errors due to use of the old > > Exception API: > > > > ... > > [17 of 19] Compiling FileNameUtils ( FileNameUtils.lhs, > FileNameUtils.o > > ) > > > > FileNameUtils.lhs:81:35: > > Ambiguous type variable `b' in the constraint: > > `GHC.Exception.Exception b' > > arising from a use of `catch' at > FileNameUtils.lhs:(81,35)-(89,60) > > Probable fix: add a type signature that fixes these type > variable(s) > > ... > > > > Suggestions greatly appreciated! > > Via cabal: > > --constraint='base<4' > > or replace Control.Exception with Control.OldException > > or add 'base < 4' to the depends in the .cabal file. > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090727/7c8f281b/attachment-0001.html From conal at conal.net Mon Jul 27 14:54:56 2009 From: conal at conal.net (Conal Elliott) Date: Mon Jul 27 14:36:29 2009 Subject: [Haskell-cafe] 'cabal install lhs2tex' fails for me on os x -- help please In-Reply-To: References: <20090727182242.GF30193@whirlpool.galois.com> Message-ID: Yo ho! I just installed ghc-6.10.4 over my 6.10.3. Now 'cabal install lhs2tex' works. Phew! On Mon, Jul 27, 2009 at 11:44 AM, Conal Elliott wrote: > Via cabal: >> >> --constraint='base<4' >> >> or replace Control.Exception with Control.OldException >> >> or add 'base < 4' to the depends in the .cabal file. >> > > Thanks, Don. > > Trying your first suggestion, I get the same result for the first and third > method, and a ghc panic on cat_evals for the second method. All happening > in ghc-6.10.3 installed via the Haskell Platform last week on OS X. > > bash-3.2$ cabal install lhs2tex --constraint='base<4' > Resolving dependencies... > [1 of 1] Compiling Main ( > /tmp/lhs2tex-1.1424460/lhs2tex-1.14/Setup.hs, > /tmp/lhs2tex-1.1424460/lhs2tex-1.14/dist/setup/Main.o ) > Linking /tmp/lhs2tex-1.1424460/lhs2tex-1.14/dist/setup/setup ... > Configuring lhs2tex-1.14... > cabal: Error: some packages failed to install: > lhs2tex-1.14 failed during the configure step. The exception was: > exit: ExitFailure 11 > > Still fishy about compiling Main first. > > Now I'll edit add the '< 4' constraint on base, giving the same result: > > bash-3.2$ dirs > ~/cabal > bash-3.2$ cabal unpack lhs2tex > Unpacking lhs2tex-1.14... > bash-3.2$ cd lhs2tex-1.14 > > [lhs2tex.cabal edit happens here] > > bash-3.2$ cabal install > Resolving dependencies... > [1 of 1] Compiling Main ( Setup.hs, dist/setup/Main.o ) > Linking ./dist/setup/setup ... > Configuring lhs2tex-1.14... > cabal: Error: some packages failed to install: > lhs2tex-1.14 failed during the configure step. The exception was: > exit: ExitFailure 11 > > Note that on linux, the package compiles without changing the base > constraint. I don't know how. > > Finally, use explicit ./configure & make: > > bash-3.2$ ./configure > bash: ./configure: Permission denied > bash-3.2$ sh configure > checking for ghc... /usr/bin/ghc > checking for hugs... no > checking for a BSD-compatible install... /usr/bin/install -c > checking whether ln -s works... yes > checking for mv... /bin/mv > checking for cp... /bin/cp > checking for rm... /bin/rm > checking for mkdir... /bin/mkdir > checking for touch... /usr/bin/touch > checking for diff... /usr/bin/diff > checking for grep... /usr/bin/grep > checking for sed... /usr/bin/sed > checking for sort... /usr/bin/sort > checking for uniq... /usr/bin/uniq > checking for find... /usr/bin/find > checking for latex... > /usr/local/texlive/2008/bin/universal-darwin/latex > checking for pdflatex... > /usr/local/texlive/2008/bin/universal-darwin/pdflatex > checking for xdvi... /usr/local/texlive/2008/bin/universal-darwin/xdvi > checking for gv... no > checking for dvips... > /usr/local/texlive/2008/bin/universal-darwin/dvips > checking for kpsewhich... > /usr/local/texlive/2008/bin/universal-darwin/kpsewhich > checking for a texmf tree... /usr/local/texlive/2008/../texmf-local > checking for texmf.cnf... yes > checking for the polytable package... > /usr/local/texlive/2008/texmf-dist/tex/latex/polytable/polytable.sty > checking for version of polytable... 0.8.2 > checking whether polytable needs to be installed... no > checking for mktexlsr... > /usr/local/texlive/2008/bin/universal-darwin/mktexlsr > configure: creating ./config.status > config.status: creating config.mk > config.status: creating Version.lhs > config.status: creating lhs2TeX.1 > config.status: creating doc/InteractiveHugs.lhs > config.status: creating doc/InteractivePre.lhs > Configuration succesfully completed. > Say > make to compile and build documentation > make bin to compile the binary only > make install to (compile and) install > > [edit happens here, changing Control.Exception to Control.OldException.] > > bash-3.2$ ./configure > bash: ./configure: Permission denied > bash-3.2$ sh configure > checking for ghc... /usr/bin/ghc > checking for hugs... no > checking for a BSD-compatible install... /usr/bin/install -c > checking whether ln -s works... yes > checking for mv... /bin/mv > checking for cp... /bin/cp > checking for rm... /bin/rm > checking for mkdir... /bin/mkdir > checking for touch... /usr/bin/touch > checking for diff... /usr/bin/diff > checking for grep... /usr/bin/grep > checking for sed... /usr/bin/sed > checking for sort... /usr/bin/sort > checking for uniq... /usr/bin/uniq > checking for find... /usr/bin/find > checking for latex... > /usr/local/texlive/2008/bin/universal-darwin/latex > checking for pdflatex... > /usr/local/texlive/2008/bin/universal-darwin/pdflatex > checking for xdvi... /usr/local/texlive/2008/bin/universal-darwin/xdvi > checking for gv... no > checking for dvips... > /usr/local/texlive/2008/bin/universal-darwin/dvips > checking for kpsewhich... > /usr/local/texlive/2008/bin/universal-darwin/kpsewhich > checking for a texmf tree... /usr/local/texlive/2008/../texmf-local > checking for texmf.cnf... yes > checking for the polytable package... > /usr/local/texlive/2008/texmf-dist/tex/latex/polytable/polytable.sty > checking for version of polytable... 0.8.2 > checking whether polytable needs to be installed... no > checking for mktexlsr... > /usr/local/texlive/2008/bin/universal-darwin/mktexlsr > configure: creating ./config.status > config.status: creating config.mk > config.status: creating Version.lhs > config.status: creating lhs2TeX.1 > config.status: creating doc/InteractiveHugs.lhs > config.status: creating doc/InteractivePre.lhs > Configuration succesfully completed. > Say > make to compile and build documentation > make bin to compile the binary only > make install to (compile and) install > bash-3.2$ make > [...] > /usr/bin/grep "^%include " Main.lhs | /usr/bin/sed -e 's,^%include > ,Main.tex : ,' | /usr/bin/sort | /usr/bin/uniq > Main.ld; \ > /bin/cp Main.ld Main.ldd; \ > /usr/bin/sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$//' -e > '/^$/ d' -e 's/$/ :/' < Main.ldd >> Main.ld; \ > /bin/rm -f Main.ldd > /usr/bin/ghc -O --make -o lhs2TeX Main.lhs > [ 1 of 19] Compiling Document ( Document.lhs, Document.o ) > [ 2 of 19] Compiling Auxiliaries ( Auxiliaries.lhs, Auxiliaries.o > ) > [ 3 of 19] Compiling StateT ( StateT.lhs, StateT.o ) > [ 4 of 19] Compiling Verbatim ( Verbatim.lhs, Verbatim.o ) > [ 5 of 19] Compiling Value ( Value.lhs, Value.o ) > [ 6 of 19] Compiling FiniteMap ( FiniteMap.lhs, FiniteMap.o ) > [ 7 of 19] Compiling TeXCommands ( TeXCommands.lhs, TeXCommands.o > ) > [ 8 of 19] Compiling HsLexer ( HsLexer.lhs, HsLexer.o ) > [ 9 of 19] Compiling TeXParser ( TeXParser.lhs, TeXParser.o ) > [10 of 19] Compiling Parser ( Parser.lhs, Parser.o ) > [11 of 19] Compiling Directives ( Directives.lhs, Directives.o ) > [12 of 19] Compiling Typewriter ( Typewriter.lhs, Typewriter.o ) > [13 of 19] Compiling MathCommon ( MathCommon.lhs, MathCommon.o ) > [14 of 19] Compiling MathPoly ( MathPoly.lhs, MathPoly.o ) > [15 of 19] Compiling NewCode ( NewCode.lhs, NewCode.o ) > [16 of 19] Compiling Math ( Math.lhs, Math.o ) > [17 of 19] Compiling FileNameUtils ( FileNameUtils.lhs, > FileNameUtils.o ) > [18 of 19] Compiling Version ( Version.lhs, Version.o ) > [19 of 19] Compiling Main ( Main.lhs, Main.o ) > ghc: panic! (the 'impossible' happened) > (GHC version 6.10.3 for i386-apple-darwin): > cat_evals > base:GHC.Arr.Array{d rau} > [ww{v aFwM} [lid], ww1{v aFwN} [lid], ww2{v aFwO} [lid]] > [!, !, _, _] > > Please report this as a GHC bug: > http://www.haskell.org/ghc/reportabug > > make: *** [lhs2TeX] Error 1 > bash-3.2$ > > Hm! Gremlins. > > - Conal > > > On Mon, Jul 27, 2009 at 11:22 AM, Don Stewart wrote: > >> conal: >> > Fails during configuration: >> > >> > bash-3.2$ cabal install lhs2tex >> > Resolving dependencies... >> > [1 of 1] Compiling Main ( >> /tmp/lhs2tex-1.1423397/lhs2tex-1.14/ >> > Setup.hs, /tmp/lhs2tex-1.1423397/lhs2tex-1.14/dist/setup/Main.o ) >> > Linking /tmp/lhs2tex-1.1423397/lhs2tex-1.14/dist/setup/setup ... >> > Configuring lhs2tex-1.14... >> > cabal: Error: some packages failed to install: >> > lhs2tex-1.14 failed during the configure step. The exception was: >> > exit: ExitFailure 11 >> > >> > Note that the the first module to be compiled is Main. On my linux >> machine, >> > Main is the *last* of several modules to be compiled. >> > >> > Here's my failure log: >> http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3096# >> > a3096 . >> > >> > If instead I use ./configure and make, i get errors due to use of the >> old >> > Exception API: >> > >> > ... >> > [17 of 19] Compiling FileNameUtils ( FileNameUtils.lhs, >> FileNameUtils.o >> > ) >> > >> > FileNameUtils.lhs:81:35: >> > Ambiguous type variable `b' in the constraint: >> > `GHC.Exception.Exception b' >> > arising from a use of `catch' at >> FileNameUtils.lhs:(81,35)-(89,60) >> > Probable fix: add a type signature that fixes these type >> variable(s) >> > ... >> > >> > Suggestions greatly appreciated! >> >> Via cabal: >> >> --constraint='base<4' >> >> or replace Control.Exception with Control.OldException >> >> or add 'base < 4' to the depends in the .cabal file. >> >> -- Don >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090727/48d55c04/attachment.html From rendel at cs.au.dk Mon Jul 27 16:29:50 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Mon Jul 27 16:11:28 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances In-Reply-To: <4A6A1DCD.8090503@freegeek.org> References: <20090717191433.GA19514@pudlak.name> <4A6907E3.6070208@freegeek.org> <49a77b7a0907231914k16b2634cs13514097ce841b3d@mail.gmail.com> <4A6A1DCD.8090503@freegeek.org> Message-ID: <4A6E0E3E.8080907@cs.au.dk> wren ng thornton wrote: > [1] In System F the capital-lambda binder is used for the term-level > abstraction of passing type representations. So for example we have, > > id :: forall a. a -> a > id = /\a. \(x::a). x > > Thus, the forall keyword is serving as the type-level abstraction. > Perhaps this is suboptimal syntax, but it is the standard. We could, of > course, have both a term-level /\ and a type-level /\ where the latter > is the type of the former (since the namespaces are separate) though > that's also dubious. Capital-pi is the canonical type-level abstraction, > though that evokes the idea of dependent types which are much more complex. What do you mean by "type-level abstraction" here? In a language with type functions and polymorphism, we need three different lambda binders: (1) abstraction over terms in terms (to construct functions) (2) abstraction over types in terms (to construct polymorphic values) (3) abstraction over types in types (to construct type functions) I think only (2) should be written as upper-case lambdas, while (1) and (3) should both be written as lower-case lambdas. Since (1) and (3) belong to different syntactic categories, they can not be confused, and we can reuse the lower-case lambda at the type-level. Furthermore, we need three function types / kinds to describe the three lambdas one level higher: (4) the type of functions (5) the type of polymorphic values (6) the kind of type functions In ghc, we already have "forall" for (5), and arrows for (4) and (6). I would say that (3) is the "type-level abstraction", not (5). Tillmann From haskell at colquitt.org Mon Jul 27 16:41:37 2009 From: haskell at colquitt.org (John Dorsey) Date: Mon Jul 27 16:22:51 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <89ca3d1f0907271010r359baf22q6a1e66a4d91fd8a2@mail.gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <89ca3d1f0907271010r359baf22q6a1e66a4d91fd8a2@mail.gmail.com> Message-ID: <20090727204137.GE14826@colquitt.org> Cale et al, I have a concern about the implementation of the proposed TypeDirectedNameResolution. (I'm not familiar with the internals of any of the compilers, so it could be that my concern isn't well founded.) I'm assuming that name resolution is currently independent of type inference, and will happen before type inference. With the proposal this is no longer true, and in general some partial type inference will have to happen before conflicting unqualified names are resolved. My worry is that the proposal will require a compliant compiler to interweave name resolution and type inference iteratively. Give the Haskell source code: import X import Y import Z a = 1 + (1 :: Integer) b = x a c = y b d = z c . . . Assume X, Y, and Z all export x, y, and z. The compiler might do something like this: (do stuff) Infer type of 'a' Resolve unqualified use of 'x' in "x a" Infer type of 'b' from "b = x a" Resolve unqualified use of 'y' in "y b" Infer type of 'c' from "c = y b" Resolve unqualified use of 'z' in "z c" etc. If ambiguous unqualified names are used mutually recursively it may be that there's only one reasonable combination of name resolutions, but is this decidable? To my untrained eye it looks complicated and invasive, even without the mutually recursive case. Can anyone shed light on whether this would be a problem for, say, GHC? Thanks, John From kyagrd at gmail.com Mon Jul 27 17:12:34 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Mon Jul 27 16:54:19 2009 Subject: [Haskell-cafe] Testing nested implication properties with QuickCheck? Message-ID: How should I you use QuickCheck for testing a property that is a nested implecation such as (A ==> B) ==> C ? The problem is (==>) in QuickCheck is that its type is Testable prop => Bool -> prop -> Property rather than Testable prop => prop -> prop -> Property. So, A ==> (B ==> C) would work but (A ==> B) ==> C won't work when A, B, C are boolean expressions. Is there some trick to handle the latter? Thanks, -- Ahn, Ki Yung From kyagrd at gmail.com Mon Jul 27 17:12:55 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Mon Jul 27 16:56:22 2009 Subject: [Haskell-cafe] Testing nested implication properties with QuickCheck? Message-ID: How should I use QuickCheck for testing a property that is a nested implecation such as (A ==> B) ==> C ? The problem is (==>) in QuickCheck is that its type is Testable prop => Bool -> prop -> Property rather than Testable prop => prop -> prop -> Property. So, A ==> (B ==> C) would work but (A ==> B) ==> C won't work when A, B, C are boolean expressions. Is there some trick to handle the latter? Thanks, -- Ahn, Ki Yung From lrpalmer at gmail.com Mon Jul 27 17:17:54 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jul 27 16:59:07 2009 Subject: [Haskell-cafe] Testing nested implication properties with QuickCheck? In-Reply-To: References: Message-ID: <7ca3f0160907271417j32c84b0bg657980db5fcbc7b0@mail.gmail.com> 2009/7/27 Ahn, Ki Yung : > How should I you use QuickCheck for testing a property that is a nested > implecation such as (A ==> B) ==> C ? You could use the classical equivalence (A ==> B) <=> (~A \/ B). I'm not sure you would get very much out of the implication strategy for the nested one, anyway. > > The problem is (==>) in QuickCheck is that its type is Testable prop => > Bool -> prop -> Property ?rather than Testable prop => prop -> prop -> > Property. ?So, A ==> (B ==> C) would work but (A ==> B) ==> C won't work > when A, B, C are boolean expressions. ?Is there some trick to handle the > latter? > > Thanks, > > -- > ?Ahn, Ki Yung > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From goofyheadedpunk at gmail.com Mon Jul 27 19:06:32 2009 From: goofyheadedpunk at gmail.com (Brian Troutwine) Date: Mon Jul 27 18:47:44 2009 Subject: [Haskell-cafe] A Question of Restriction In-Reply-To: <35B36AF3-0AE5-4DFD-A263-13FDE330E94C@cs.nott.ac.uk> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> <35B36AF3-0AE5-4DFD-A263-13FDE330E94C@cs.nott.ac.uk> Message-ID: <971980cc0907271606r676f3eberb38147e2f91fde7f@mail.gmail.com> Hello Wouter. I've had a go at the paper linked and perused other references found with Google. Unfortunately, such sophisticated use of the type system is pretty far out of my normal problem domain and I can't see how to apply the techniques presented to my motivating example. Would you be so kind as to elaborate? Thank you, Brian On Mon, Jul 27, 2009 at 2:37 AM, Wouter Swierstra wrote: > Hi Brian, > > If I understand you correctly, you've run into the "Expression Problem". > Phil Wadler posed the problem in a widely-cited e-mail, formulating it much > more clearly than I ever could: > > ?http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt > > There are lots of ways to tackle this problem in Haskell - just google > "Expression Problem Haskell". My (completely biased) personal favourite is: > > ?http://www.cse.chalmers.se/~wouter/Publications/DataTypesALaCarte.pdf > > Hope this helps, > > ?Wouter > > From ok at cs.otago.ac.nz Mon Jul 27 19:32:28 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon Jul 27 19:14:20 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <20090727204137.GE14826@colquitt.org> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <89ca3d1f0907271010r359baf22q6a1e66a4d91fd8a2@mail.gmail.com> <20090727204137.GE14826@colquitt.org> Message-ID: <4854F267-62DA-4721-AC0C-E43BD96ABD20@cs.otago.ac.nz> I would find a third meaning for dot in Haskell just a little bit too many. Especially with hierarchical modules, Haskell encourages writing small modules, or at any rate no larger than they have to be. (SML goes further, of course.) So if we're doing what the software engineering books say (small highly cohesive loosely coupled modules) we should have that much of a name overloading problem in the first place, no? The alias facility for imports, and the practice that has sprung up of using single-letter abbreviations for modules, make the existing practice fairly light-weight. I'm not sure, therefore, that we have a problem that OUGHT to be "solved", still less by a method that I find less readable. It seems to me that there's an approach that could be swiped from ML. One of the declaration forms in ML is local in end Just as "where" lets you share a bunch of definitions across a bunch of clauses, so "local" makes everything in the visible inside the but not outside; from the outside only the can be seen. Waving my hands a bit, this is roughly equivalent to (x1,...,xn) = let in let in (x1,...,xn) What has this to do with imports? It means that you can introduce local renamings that can be _shared_ by a group of declarations, while elsewhere in the module, another group of declarations can share different resolutions for the same names. The advantages of that over type directed resolution include - what's happening is visible to the programmer - it's basically ordinary declarations, not some new constraint satisfaction process that has to be interwoven somehow with type inference - that makes life easier for other tools as well - it doesn't overload dot (or my small head) From dvde at gmx.net Mon Jul 27 19:37:29 2009 From: dvde at gmx.net (Daniel van den Eijkel) Date: Mon Jul 27 19:18:47 2009 Subject: [Haskell-cafe] ghci identifier listing question Message-ID: <4A6E3A39.3080309@gmx.net> Hi, in GHCi, after pressing the tab-key, all defined identifiers are listed. If an identifier was redefined, all old and shadowed versions are listed, too. Is it possible, to reach the (shadowed) values in any way? Another question: Is it possible to show only those identifiers that are defined during the interactive session? I only can list all identifiers which start with a given prefix, but I would like to know if GHCi can show me all identifiers defined in a given module or in the current session (by pressing Tab or alike). Best regards, Daniel From ok at cs.otago.ac.nz Mon Jul 27 21:35:09 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon Jul 27 21:16:30 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago In-Reply-To: References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> Message-ID: <280B5FB0-1C98-48FB-AF44-A28C32C02B96@cs.otago.ac.nz> On Jul 27, 2009, at 6:30 PM, Benjamin L.Russell wrote: > Incidentally, just for the record, in response to my forwarding your > claim, Alan Kay, the inventor of Smalltalk, just refuted your > refutation [1] (see > http://lists.squeakfoundation.org/pipermail/beginners/2009-July/006331.html) > ; > _viz._: If you read carefully what he wrote there, it doesn't actually contradict what I said. (For what it's worth, I _have_ read a good deal of Alan Kay's writings.) Molecular biology may very well have been an influence on >Alan Kay<, but there are no traces of it in >Smalltalk<. The concepts of >Smalltalk< have their roots in Lisp, including the original version using nil as false, and the meta-circular interpreter. Sketchpad and Simula also have no trace of biology in them. As for the claim that Smalltalk had its roots in Lisp, this is not my opinion. It's straight from the horse's mouth. Visit http://www.smalltalk.org/smalltalk/TheEarlyHistoryOfSmalltalk_IV.html whose title is "The first real Smalltalk", and you will read this paragraph: "I had orignally made the boast because McCarthy's self-describing LISP interpreter was written in itself. It was about "a page", and as far as power goes, LISP was the whole nine-yards for functional languages. I was quite sure I could do the same for object-oriented languages plus be able to do a resonable syntax for the code a loa some of the FLEX machine techiques." [Errors in the page.] So clearly Alan Kay _was_ influenced by Lisp, and the initial Smalltalk-72 implementation _was_ influenced by the Lisp meta-circular interpreter. While we're on that page, here are the six core principles: 1. Everything is an object [Where's the biology in that? Rocks are objects.] 2. Objects communicate by sending and receiving messages (in terms of objects) [Where's the biology in that? Sounds more like the telephone system. And when organisms send messages to other organisms, those messages are not themselves organisms, although that might make a neat gimmick for a science fiction story.] 3. Objects have their own memory (in terms of objects) [Many organisms have memory. But their memories are not themselves organisms. Again that might make a nice science fiction gimmick, and Brin's hydrogen breathers in the Uplift series come close. Not in THIS biology though.] 4. Every object is an instance of a class (which must be an object) [Maybe here's the biology? But no, Simula 67 had single-inheritance classes, with never a trace of biology. There's certainly no biology-talk in the Simula Common Base manual that I can find. Again, in THIS biology, a taxon is not itself an organism, so if anything, Smalltalk is contradicting biology.] 5. The class holds the shared behavior for its instances (in the form of objects in a pogram list) [Errors in the page. Where's the biology here? Organisms behave, but their behaviour isn't made of organisms held in another organism. Class as site of shared behaviour is straight Simula (and of course other sources).] 6. To eval a program list, control is passed to the first object and the remainder is treated as its message [Does that look like biology to you?] A PDF of the whole thing is http://www.smalltalk.org/downloads/papers/SmalltalkHistoryHOPL.pdf But how important is that paper anyway? (1) It's by Alan Kay. (2) It's his official history of Smalltalk. (3) It actually says on the second page "I will try to show where most of the influences come from." It's true that the abstract speaks of "a more biological scheme of protected universal cells interacting only through messages that could mimic any desired behavior", but that's basically _it_ for biology, if we are to believe Kay, and even then, "its semantics are a bit like having thousands of and thousands of comptuers all hooked together by a very fast network" and "Philosophically, Smalltalk's objects have much in common with the monads of Leibnitz" (bringing us neatly back to Haskell (:-)). We read "The biggest hit for me while at SAIL in late '69 was to _really understand_ Lisp". By the way, Haskell programmers should really appreciate the anecdote on page 13 about programming odds_evens x = odds x ++ evens x where odds [] = [] odds (x:xs) = x : evens xs evens (_:x:xs) = x : evens xs evens _ = []. It took him about 5 seconds to do about that way, while it took Allen Newell "30 minutes to not quite solve". At any rate, the paper which is supposed to trace "most of the influences" doesn't link even *one* idea in Smalltalk to biology. The influences are other programming languages, notably Lisp, Simula, and the ever-famous Sketchpad system, philosophy, programming, computer networks, ... As for the "biological" nature of message passing, the paper says (p50) "An extemporaneous talk by R. S. Barton at Alta ski lodge (1968) about computers as communication devices and how everything one does can easily be portrayed as sending messages to and from, was the real genesis of the current version of SMALLTALK." Biology? I repeat, this is not MY interpretation or history. My claim was solidly based on what Alan Kay himself wrote. From peteg42 at gmail.com Mon Jul 27 22:25:58 2009 From: peteg42 at gmail.com (Peter Gammie) Date: Mon Jul 27 22:07:17 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago In-Reply-To: <280B5FB0-1C98-48FB-AF44-A28C32C02B96@cs.otago.ac.nz> References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> <280B5FB0-1C98-48FB-AF44-A28C32C02B96@cs.otago.ac.nz> Message-ID: <97EDA097-2324-4BD5-B21E-9B8140B11027@gmail.com> On 28/07/2009, at 11:35 AM, Richard O'Keefe wrote: > It's true that the abstract speaks of "a more biological > scheme of protected universal cells interacting only through > messages that could mimic any desired behavior", but that's > basically _it_ for biology, if we are to believe Kay, and > even then, "its semantics are a bit like having thousands of > and thousands of comptuers all hooked together by a very fast > network" and "Philosophically, Smalltalk's objects have much > in common with the monads of Leibnitz" (bringing us neatly > back to Haskell (:-)). But Richard (or am I arguing with Kay?) - monads don't interact. http://en.wikipedia.org/wiki/Monadology I'd take that to be their defining characteristic - Leibniz is trying to overcome Cartesian mind/body dualism here. Perhaps Smalltalk objects are regulated by pre-established harmonies... and have no need to talk to each other. Or perhaps that is the part that lies outside Kay's identification, in which case one might say the ontologies of monads and Smalltalk have superficial similarities but the deeper structure diverges significantly. (I think my point is well-defended by the above wikipedia article - the OO insights are thin on the ground, and are at least quite tangled.) How are you going to relate Leibniz's monads and Haskell's? I can't find my way, neatly or otherwise. :-P Ah, I see, Haskell has an interface to the best of all possible worlds... :-) cheers peter -- http://peteg.org/ From jvranish at gmail.com Mon Jul 27 22:28:52 2009 From: jvranish at gmail.com (Job Vranish) Date: Mon Jul 27 22:10:05 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> References: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> Message-ID: I tried updating to ghc-6.10.4 and have exactly the same error. Also ghc doesn't seem to be able to find any of the haskell platform packages, even though it ghc-pkg finds them just fine. For example (trimmed for brevity): ghc-pkg list /usr/local/lib/ghc-6.10.4/./package.conf: Cabal-1.6.0.3, ... parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, ... ghci -v readModel.hs GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98, stage 2 booted by GHC version 6.8.2 Using package config file: /usr/local/lib/ghc-6.10.4/./package.conf ... readModel.hs:9:7: Could not find module `Text.Parsec.Language': locations searched: Text/Parsec/Language.hs Text/Parsec/Language.lhs Failed, modules loaded: none. ... ghc-pkg finds parsec, but ghci can't find it. And if I do a cabal -v3 update I get a: cabal: 3: openFile: does not exist (No such file or directory) Anybody figured it out? - Job Vranish On Fri, Jul 17, 2009 at 11:17 AM, Thomas Hartman wrote: > cabal -v3 update > > will give you a more verbose version of what is going wrong. > > cabal --help > > regrettably, cabal --help doesn't tell you this but there is always > the man page I suppose. > > 2009/7/16 Tony Hannan : > > Hello, > > > > I'm on Ubuntu 8.10. > > I installed ghc 6.10.4 (from binary package: > > ghc-6.10.4-i386-unknown-linux-n.tar.bz2). > > I installed haskell-platform-2009.2.0.1 (from source package: > > haskell-platform-2009.2.0.1.tar.gz). It contains cabal-install-0.6.2. > > > > Then when I run "cabal update", I get the following error: > > cabal: : openFile: does not exist (No such file or directory) > > > > Any ideas? > > > > Thanks, > > Tony > > > > _______________________________________________ > > Libraries mailing list > > Libraries@haskell.org > > http://www.haskell.org/mailman/listinfo/libraries > > > > > _______________________________________________ > 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/20090727/4e21cfbc/attachment.html From ok at cs.otago.ac.nz Mon Jul 27 22:59:11 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon Jul 27 22:40:28 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago In-Reply-To: <97EDA097-2324-4BD5-B21E-9B8140B11027@gmail.com> References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> <280B5FB0-1C98-48FB-AF44-A28C32C02B96@cs.otago.ac.nz> <97EDA097-2324-4BD5-B21E-9B8140B11027@gmail.com> Message-ID: <523A3AEA-06A4-4991-A247-C891826D7712@cs.otago.ac.nz> On Jul 28, 2009, at 2:25 PM, Peter Gammie wrote: > > But Richard (or am I arguing with Kay?) - monads don't interact. You're arguing with Alan Kay here: the reference to Leibniz was his. The key link here is (Wikipedia): " Leibniz allows just one type of element in the build of the universe" (sic.). In precisely the same way, Alan Kay allowed just one kind of 'thing' in his computational universe: object. Just as in the lambda calculus, everything is a function and in set theory everything is a set, so in Smalltalk _everything_ (including classes and the number 42 and anonymous functions) is an object. > > How are you going to relate Leibniz's monads and Haskell's? I can't > find my way, neatly or otherwise. :-P Verbally. From peteg42 at gmail.com Mon Jul 27 23:06:50 2009 From: peteg42 at gmail.com (Peter Gammie) Date: Mon Jul 27 22:48:08 2009 Subject: [Haskell-cafe] Re: [Haskell] Re: 20 years ago In-Reply-To: <523A3AEA-06A4-4991-A247-C891826D7712@cs.otago.ac.nz> References: <1147957281.20090713163506@gmail.com> <695085323.20090714115222@gmail.com> <02mo55dtdn6o6n6vfvtpq0eo674hros8fe@4ax.com> <871vojk0vh.fsf@malde.org> <66pq555jvrctktp7qpekqjo14iosfd30ap@4ax.com> <06BFB3BB-324C-4F05-89B8-60EC3EEED7D3@cs.otago.ac.nz> <280B5FB0-1C98-48FB-AF44-A28C32C02B96@cs.otago.ac.nz> <97EDA097-2324-4BD5-B21E-9B8140B11027@gmail.com> <523A3AEA-06A4-4991-A247-C891826D7712@cs.otago.ac.nz> Message-ID: On 28/07/2009, at 12:59 PM, Richard O'Keefe wrote: > On Jul 28, 2009, at 2:25 PM, Peter Gammie wrote: >> >> But Richard (or am I arguing with Kay?) - monads don't interact. > > You're arguing with Alan Kay here: the reference to Leibniz > was his. The key link here is (Wikipedia): " Leibniz allows > just one type of element in the build of the universe" (sic.). > In precisely the same way, Alan Kay allowed just one kind of > 'thing' in his computational universe: object. Just as in > the lambda calculus, everything is a function and in set theory > everything is a set, so in Smalltalk _everything_ (including > classes and the number 42 and anonymous functions) is an object. Yea gods, that's the thinnest use of monads ever. The concept that lead to idealism, away from mind-body dualism is reduced to ... monism. Awesome. http://en.wikipedia.org/wiki/Monism He could've cited just about any of the major philosophies for that - and I'm not going to talk about religions. >> How are you going to relate Leibniz's monads and Haskell's? I can't >> find my way, neatly or otherwise. :-P > > Verbally. Sure, but I was hoping you'd explain why Wadler uses the pineal gland allusions in his COMPREHENDING MONADS (capitals denoting paper title). That structure was *exactly* what Leibniz was doing his best to avoid in his monadology. I think Wadler was making a joke. cheers peter From westondan at imageworks.com Mon Jul 27 23:58:29 2009 From: westondan at imageworks.com (Dan Weston) Date: Mon Jul 27 23:39:48 2009 Subject: [Haskell-cafe] Importing Control.Arrow changes inferred type of (m >>= f) x in ghci Message-ID: <4A6E7765.4060903@imageworks.com> The following inferred type has a constraint that can be trivially satisfied, but isn't: Control.Monad> :t \ (m,f,x) -> (m >>= f) x \ (m,f,x) -> (m >>= f) x :: forall t a b. (Monad ((->) t)) => (t -> a, a -> t -> b, t) -> b -- In Control.Monad there is forall t. instance Monad ((->) t), -- so why is the vacuous Monad constraint still there? -- Nor can I remove it with a type annotation: Control.Monad> :t \ (m,f,x) -> (m >>= f) x :: forall t a b. (t -> a, a -> t -> b, t) -> b :1:13: Inferred type is less polymorphic than expected [snip] -- Then if I just import a module: Control.Monad> :m + Control.Arrow -- Now, the Monad ((-> t) constraint disappears: Control.Monad Control.Arrow> :t \ (m,f,x) -> (m >>= f) x \ (m,f,x) -> (m >>= f) x :: forall t a b. (t -> a, a -> t -> b, t) -> b -- Although it still will not accept an explicit type annotation: Control.Monad Control.Arrow> :t \ (m,f,x) -> (m >>= f) x :: forall t a b. (t -> a, a -> t -> b, t) -> b :1:13: Inferred type is less polymorphic than expected [snip] Is there some explicit kind annotation I can/should give to get the most general type? Dan From lrpalmer at gmail.com Tue Jul 28 00:04:20 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jul 27 23:45:32 2009 Subject: [Haskell-cafe] Importing Control.Arrow changes inferred type of (m >>= f) x in ghci In-Reply-To: <4A6E7765.4060903@imageworks.com> References: <4A6E7765.4060903@imageworks.com> Message-ID: <7ca3f0160907272104h8f54e65iffaaae994782b329@mail.gmail.com> On Mon, Jul 27, 2009 at 7:58 PM, Dan Weston wrote: > The following inferred type has a constraint that can be trivially > satisfied, but isn't: > > Control.Monad> :t \ (m,f,x) -> (m >>= f) x > \ (m,f,x) -> (m >>= f) x > ?:: forall t a b. (Monad ((->) t)) => (t -> a, a -> t -> b, t) -> b > > -- In Control.Monad there is forall t. instance Monad ((->) t), > -- so why is the vacuous Monad constraint still there? > -- Nor can I remove it with a type annotation: That instance is in the annoying module Control.Monad.Instances. > > Control.Monad> :t \ (m,f,x) -> (m >>= f) x :: forall t a b. (t -> a, a -> t > -> b, t) -> b > > :1:13: > ? ?Inferred type is less polymorphic than expected > ? ?[snip] > > -- Then if I just import a module: > Control.Monad> :m + Control.Arrow Presumably it is also here. > > -- Now, the Monad ((-> t) constraint disappears: > > Control.Monad Control.Arrow> :t \ (m,f,x) -> (m >>= f) x > \ (m,f,x) -> (m >>= f) x > ?:: forall t a b. (t -> a, a -> t -> b, t) -> b > > -- Although it still will not accept an explicit type annotation: > Control.Monad Control.Arrow> :t \ (m,f,x) -> (m >>= f) x :: forall t a b. (t > -> a, a -> t -> b, t) -> b This is just because :: binds tighter than lambda, I think: >>> :t (\(m,f,x) -> (m >>= f) x) :: forall t a b. (t -> a, a -> t -> b, t) -> b typechecks just fine. Luke From jeff at nokrev.com Tue Jul 28 02:54:04 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Tue Jul 28 02:35:38 2009 Subject: [Haskell-cafe] ghci identifier listing question In-Reply-To: <4A6E3A39.3080309@gmx.net> References: <4A6E3A39.3080309@gmx.net> Message-ID: <50c1e0910907272354l43baa618h59cae3829dd337f1@mail.gmail.com> On Mon, Jul 27, 2009 at 6:37 PM, Daniel van den Eijkel wrote: > Is it possible, to reach the (shadowed) values in any way? I'm not sure about this, but . . . > Another question: Is it possible to show only those identifiers that are > defined during the interactive session? I only can list all identifiers > which start with a given prefix, but I would like to know if GHCi can show > me all identifiers defined in a given module or in the current session (by > pressing Tab or alike). Yes, this will list the current bindings: > :show bindings Jeff Wheeler From ganesh.sittampalam at credit-suisse.com Tue Jul 28 03:14:50 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Tue Jul 28 02:56:18 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9F826@ELON17P32001A.csfb.cs-group.com> Cale Gibbard wrote: > There was a great related idea on #haskell the other day: Make > explicit qualification unnecessary whenever there is a *unique* > choice of module qualifications from those imported which would make > the expression typecheck. Ambiguities would still need to be > qualified, but I feel that this would eliminate 99% of all ugly > qualified names from code. It would be especially good in the case of > infix operators, which as far as I know, nobody actually enjoys > qualifying explicitly. > [...] > What do people think of this idea? Personally, it really annoys me > whenever I'm forced to give explicit module qualifications, and I > think this would really help. It would also subsume the > DisambiguateRecordFields extension rather handily. I think this idea would severely damage compositionality. One example of this is that it would make it substantially less likely that subexpressions could be abstracted into a separate declaration without giving a type signature to fix the type of the new declaration. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From wss at Cs.Nott.AC.UK Tue Jul 28 03:54:02 2009 From: wss at Cs.Nott.AC.UK (Wouter Swierstra) Date: Tue Jul 28 03:35:21 2009 Subject: [Haskell-cafe] A Question of Restriction In-Reply-To: <971980cc0907271606r676f3eberb38147e2f91fde7f@mail.gmail.com> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> <35B36AF3-0AE5-4DFD-A263-13FDE330E94C@cs.nott.ac.uk> <971980cc0907271606r676f3eberb38147e2f91fde7f@mail.gmail.com> Message-ID: <89AC6E7C-ADEE-4F5F-9F7A-643CBD99F434@Cs.Nott.AC.UK> > Would you be so kind as to elaborate? Sure. I'll just sketch how to deal the example in your e-mail. If you want to use recursive data types (like Lists or Trees), you'll need to use the Expr data type from the paper. Instead of defining: > data Foo = One | Two | Three | Four Define the following data types: > data One = One > data Two = Two > data Three = Three > data Four = Four You can define the following data type to assemble the pieces: > infixr 6 :+: > data (a :+: b) = Inl a | Inr b So, for example you could define: > type Odd = One :+: Three > type Even = Two :+: Four > type Foo = One :+: Two :+: Three :+: Four To define functions modularly, it's a good idea to use Haskell's clasess to do some of the boring work for you. Here's another example: > class ToNumber a where > toNumber :: a -> Int > > instance ToNumber One where > toNumber One = 1 (and similar instances for Two, Three, and Four) The key instance, however, is the following: > instance (ToNumber a, ToNumber b) => ToNumber (a :+: b) where > toNumber (Inl a) = toNumber a > toNumber (Inr b) = toNumber b This instance explains how to build instances for Odd, Even, and Foo from the instances for One, Two, Three, and Four. An example ghci sessions might look like: *Main> let x = Inl One :: Odd *Main> toNumber x 1 *Main> let y = Inr (Inr (Inl Three) :: Foo *Main> toNumber y 3 Of course, writing all these injections (Inr (Inr (Inl ...))) gets dull quite quickly. The (<) class in the paper explains how to avoid this. I hope this gives you a better idea of how you might go about solving your problem. All the best, Wouter From wren at freegeek.org Tue Jul 28 03:56:06 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Jul 28 03:37:34 2009 Subject: [Haskell-cafe] A Question of Restriction In-Reply-To: <971980cc0907271606r676f3eberb38147e2f91fde7f@mail.gmail.com> References: <971980cc0907262101i2439436fw620e86e7ec0c836e@mail.gmail.com> <35B36AF3-0AE5-4DFD-A263-13FDE330E94C@cs.nott.ac.uk> <971980cc0907271606r676f3eberb38147e2f91fde7f@mail.gmail.com> Message-ID: <4A6EAF16.6080804@freegeek.org> Brian Troutwine wrote: > Hello Wouter. > > I've had a go at the paper linked and perused other references found > with Google. Unfortunately, such sophisticated use of the type system > is pretty far out of my normal problem domain and I can't see how to > apply the techniques presented to my motivating example. Would you be > so kind as to elaborate? data Foo = One | Two | Three | Four data Odd = One | Three data Even = Two | Four ==> {- data Fix f = Fix { unFix :: f (Fix f) } data (:+:) f g x = Inl (f x) | Inr (g x) ... -} data One r = One data Two r = Two data Three r = Three data Four r = Four instance Functor One where fmap _ One = One instance Functor Two where fmap _ Two = Two instance Functor Three where fmap _ Three = Three instance Functor Four where fmap _ Four = Four type Foo = Fix (One :+: Two :+: Three :+: Four) type Odd = Fix (One :+: Three) type Even = Fix (Two :+: Four) If your original types were actually recursive, then the unfixed functors should use their r parameter in place of the recursive call, e.g. data List a = Nil | Cons a (List a) ==> data List a r = Nil | Cons a r Also, if you know a certain collection of component types must always occur together, then you can flatten parts of the coproduct and use normal unions as well. E.g. data Odd r = One | Three data Two r = Two data Four r = Four type Foo = Fix (Odd :+: Two :+: Four) -- Live well, ~wren From waldmann at imn.htwk-leipzig.de Tue Jul 28 04:06:01 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Tue Jul 28 03:47:19 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B03B9F826@ELON17P32001A.csfb.cs-group.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B03B9F826@ELON17P32001A.csfb.cs-group.com> Message-ID: <4A6EB169.1090301@imn.htwk-leipzig.de> Sittampalam, Ganesh wrote: > ... it would make it substantially less likely that > subexpressions could be abstracted into a separate declaration without > giving a type signature to fix the type of the new declaration. OK, then give a type signature to fix the type of (really, to document) the new declaration. I can't understand why declarative programmers insist they should be able to omit (type) declarations ... Best, J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 257 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090728/153b6461/signature-0001.bin From ganesh.sittampalam at credit-suisse.com Tue Jul 28 04:28:14 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Tue Jul 28 04:09:36 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <4A6EB169.1090301@imn.htwk-leipzig.de> References: <4A6DCE93.5020700@imn.htwk-leipzig.de><89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com><16442B752A06A74AB4D9F9A5FF076E4B03B9F826@ELON17P32001A.csfb.cs-group.com> <4A6EB169.1090301@imn.htwk-leipzig.de> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9F827@ELON17P32001A.csfb.cs-group.com> (To be clear, this about Cale's proposal, not simonpj's one) Johannes Waldmann wrote: > Sittampalam, Ganesh wrote: > >> ... it would make it substantially less likely that subexpressions >> could be abstracted into a separate declaration without giving a type >> signature to fix the type of the new declaration. > > OK, then give a type signature to fix the type of (really, to > document) the new declaration. > > I can't understand why declarative programmers insist they should be > able to omit (type) declarations ... I find type inference a valuable feature. Generally at some point I annotate top-level declarations, but while developing it's nice not to have to worry about it. Having to annotate every single declaration would be painful. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From apfelmus at quantentunnel.de Tue Jul 28 04:41:28 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Jul 28 04:22:37 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution In-Reply-To: <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: Cale Gibbard wrote: > There was a great related idea on #haskell the other day: Make > explicit qualification unnecessary whenever there is a *unique* choice > of module qualifications from those imported which would make the > expression typecheck. Ambiguities would still need to be qualified, > but I feel that this would eliminate 99% of all ugly qualified names > from code. It would be especially good in the case of infix operators, > which as far as I know, nobody actually enjoys qualifying explicitly. > > [...] > > What do people think of this idea? Personally, it really annoys me > whenever I'm forced to give explicit module qualifications, and I > think this would really help. It would also subsume the > DisambiguateRecordFields extension rather handily. While I do agree that qualified names are annoying at times, I think that type directed name disambiguation is a Pandora's box. Furthermore, we already have a mechanism for type based disambiguation, namely good old type classes. For instance, the qualifications required when importing Data.Map are actually a sign that we are lacking proper container type classes ? la Edison. There are other possible language extension that may make qualification easier, Pascal's with statement comes to mind. http://freepascal.decenturl.com/with-statement-pascal In Haskell, this would work something like this: histogram xs = with Data.Map foldl' f empty xs where f m x = case lookup m x where Just k -> insertWith x (+1) m Nothing -> insert x 1 m In the scope of with , ambiguous qualifications default to Data.Map . Regards, apfelmus -- http://apfelmus.nfshost.com From wren at freegeek.org Tue Jul 28 04:58:16 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Jul 28 04:39:32 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances In-Reply-To: <4A6E0E3E.8080907@cs.au.dk> References: <20090717191433.GA19514@pudlak.name> <4A6907E3.6070208@freegeek.org> <49a77b7a0907231914k16b2634cs13514097ce841b3d@mail.gmail.com> <4A6A1DCD.8090503@freegeek.org> <4A6E0E3E.8080907@cs.au.dk> Message-ID: <4A6EBDA8.9080801@freegeek.org> Tillmann Rendel wrote: > wren ng thornton wrote: >> [1] In System F the capital-lambda binder is used for the term-level >> abstraction of passing type representations. So for example we have, >> >> id :: forall a. a -> a >> id = /\a. \(x::a). x >> >> Thus, the forall keyword is serving as the type-level abstraction. >> Perhaps this is suboptimal syntax, but it is the standard. We could, >> of course, have both a term-level /\ and a type-level /\ where the >> latter is the type of the former (since the namespaces are separate) >> though that's also dubious. Capital-pi is the canonical type-level >> abstraction, though that evokes the idea of dependent types which are >> much more complex. > > What do you mean by "type-level abstraction" here? I mean an abstraction, as in a lambda-abstraction (aka a lambda-expression), at the type level. > In a language with type functions and polymorphism, we need three > different lambda binders: > > (1) abstraction over terms in terms (to construct functions) > (2) abstraction over types in terms (to construct polymorphic values) > (3) abstraction over types in types (to construct type functions) > > I think only (2) should be written as upper-case lambdas, while (1) and > (3) should both be written as lower-case lambdas. Since (1) and (3) > belong to different syntactic categories, they can not be confused, and > we can reuse the lower-case lambda at the type-level. I'm sure that's fine. I was merely pointing out precedent. The syntax of #3 could also be conflated with the syntax of #2, for the same reason: they are in different syntactic categories. I pointed this out because the capital-lambda was the syntax others in the thread were using. Also, it makes sense to me to have #2 and #3 ("abstraction over types in _") paired together, rather than #1 and #3 ("abstraction over X in X"). Pairing #2/#3 also gives term/type symmetry as we have for other built-ins like [], (,), and -> (though the symmetry is imperfect for ->). > Furthermore, we need three function types / kinds to describe the three > lambdas one level higher: > > (4) the type of functions > (5) the type of polymorphic values > (6) the kind of type functions > > In ghc, we already have "forall" for (5), and arrows for (4) and (6). > > I would say that (3) is the "type-level abstraction", not (5). I'm not sure I follow what you mean. Given the relationship between /\ and forall as demonstrated in the definition of id above, I don't see such a difference between #3 and #5. That is, given the need for #2 the need for #5 follows; from there #3 follows by extending the wording of #5. (Though #6 is desirable from a theoretical perspective I'm not sure whether the language needs to be able to express it. There's much else at the kind-layer we cannot express.) In other words, just because forall is the type of /\ doesn't mean that that's all it is. All of these are effectively identical: -- Just a type-level lambda five :: (forall a. a) Int five = 5 -- Making the term-level match the type exactly five :: (forall a. a) Int five = (/\a. 5::a) @Int -- Hiding a CAF behind a constant type -- (somewhat like how numeric constants really work) five :: Int five = (/\a. 5::a) @Int -- Boring five :: Int five = 5 -- Live well, ~wren From sebf at informatik.uni-kiel.de Tue Jul 28 04:58:53 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Tue Jul 28 04:40:06 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: <7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> <7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> Message-ID: > The M is the list, i.e. nondeterminism monad. For each element in > the list, there is one return value where it appears (True), and one > where it does not (False). This discussion made Curry [1] programmers realise the beauty of non- determinism and lead to interesting reformulations of common list functions [2]. Here are some of them translated to Haskell: inits = takeWhileM (const [True,False]) tails = dropWhileM (const [True,False]) perms = sortByM (const [True,False]) Only that Hoogle does not know any of these monadic helper functions. Cheers, Sebastian [1]: http://www.curry-language.org/ [2]: unfortunately not yet in the mailing list archive ( Thread title: "beautiful non-determinism") -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090728/1718bff2/attachment.html From ganesh.sittampalam at credit-suisse.com Tue Jul 28 05:06:52 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Tue Jul 28 04:48:16 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com><7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9F829@ELON17P32001A.csfb.cs-group.com> > perms = sortByM (const [True,False]) This doesn't seem right, since the comparison function is inconsistent and moreover the results will depend on the sorting algorithm chosen. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From felipe.lessa at gmail.com Tue Jul 28 05:09:38 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Jul 28 04:50:56 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> <7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> Message-ID: <20090728090938.GA13200@kira.casa> On Tue, Jul 28, 2009 at 10:58:53AM +0200, Sebastian Fischer wrote: > tails = dropWhileM (const [True,False]) Actually this should be tails = dropWhileM (const [False, True]) -- Felipe. From dvde at gmx.net Tue Jul 28 06:17:53 2009 From: dvde at gmx.net (Daniel van den Eijkel) Date: Tue Jul 28 05:59:09 2009 Subject: [Haskell-cafe] ghci identifier listing question In-Reply-To: <50c1e0910907272354l43baa618h59cae3829dd337f1@mail.gmail.com> References: <4A6E3A39.3080309@gmx.net> <50c1e0910907272354l43baa618h59cae3829dd337f1@mail.gmail.com> Message-ID: <4A6ED051.1050202@gmx.net> Ah, thats great! And it shows the values (or part of if), too. Very nice. Thank you, Daniel Jeff Wheeler schrieb: > On Mon, Jul 27, 2009 at 6:37 PM, Daniel van den Eijkel wrote: > > >> Is it possible, to reach the (shadowed) values in any way? >> > > I'm not sure about this, but . . . > > >> Another question: Is it possible to show only those identifiers that are >> defined during the interactive session? I only can list all identifiers >> which start with a given prefix, but I would like to know if GHCi can show >> me all identifiers defined in a given module or in the current session (by >> pressing Tab or alike). >> > > Yes, this will list the current bindings: > > >> :show bindings >> > > Jeff Wheeler > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dav.vire+haskell at gmail.com Tue Jul 28 07:17:11 2009 From: dav.vire+haskell at gmail.com (david48) Date: Tue Jul 28 06:58:23 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution In-Reply-To: References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <4c88418c0907280417s4c9b912k413949c35fa487ed@mail.gmail.com> > There are other possible language extension that may make qualification > easier, Pascal's ?with ?statement comes to mind. > > ?http://freepascal.decenturl.com/with-statement-pascal > > In Haskell, this would work something like this: > > ?histogram xs = > ? ? ?with Data.Map > ? ? ? ? ?foldl' f empty xs > ? ? ? ? ?where > ? ? ? ? ? ? ?f m x = case lookup m x where > ? ? ? ? ? ? ? ? ? ? ? ? Just k ?-> insertWith x (+1) m I like both that and TDNR. It would be cool that at least one of them gets accepted in Haskell prime. David. From rendel at cs.au.dk Tue Jul 28 08:28:05 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Tue Jul 28 08:08:45 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances In-Reply-To: <4A6EBDA8.9080801@freegeek.org> References: <20090717191433.GA19514@pudlak.name> <4A6907E3.6070208@freegeek.org> <49a77b7a0907231914k16b2634cs13514097ce841b3d@mail.gmail.com> <4A6A1DCD.8090503@freegeek.org> <4A6E0E3E.8080907@cs.au.dk> <4A6EBDA8.9080801@freegeek.org> Message-ID: <4A6EEED5.3090409@cs.au.dk> wren ng thornton wrote: >>> Thus, the forall keyword is serving as the type-level abstraction. >> >> What do you mean by "type-level abstraction" here? > > I mean an abstraction, as in a lambda-abstraction (aka a > lambda-expression), at the type level. > >> [...] > > I'm not sure I follow what you mean. I mean that the forall keyword is *not* serving as the type-level abstraction. There is a difference between abstraction (as in lambda abstraction) and the type of abstractions (as in function types). In pure type systems, we have two different binders for these different features: - lower-case lambda for abstraction (on all levels) - upper-case Pi for the type of abstractions (on all levels) I find it highly confusing to say that forall denotes type-level abstraction, because it does not denote abstraction at all. It rather denotes the type of an abstraction, namely in Haskell, the type of abstracting over types in terms. In other words, the following is not legal Haskell, and not how forall works in any polymorphic lambda calculus: > -- Just a type-level lambda > five :: (forall a. a) Int > five = 5 > > -- Making the term-level match the type exactly > five :: (forall a. a) Int > five = (/\a. 5::a) @Int Note that (forall a . a) has kind *, so (forall a . a) Int is not even well-kinded, as ghci correctly determines: > ghci -XRankNTypes > :k (forall a. a) (forall a. a) :: * > :k (forall a . a) Int :1:0: Kind error: `forall a. a' is applied to too many type arguments About syntax: >> (1) abstraction over terms in terms (to construct functions) >> (2) abstraction over types in terms (to construct polymorphic values) >> (3) abstraction over types in types (to construct type functions) > > The syntax of #3 could also be conflated with the syntax of #2, for > the same reason: they are in different syntactic categories. I > pointed this out because the capital-lambda was the syntax others in > the thread were using. Also, it makes sense to me to have #2 and #3 > ("abstraction over types in _") paired together, rather than #1 and > #3 ("abstraction over X in X"). Pairing #2/#3 also gives term/type > symmetry as we have for other built-ins like [], (,), and -> (though > the symmetry is imperfect for ->). I agree that this makes as much sense as my view. However, I still argue that the existing type/kind symmetry for -> should be reflected in a term/type symmetry for \. We already have: id x = x type Id x = x :t id id :: a -> a :k Id Id :: * -> * And I think anonymous type-level abstraction should look like this: id' = \x -> x type Id' = \x -> x :t id' id' :: a -> a :k Id' Id' :: * -> * I would use the upper-case lambda for kind-polymorphism on the type level. type Id'' = /\k -> \t :: k -> t :k Id'' :: forall k . k -> k :k Id'' [*] :: * -> * :k Id'' [*] Int = Int :k Id'' [forall k . k -> k] Id'' [*] Int = Int Tillmann From ck_kashyap at yahoo.com Tue Jul 28 09:04:47 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Tue Jul 28 08:45:59 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code Message-ID: <549911.34300.qm@web112502.mail.gq1.yahoo.com> Hi Everyone, I managed to write up the line drawing function using the following links - http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell line :: Point -> Point -> [Point] line (xa,ya) (xb,yb) = line' (x1,y1) (x2,y2) deltax deltay ystep isSteep 0 where isSteep = abs (yb - ya) > abs (xb - xa) (xa',ya',xb',yb') = if isSteep then (ya,xa,yb,xb) else (xa,ya,xb,yb) (x1,y1,x2,y2) = if xa' > xb' then (xb',yb',xa',ya') else (xa',ya',xb',yb') deltax = x2 - x1 deltay = abs (y2 - y1) ystep = if y1 < y2 then 1 else -1 line' :: Point -> Point -> Integer -> Integer -> Integer -> Bool -> Integer -> [Point] line' (x1,y1) (x2,y2) deltax deltay ystep isSteep error = if x1 == x2 then if isSteep then [(y1,x1)] else [(x1,y1)] else if isSteep then [(y1,x1)] ++ line' (newX,newY) (x2,y2) deltax deltay ystep isSteep newError else [(x1,y1)] ++ line' (newX,newY) (x2,y2) deltax deltay ystep isSteep newError where newX = x1 + 1 tempError = error + deltay (newY, newError) = if (2*tempError) >= deltax then (y1+ystep,tempError-deltax) else (y1,tempError) Can someone please provide feedback on this? In terms of, how do I get more Haskell'ism into it. Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090728/ecd2935b/attachment.html From ndmitchell at gmail.com Tue Jul 28 09:14:58 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Jul 28 08:56:10 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <549911.34300.qm@web112502.mail.gq1.yahoo.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> Message-ID: <404396ef0907280614o707e9e4rf7280bb948d18949@mail.gmail.com> Hi Kashyap, My first suggestion would be to run HLint over the code (http://community.haskell.org/~ndm/hlint) - that will spot a few easy simplifications. Thanks Neil On Tue, Jul 28, 2009 at 2:04 PM, CK Kashyap wrote: > Hi Everyone, > I managed to write up the line drawing function using the following links - > http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html > http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell > > line :: Point -> Point -> [Point] > line (xa,ya) (xb,yb) = line' (x1,y1) (x2,y2) deltax deltay ystep isSteep 0 > ? where > ??? isSteep = abs (yb - ya) > abs (xb - xa) > ??? (xa',ya',xb',yb') = if isSteep > ????? then (ya,xa,yb,xb) > ????? else (xa,ya,xb,yb) > ??? (x1,y1,x2,y2) = if xa' > xb' > ????? then (xb',yb',xa',ya') > ????? else (xa',ya',xb',yb') > ??? deltax = x2 - x1 > ??? deltay = abs (y2 - y1) > ??? ystep = if y1 < y2 then 1 else -1 > > > line' :: Point -> Point -> Integer -> Integer -> Integer -> Bool -> Integer > -> [Point] > line' (x1,y1) (x2,y2) deltax deltay ystep isSteep error = > ? if x1 == x2 > ? then if isSteep then [(y1,x1)] else [(x1,y1)] > ? else > ??? if isSteep > ????? then [(y1,x1)] ++ line' (newX,newY) (x2,y2) deltax deltay ystep > isSteep newError > ????? else [(x1,y1)] ++ line' (newX,newY) (x2,y2) deltax deltay ystep > isSteep newError > ??????? where > ????????? newX = x1 + 1 > ????????? tempError = error + deltay > ????????? (newY, newError) = if (2*tempError) >= deltax then > (y1+ystep,tempError-deltax) else (y1,tempError) > > > Can someone please provide feedback on this? In terms of, how do I get more > Haskell'ism into it. > > Regards, > Kashyap > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ck_kashyap at yahoo.com Tue Jul 28 09:37:35 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Tue Jul 28 09:18:46 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <404396ef0907280614o707e9e4rf7280bb948d18949@mail.gmail.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <404396ef0907280614o707e9e4rf7280bb948d18949@mail.gmail.com> Message-ID: <569734.60828.qm@web112506.mail.gq1.yahoo.com> Thanks Neil, That helped. Now the code looks better - I still feel a little bad about the way I repeat calls to line' though - I was thinking of using a partially applied function with (newX,newY) as the last parameter - but that'll make the code less readable. line :: Point -> Point -> [Point] line (xa,ya) (xb,yb) = line' (x1,y1) (x2,y2) deltax deltay ystep isSteep 0 where isSteep = abs (yb - ya) > abs (xb - xa) (xa',ya',xb',yb') = if isSteep then (ya,xa,yb,xb) else (xa,ya,xb,yb) (x1,y1,x2,y2) = if xa' > xb' then (xb',yb',xa',ya') else (xa',ya',xb',yb') deltax = x2 - x1 deltay = abs (y2 - y1) ystep = if y1 < y2 then 1 else -1 line' (x1, y1) (x2, y2) deltax deltay ystep isSteep error | x1 == x2 = if isSteep then [(y1, x1)] else [(x1, y1)] | isSteep = (y1, x1) : line' (newX, newY) (x2, y2) deltax deltay ystep isSteep newError | otherwise = (x1, y1) : line' (newX, newY) (x2, y2) deltax deltay ystep isSteep newError where newX = x1 + 1 tempError = error + deltay (newY, newError) = if (2 * tempError) >= deltax then (y1 + ystep, tempError - deltax) else (y1, tempError) Regards, Kashyap ________________________________ From: Neil Mitchell To: CK Kashyap Cc: haskell-cafe@haskell.org Sent: Tuesday, July 28, 2009 6:44:58 PM Subject: Re: [Haskell-cafe] Need feedback on my Haskell code Hi Kashyap, My first suggestion would be to run HLint over the code (http://community.haskell.org/~ndm/hlint) - that will spot a few easy simplifications. Thanks Neil On Tue, Jul 28, 2009 at 2:04 PM, CK Kashyap wrote: > Hi Everyone, > I managed to write up the line drawing function using the following links - > http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html > http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell > > line :: Point -> Point -> [Point] > line (xa,ya) (xb,yb) = line' (x1,y1) (x2,y2) deltax deltay ystep isSteep 0 > where > isSteep = abs (yb - ya) > abs (xb - xa) > (xa',ya',xb',yb') = if isSteep > then (ya,xa,yb,xb) > else (xa,ya,xb,yb) > (x1,y1,x2,y2) = if xa' > xb' > then (xb',yb',xa',ya') > else (xa',ya',xb',yb') > deltax = x2 - x1 > deltay = abs (y2 - y1) > ystep = if y1 < y2 then 1 else -1 > > > line' :: Point -> Point -> Integer -> Integer -> Integer -> Bool -> Integer > -> [Point] > line' (x1,y1) (x2,y2) deltax deltay ystep isSteep error = > if x1 == x2 > then if isSteep then [(y1,x1)] else [(x1,y1)] > else > if isSteep > then [(y1,x1)] ++ line' (newX,newY) (x2,y2) deltax deltay ystep > isSteep newError > else [(x1,y1)] ++ line' (newX,newY) (x2,y2) deltax deltay ystep > isSteep newError > where > newX = x1 + 1 > tempError = error + deltay > (newY, newError) = if (2*tempError) >= deltax then > (y1+ystep,tempError-deltax) else (y1,tempError) > > > Can someone please provide feedback on this? In terms of, how do I get more > Haskell'ism into it. > > Regards, > Kashyap > > > _______________________________________________ > 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/20090728/2d7d8bcb/attachment.html From chaddai.fouche at gmail.com Tue Jul 28 09:40:38 2009 From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=) Date: Tue Jul 28 09:21:49 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <549911.34300.qm@web112502.mail.gq1.yahoo.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> Message-ID: On Tue, Jul 28, 2009 at 3:04 PM, CK Kashyap wrote: > Hi Everyone, > I managed to write up the line drawing function using the following links - > http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html > http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell > I tried to simplify your function a little bit : line :: Point -> Point -> [Point] line pa@(xa,ya) pb@(xb,yb) = map maySwitch . unfoldr go $ (x1,y1,0) where steep = abs (yb - ya) > abs (xb - xa) maySwitch = if steep then (\(x,y) -> (y,x)) else id [(x1,y1),(x2,y2)] = sort [maySwitch pa, maySwitch pb] deltax = x2 - x1 deltay = abs (y2 - y1) ystep = if y1 < y2 then 1 else -1 go (xTemp, yTemp, error) | xTemp > x2 = Nothing | otherwise = Just ((xTemp, yTemp), (xTemp + 1, newY, newError)) where tempError = error + deltay (newY, newError) = if (2*tempError) >= deltax then (yTemp+ystep,tempError-deltax) else (yTemp,tempError) I think it will be a bit better, tell me what you think ? -- Jeda? From sebf at informatik.uni-kiel.de Tue Jul 28 09:47:53 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Tue Jul 28 09:29:07 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B03B9F829@ELON17P32001A.csfb.cs-group.com> References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com><7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B03B9F829@ELON17P32001A.csfb.cs-group.com> Message-ID: On Jul 28, 2009, at 11:06 AM, Sittampalam, Ganesh wrote: >> perms = sortByM (const [True,False]) > > This doesn't seem right, since the comparison function is inconsistent I was also wary about this point, e.g. QuickSort depends on transitivity. > and moreover the results will depend on the sorting algorithm chosen. Is it only that different sorting algorithms enumerate all permutations in different orders or is there a sorting algorithm, such that the above definition does not enumerate all permutations? Here is some shirt-sleeved reasoning: Every sorting algorithm :: [Int] -> [Int] that actually sorts can describe every possible permutation (if there is a permutation that cannot be realised by the sorting algorithm then there is an input list that cannot be sorted). Hence, if this sorting algorithm is `sortBy p` for some predicate p then there are possible decisions of p to produce every possible permutation. If p makes *every* decision non- deterministically then certainly the specific decisions necessary for any specific permutation are also made. Hence, perm as defined above can yield a list that contains all permutations of the input (at least once) regardless of the sorting algorithm. Where is the hitch? Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From ganesh.sittampalam at credit-suisse.com Tue Jul 28 09:58:29 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Tue Jul 28 09:40:07 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com><7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B03B9F829@ELON17P32001A.csfb.cs-group.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9F82E@ELON17P32001A.csfb.cs-group.com> Sebastian Fischer wrote: > On Jul 28, 2009, at 11:06 AM, Sittampalam, Ganesh wrote: > >>> perms = sortByM (const [True,False]) >> >> and moreover the results will depend on the sorting algorithm chosen. > > Is it only that different sorting algorithms enumerate all > permutations in different orders or is there a sorting algorithm, > such that the above definition does not enumerate all permutations? > [..] > Hence, perm as defined above can yield a list that contains all > permutations of the input (at least once) regardless of the sorting > algorithm. > > Where is the hitch? The "at least once" bit - unless your non-determinism is based on set rather than bag semantics, it's wrong to duplicate results. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From felipe.lessa at gmail.com Tue Jul 28 10:24:34 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Jul 28 10:05:51 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <549911.34300.qm@web112502.mail.gq1.yahoo.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> Message-ID: <20090728142434.GA4655@kira.casa> Small tips: - Use swap and avoid those if's. - [a] ++ b is the same as a : b. - Factor out the first point that is always there. - Factor out line' arguments that don't change with the recursion. Untested: > swap :: Bool -> (a,a) -> (a,a) > swap False = id > swap True = \(x,y) -> (y,x) > > line :: Point -> Point -> [Point] > line (xa,ya) (xb,yb) = line' p1 p2 deltax deltay ystep isSteep 0 > where > isSteep = abs (yb - ya) > abs (xb - xa) > (p1,p2) = let a = swap isSteep (xa,ya) > b = swap isSteep (xb,yb) > in swap (fst a > fst b) (a, b) > ((x1,y1),(x2,y2)) = (p1,p2) > deltax = x2 - x1 > deltay = abs (y2 - y1) > ystep = if y1 < y2 then 1 else -1 > > > line' :: Point -> Point -> Integer -> Integer -> Integer -> Bool -> Integer -> [Point] > line' p1 (x2,_) deltax deltay ystep isSteep = go p1 > where > go (x1,y1) error = swap isSteep (x1,y1) : rest > where > rest = if x1 == x2 then [] else go (newX,newY) newError > newX = x1 + 1 > tempError = error + deltay > (newY, newError) = if (2*tempError) >= deltax > then (y1+ystep,tempError-deltax) else (y1,tempError) But now that we got here, you may inline line' and avoid "swap isSteep". I've also changed some names to more pleasant one (for me, at least :). Untested as well: > swap :: Bool -> (a,a) -> (a,a) > swap False = id > swap True = \(x,y) -> (y,x) > > line :: Point -> Point -> [Point] > line (xa,ya) (xb,yb) = go (x1,y1) 0 > where > ((x1,y1),(x2,y2)) = let a = adjust (xa,ya) > b = adjust (xb,yb) > in swap (fst a > fst b) (a, b) > adjust = swap $ abs (yb - ya) > abs (xb - xa) > deltax = x2 - x1 > deltay = abs (y2 - y1) > ystep = if y1 < y2 then 1 else -1 > > go (x,y) error = > let error' = error + deltay > (yd,ed) = if 2*tempError >= deltax then (ystep,deltax) else (0,0) > in adjust (x,y) : if x == x2 then [] else go (x+1,y+yd) (error' - ed) HTH, -- Felipe. From nadine.and.henry at pobox.com Tue Jul 28 10:29:13 2009 From: nadine.and.henry at pobox.com (Henry Laxen) Date: Tue Jul 28 10:10:34 2009 Subject: [Haskell-cafe] Adding a field to a data record Message-ID: Dear Group, It seems to me this should be easy, but I can't quite figure out how to do it without a lot of typing. Here is the question: Suppose you have a data type like: Data Foo = Foo { a :: Int, b :: Int, ... many other fields ... y :: Int } deriving (Eq, Read, Show, Typeable, Data) Now I would like to add a field z :: Int to the end of Foo. If I have a ton of data out on disk, which I wrote with, say writeFile "a.data" (show foo) -- where foo is a [Foo] say 1000 long, I would like to get a new "a.data" file which has a new z::Int field. So far the only way I can think of is to make a new Data Foo1, which includes the z::Int, read in a.data as a list of Foo, write a function like: fooTofoo1 :: Foo -> Foo1 fooTofoo1 xx = Foo1 {a = a xx, ... y = y xx, z = 1} then write the file back out, and perhaps use emacs to query-replace all the Foo1's back to Foo's, add the z::Int field back into Foo, and read it back. Please tell me there is a better way. Thanks in advance. Best wishes, Henry Laxen PS: I have read syb1, and syb2 a couple of times now, but so far haven't been able to connect it with this kind of problem. From Malcolm.Wallace at cs.york.ac.uk Tue Jul 28 10:40:16 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Jul 28 10:21:28 2009 Subject: [Haskell-cafe] Adding a field to a data record In-Reply-To: References: Message-ID: <44549581-0DF7-426B-9AFF-321C50B04B15@cs.york.ac.uk> > and perhaps use emacs to > query-replace all the Foo1's back to Foo's At least this bit can be avoided easily enough, by using module qualification during the conversion process. module Original (Foo(..)) where data Foo = Foo { ... y :: Int } deriving ... module New (Foo(..)) where data Foo = Foo { ... y, z :: Int } deriving ... module Convert where import Original as Old import New as New newFoo :: Old.Foo -> New.Foo newFoo old{..} = New.Foo { a=a, b=b, ... z=1 } Finally rename module New. Regards, Malcolm From tphyahoo at gmail.com Tue Jul 28 10:44:19 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Jul 28 10:25:31 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: References: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> Message-ID: <910ddf450907280744j6e1b7635kdb1c68760718ac44@mail.gmail.com> did you verify parsec-2.1.0.1 exports Text.Parsec.Language ? This might be a parsec 2 versus parsec 3 issue ghc-pkg describe parsec-2.1.0.1 should tell you the answer to that. 2009/7/27 Job Vranish : > I tried updating to ghc-6.10.4 and have exactly the same error. > Also ghc doesn't seem to be able to find any of the haskell platform > packages, even though it ghc-pkg finds them just fine. > > For example (trimmed for brevity): > > ghc-pkg list > /usr/local/lib/ghc-6.10.4/./package.conf: > ??? Cabal-1.6.0.3, > ... > ??? parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, > ... > > ghci -v readModel.hs > GHCi, version 6.10.4: http://www.haskell.org/ghc/? :? for help > Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98, stage 2 booted by > GHC version 6.8.2 > Using package config file: /usr/local/lib/ghc-6.10.4/./package.conf > ... > > readModel.hs:9:7: > ??? Could not find module `Text.Parsec.Language': > ????? locations searched: > ??????? Text/Parsec/Language.hs > ??????? Text/Parsec/Language.lhs > Failed, modules loaded: none. > ... > > > ghc-pkg finds parsec, but ghci can't find it. > > And if I do a cabal -v3 update I get a: > cabal: 3: openFile: does not exist (No such file or directory) > > Anybody figured it out? > > - Job Vranish > > On Fri, Jul 17, 2009 at 11:17 AM, Thomas Hartman wrote: >> >> cabal -v3 update >> >> will give you a more verbose version of what is going wrong. >> >> cabal --help >> >> regrettably, cabal --help doesn't tell you this but there is always >> the man page I suppose. >> >> 2009/7/16 Tony Hannan : >> > Hello, >> > >> > I'm on Ubuntu 8.10. >> > I installed ghc 6.10.4 (from binary package: >> > ghc-6.10.4-i386-unknown-linux-n.tar.bz2). >> > I installed haskell-platform-2009.2.0.1 (from source package: >> > haskell-platform-2009.2.0.1.tar.gz). It contains cabal-install-0.6.2. >> > >> > Then when I run "cabal update", I get the following error: >> > cabal:? : openFile: does not exist (No such file or directory) >> > >> > Any ideas? >> > >> > Thanks, >> > Tony >> > >> > _______________________________________________ >> > Libraries mailing list >> > Libraries@haskell.org >> > http://www.haskell.org/mailman/listinfo/libraries >> > >> > >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From nadine.and.henry at pobox.com Tue Jul 28 10:47:05 2009 From: nadine.and.henry at pobox.com (Henry Laxen) Date: Tue Jul 28 10:28:29 2009 Subject: [Haskell-cafe] Re: Adding a field to a data record References: <44549581-0DF7-426B-9AFF-321C50B04B15@cs.york.ac.uk> Message-ID: Malcolm Wallace cs.york.ac.uk> writes: > > > and perhaps use emacs to > > query-replace all the Foo1's back to Foo's > > At least this bit can be avoided easily enough, by using > module qualification during the conversion process. > > module Original (Foo(..)) where > data Foo = Foo { ... y :: Int } deriving ... > > module New (Foo(..)) where > data Foo = Foo { ... y, z :: Int } deriving ... > > module Convert where > import Original as Old > import New as New > newFoo :: Old.Foo -> New.Foo > newFoo old{..} = New.Foo { a=a, b=b, ... z=1 } > > Finally rename module New. > > Regards, > Malcolm > Thanks Malcolm, yes, that keeps me out of emacs, but the part I would really like to avoid is writing the New.Foo { a=a, b=b, ... z=1 } part, where the field names are many, long, and varied. Yes, I could cut and paste, but I'm hoping for a "better way." Thanks. Best wishes, Henry Laxen From dagit at codersbase.com Tue Jul 28 10:56:06 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue Jul 28 10:37:17 2009 Subject: [Haskell-cafe] Re: Adding a field to a data record In-Reply-To: References: <44549581-0DF7-426B-9AFF-321C50B04B15@cs.york.ac.uk> Message-ID: On Tue, Jul 28, 2009 at 7:47 AM, Henry Laxen wrote: > Malcolm Wallace cs.york.ac.uk> writes: > > > > > > and perhaps use emacs to > > > query-replace all the Foo1's back to Foo's > > > > At least this bit can be avoided easily enough, by using > > module qualification during the conversion process. > > > > module Original (Foo(..)) where > > data Foo = Foo { ... y :: Int } deriving ... > > > > module New (Foo(..)) where > > data Foo = Foo { ... y, z :: Int } deriving ... > > > > module Convert where > > import Original as Old > > import New as New > > newFoo :: Old.Foo -> New.Foo > > newFoo old{..} = New.Foo { a=a, b=b, ... z=1 } > > > > Finally rename module New. > > > > Regards, > > Malcolm > > > > Thanks Malcolm, yes, that keeps me out of emacs, but the part I would > really > like to avoid is writing the New.Foo { a=a, b=b, ... z=1 } part, where the > field > names are many, long, and varied. Yes, I could cut and paste, but I'm > hoping > for a "better way." Thanks. I guess you could define: type UpgradeFoo = (Foo, Int) And then write the conversion code as a zip. upgradeFoo foos = zip foos [1..] instance Show UpgradeFoo where ... And then use the module trick to switch the code around? Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090728/33fce6e4/attachment.html From mauricio.antunes at gmail.com Tue Jul 28 10:55:39 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Tue Jul 28 10:46:14 2009 Subject: [Haskell-cafe] Re: Adding a field to a data record In-Reply-To: References: Message-ID: > Suppose you have a data type like: > Data Foo = Foo { a :: Int, b :: Int, > ... many other fields ... > y :: Int } deriving (Eq, Read, Show, Typeable, Data) > > Now I would like to add a field z :: Int to the end of Foo. If > I have a ton of data out on disk, which I wrote with, say > writeFile "a.data" (show foo) -- where foo is a [Foo] say 1000 > long, I would like to get a new "a.data" file which has a new > z::Int field. This seems to depend on what you want to accomplish. Is your goal just to rewrite this whole file? If it is, the idea of just adding a field to Foo would be enough. You could then add that 'z' field in your file using 'sed' (or, as you said, emacs) and then read it back. In general, however, if you want to deal with this kind of translation of text to data, what you really want is to take some time to learn something like Parsec. http://www.haskell.org/ghc/docs/latest/html/libraries/parsec/Text-ParserCombinators-Parsec.html > So far the only way I can think of is to make a new Data Foo1, > which includes the z::Int, read in a.data as a list of Foo, > write a function like: > > fooTofoo1 :: Foo -> Foo1 > fooTofoo1 xx = Foo1 {a = a xx, ... y = y xx, z = 1} Note that this would not work exactly like that. 'a' is a "field" of Foo, and that means it's a function like a :: Foo -> Int So, you can't use it as a field of Foo1, as that would imply a :: Foo1 -> Int Best, Maur?cio From Malcolm.Wallace at cs.york.ac.uk Tue Jul 28 11:07:58 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Jul 28 10:49:10 2009 Subject: [Haskell-cafe] Re: Adding a field to a data record In-Reply-To: References: <44549581-0DF7-426B-9AFF-321C50B04B15@cs.york.ac.uk> Message-ID: > the part I would really like to avoid is writing the > New.Foo { a=a, b=b, ... z=1 } part, where the field > names are many, long, and varied. OK, here is another hack-ish trick, since I notice your data is stored on disk as text, using "show". I assume you are using something like Read to retrieve it. Well, how about using a real parser instead? The parser during conversion can be slightly more lax, automatically adding in the extra field. For instance, using polyparse's Text.Parse, and DrIFT to derive the appropriate Parse instance for your datatype: module Foo where data Foo = Foo { a :: Int , b :: Bool , c :: Maybe Foo } {-! derive : Parse !-} DrIFT gives you this instance: {-* Generated by DrIFT : Look, but Don't Touch. *-} instance Parse Foo where parse = constructors [ ( "Foo" , return Foo `discard` isWord "{" `apply` field "a" `discard` isWord "," `apply` field "b" `discard` isWord "," `apply` field "c" `discard` isWord "}" ) ] Let's say the field 'b' is new, and your existing data does not have it. So just take the parser generated by DrIFT and make a small modification: {-* Generated by DrIFT but modified by hand for conversion purposes *-} instance Parse Foo where parse = constructors [ ( "Foo" , return Foo `discard` isWord "{" `apply` field "a" `apply` return True -- this field does not yet exist in data `discard` isWord "," `apply` field "c" `discard` isWord "}" ) ] Then do the obvious thing: parse the old data, immediately write it out again, and then throw away the modified parser in favour of the pure generated one. Regards, Malcolm From ck_kashyap at yahoo.com Tue Jul 28 11:12:46 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Tue Jul 28 10:53:57 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> Message-ID: <836992.61083.qm@web112509.mail.gq1.yahoo.com> Thank you very much Jedai ... this looks much more concise and does not contain the repetitions that I had. I'd need to go over it more to understand it better. I'll ping you if I have any questions about this. Regards, Kashyap ________________________________ From: Chadda? Fouch? To: CK Kashyap Cc: haskell-cafe@haskell.org Sent: Tuesday, July 28, 2009 7:10:38 PM Subject: Re: [Haskell-cafe] Need feedback on my Haskell code On Tue, Jul 28, 2009 at 3:04 PM, CK Kashyap wrote: > Hi Everyone, > I managed to write up the line drawing function using the following links - > http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html > http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell > I tried to simplify your function a little bit : line :: Point -> Point -> [Point] line pa@(xa,ya) pb@(xb,yb) = map maySwitch . unfoldr go $ (x1,y1,0) where steep = abs (yb - ya) > abs (xb - xa) maySwitch = if steep then (\(x,y) -> (y,x)) else id [(x1,y1),(x2,y2)] = sort [maySwitch pa, maySwitch pb] deltax = x2 - x1 deltay = abs (y2 - y1) ystep = if y1 < y2 then 1 else -1 go (xTemp, yTemp, error) | xTemp > x2 = Nothing | otherwise = Just ((xTemp, yTemp), (xTemp + 1, newY, newError)) where tempError = error + deltay (newY, newError) = if (2*tempError) >= deltax then (yTemp+ystep,tempError-deltax) else (yTemp,tempError) I think it will be a bit better, tell me what you think ? -- Jeda? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090728/acb85006/attachment.html From iavor.diatchki at gmail.com Tue Jul 28 12:37:11 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Tue Jul 28 12:18:23 2009 Subject: [Haskell-cafe] Re: Adding a field to a data record In-Reply-To: References: <44549581-0DF7-426B-9AFF-321C50B04B15@cs.york.ac.uk> Message-ID: <5ab17e790907280937q770836aex401b1afb1509d368@mail.gmail.com> Hello, you may also find the package "pretty-show" (http://hackage.haskell.org/package/pretty-show) useful. It contains code to convert automatically derived instances of "Show" into an explicit data structure, which you can then manipulate (e.g., by adding the extra field), and then render back to text. -Iavor On Tue, Jul 28, 2009 at 6:07 PM, Malcolm Wallace wrote: >> the part I would really like to avoid is writing the >> New.Foo { a=a, b=b, ... z=1 } part, where the field >> names are many, long, and varied. > > OK, here is another hack-ish trick, since I notice your data is stored on > disk as text, using "show". ?I assume you are using something like Read to > retrieve it. ?Well, how about using a real parser instead? ?The parser > during conversion can be slightly more lax, automatically adding in the > extra field. > > For instance, using polyparse's Text.Parse, and DrIFT to derive the > appropriate Parse instance for your datatype: > > ? ?module Foo where > ? ?data Foo = Foo { a :: Int > ? ? ? ? ? ? ? ? ? , b :: Bool > ? ? ? ? ? ? ? ? ? , c :: Maybe Foo } > ? ? ?{-! derive : Parse !-} > > DrIFT gives you this instance: > > ? ?{-* Generated by DrIFT : Look, but Don't Touch. *-} > ? ?instance Parse Foo where > ? ? ? ?parse = constructors > ? ? ? ? ? ?[ ( "Foo" > ? ? ? ? ? ? ?, return Foo `discard` isWord "{" `apply` field "a" > ? ? ? ? ? ? ? ? ? ? ? `discard` isWord "," `apply` field "b" > ? ? ? ? ? ? ? ? ? ? ? `discard` isWord "," `apply` field "c" > ? ? ? ? ? ? ? ? ? ? ? `discard` isWord "}" > ? ? ? ? ? ? ?) > ? ? ? ? ? ?] > > Let's say the field 'b' is new, and your existing data does not have it. ?So > just take the parser generated by DrIFT and make a small modification: > > ? ?{-* Generated by DrIFT but modified by hand for conversion purposes *-} > ? ?instance Parse Foo where > ? ? ? ?parse = constructors > ? ? ? ? ? ?[ ( "Foo" > ? ? ? ? ? ? ?, return Foo `discard` isWord "{" `apply` field "a" > ? ? ? ? ? ? ? ? ? ? ? `apply` return True -- this field does not yet exist > in data > ? ? ? ? ? ? ? ? ? ? ? `discard` isWord "," `apply` field "c" > ? ? ? ? ? ? ? ? ? ? ? `discard` isWord "}" > ? ? ? ? ? ? ?) > ? ? ? ? ? ?] > > Then do the obvious thing: parse the old data, immediately write it out > again, and then throw away the modified parser in favour of the pure > generated one. > > Regards, > ? ?Malcolm > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Tue Jul 28 13:05:29 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 28 12:46:39 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution In-Reply-To: References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <2f9b2d30907281005u5bff3db4h19c59290b166a9ef@mail.gmail.com> On Tue, Jul 28, 2009 at 1:41 AM, Heinrich Apfelmus wrote: > While I do agree that qualified names are annoying at times, I think > that type directed name disambiguation is a Pandora's box. I see where you are going, but I'm not sure I agree. Let me give an example from another language with this kind of resolution: C++. From a purely practical point of view, function overloading in C++ does what I want almost all the time. And when it doesn't do what I want, it's always been immediately obvious, and it's a sign that my design is flawed. But those cases where it does what I want have been incredibly useful. > Furthermore, we already have a mechanism for type based disambiguation, > namely good old type classes. For instance, the qualifications required > when importing ?Data.Map ?are actually a sign that we are lacking proper > container type classes ? la Edison. Perhaps. I think containers is a great example of why you want TDNR. Many containers have *almost* the same interface, but not quite. After all, if the interface was the same, you would just find the most efficient container for that interface and call it a day. So unless you want to go the direction of putting every single container-related function in its own typeclass, I don't think you'll be able to come up with "one container interface to rule them all". To be fair, I'm not against the idea of putting each function in its own typeclass. For work along these lines, see the many "better numeric hierarchy" attempts. But I'd also need support for class aliases or something similar so that defining common subsets of those classes would work easily. Along those lines, what about being able to elide class names when they can be unambiguously determined from the functions defined? instance _ [] where fmap = map pure x = [x] fs <*> xs = [ f x | f <- fs, x <- xs ] return x = [x] m >>= f = concatMap f m This would define Functor, Applicative, and Monad for []. -- ryan From ryani.spam at gmail.com Tue Jul 28 13:10:44 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 28 12:51:55 2009 Subject: [Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell? In-Reply-To: References: <910ddf450907170235n68abf28q4513fc62da5b8a37@mail.gmail.com> <7ca3f0160907170245x659523c3pdb7efc5cd4a59307@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B03B9F829@ELON17P32001A.csfb.cs-group.com> Message-ID: <2f9b2d30907281010v13162a44x6a55e1ad463b2ac4@mail.gmail.com> On Tue, Jul 28, 2009 at 6:47 AM, Sebastian Fischer wrote: >>> perms = sortByM (const [True,False]) > Hence, perm as defined above can yield a list that contains all permutations > of the input (at least once) regardless of the sorting algorithm. > > Where is the hitch? The algorithm might diverge when given a non-transitive comparison operator. On Spore we had a bug where a NaN got into a list of floats we were sorting and our quicksort corrupted the heap because < isn't transitive on lists with NaNs. -- ryan From colin at colina.demon.co.uk Tue Jul 28 13:16:22 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Jul 28 12:57:44 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution In-Reply-To: <2f9b2d30907281005u5bff3db4h19c59290b166a9ef@mail.gmail.com> (Ryan Ingram's message of "Tue\, 28 Jul 2009 10\:05\:29 -0700") References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <2f9b2d30907281005u5bff3db4h19c59290b166a9ef@mail.gmail.com> Message-ID: >>>>> "Ryan" == Ryan Ingram writes: Ryan> Along those lines, what about being able to elide class Ryan> names when they can be unambiguously determined from the Ryan> functions defined? Ryan> instance _ [] where fmap = map pure x = [x] fs <*> xs = [ f Ryan> x | f <- fs, x <- xs ] return x = [x] m >>= f = concatMap f Ryan> m Ryan> This would define Functor, Applicative, and Monad for []. What happens if I define a class Foo with a method named fmap? If this were in scope then Functor would no longer be defined for []. Could this situation cause a problem? -- Colin Adams Preston Lancashire From Eduard.Sergeev at gmail.com Tue Jul 28 18:51:44 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Tue Jul 28 18:32:53 2009 Subject: [Haskell-cafe] Deepest polymorphic functor Message-ID: <24709303.post@talk.nabble.com> I was wondering if it is possible to somehow change "deep" f_map from http://okmij.org/ftp/Haskell/deepest-functor.lhs article in a such a way that it would work not only for monotypes like in the provided example: test1 = f_map (+1) [[[1::Int,2,3]]] But for polymorphic types as well (e.g. behaves like simple map) so the following line would compile as well: test1 = f_map (+1) [[[1,2,3]]] ? -- View this message in context: http://www.nabble.com/Deepest-polymorphic-functor-tp24709303p24709303.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From wren at freegeek.org Tue Jul 28 19:44:01 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Jul 28 19:25:15 2009 Subject: [Haskell-cafe] lifting restrictions on defining instances In-Reply-To: <4A6EEED5.3090409@cs.au.dk> References: <20090717191433.GA19514@pudlak.name> <4A6907E3.6070208@freegeek.org> <49a77b7a0907231914k16b2634cs13514097ce841b3d@mail.gmail.com> <4A6A1DCD.8090503@freegeek.org> <4A6E0E3E.8080907@cs.au.dk> <4A6EBDA8.9080801@freegeek.org> <4A6EEED5.3090409@cs.au.dk> Message-ID: <4A6F8D41.5080801@freegeek.org> Tillmann Rendel wrote: > wren ng thornton wrote: > >>>> Thus, the forall keyword is serving as the type-level abstraction. >>> >>> What do you mean by "type-level abstraction" here? >> >> I mean an abstraction, as in a lambda-abstraction (aka a >> lambda-expression), at the type level. >> >>> [...] >> >> I'm not sure I follow what you mean. > > I mean that the forall keyword is *not* serving as the type-level > abstraction. > > There is a difference between abstraction (as in lambda abstraction) and > the type of abstractions (as in function types). In pure type systems, > we have two different binders for these different features: > > - lower-case lambda for abstraction (on all levels) > - upper-case Pi for the type of abstractions (on all levels) > > I find it highly confusing to say that forall denotes type-level > abstraction, because it does not denote abstraction at all. It rather > denotes the type of an abstraction, namely in Haskell, the type of > abstracting over types in terms. I view these as different sides of the same coin. There are two different senses of the "forall" keyword. There's the implicit Rank-1 quantifier, and then there's the Rank-N quantifier for polymorphic components. Your intuition is relying on the latter, whereas mine is relying on the former. The difference is similar to the difference between morphisms vs exponential objects in CCCs. We often find it convenient to elide the conversions between them, but they are in fact quite different. And if, at the term layer, functions can be silently lifted to/lowered from closures, then why not also at the type layer? While it is important to keep the ideas distinct, in practice we've found great utility in conflating the two faces of the coin. Why can't the type of abstractions be an abstraction of types? This is not currently the case in GHC, as you point out, but that does not demonstrate that the idea is unsound. This distributive transformation is used routinely in Conal Elliott's typeclass morphisms[1], Ralf Hinze's polyidiomatic lambda calculus[2], in HOAS (if you squint), and many other places where poly*ism spans multiple layers of the tower of interpretation. The symmetry between forall and /\ in System F is simply too great to write off without investigation. In any case, I think this discussion has veered far afield from the intent of my original footnote, which was simply to point out that the capital-lambda binder already has a canonical usage in System F (so we should not co-op it for type abstractions, without express intention). I have little invested in the current discussion, and the Cafe list doesn't really seem like the best venue to pursue it. If you have references you think would enlighten me, I'd happily pursue them. Otherwise, I think the best color for the bikeshed is purple :) [1] http://conal.net/blog/tag/type-class-morphism/ [2] http://www.comlab.ox.ac.uk/ralf.hinze/WG2.8//26/slides/ralf.pdf -- Live well, ~wren From ok at cs.otago.ac.nz Tue Jul 28 20:27:53 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Jul 28 20:09:07 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution In-Reply-To: <2f9b2d30907281005u5bff3db4h19c59290b166a9ef@mail.gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <2f9b2d30907281005u5bff3db4h19c59290b166a9ef@mail.gmail.com> Message-ID: <67D78F22-0690-4CED-B8C8-F2B6D7EE9BCE@cs.otago.ac.nz> On Jul 29, 2009, at 5:05 AM, Ryan Ingram wrote: > I see where you are going, but I'm not sure I agree. Let me give an > example from another language with this kind of resolution: C++. Right. That settles it: TDNR is a bad idea. Half fun and full earnest. I'm a fan of overloading as done in Ada, but the way C++ does it has always struck me as a mix of under-useful and over-complex, and my experience with it in practice has not been that marvellous. (C++ has far too many types that are _sort of_ compatible, but only sort of.) Interestingly, I've found that when I've thought I've wanted overloading in Haskell, what I've _really_ wanted is typeclasses, because they give me - far more confidence that my code is correct - far more _leverage_; "typeful programming" is amazing. From dan.doel at gmail.com Tue Jul 28 20:41:43 2009 From: dan.doel at gmail.com (Dan Doel) Date: Tue Jul 28 20:22:56 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution In-Reply-To: <67D78F22-0690-4CED-B8C8-F2B6D7EE9BCE@cs.otago.ac.nz> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <2f9b2d30907281005u5bff3db4h19c59290b166a9ef@mail.gmail.com> <67D78F22-0690-4CED-B8C8-F2B6D7EE9BCE@cs.otago.ac.nz> Message-ID: <200907282041.43227.dan.doel@gmail.com> On Tuesday 28 July 2009 8:27:53 pm Richard O'Keefe wrote: > Right. That settles it: TDNR is a bad idea. > Half fun and full earnest. > > I'm a fan of overloading as done in Ada, but the way > C++ does it has always struck me as a mix of under-useful > and over-complex, and my experience with it in practice > has not been that marvellous. (C++ has far too many > types that are _sort of_ compatible, but only sort of.) Amusingly enough, one of the major items going into C++0x was concepts, which are an effort to add type class-alike restrictions to C++'s current completely ad-hoc overloading. They were only recently dropped due to disagreements about certain details (I think I read that people couldn't agree whether programmers should be forced to declare the analogue of class instances, or whether the compiler should figure it out, but I haven't paid close attention, so that may be inaccurate). -- Dan From magicloud.magiclouds at gmail.com Tue Jul 28 21:14:24 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Jul 28 20:55:34 2009 Subject: [Haskell-cafe] runProcess does not care about hSetBuffering? Message-ID: <3bd412d40907281814g7320bf4bm49f302eee9fc1f22@mail.gmail.com> Hi, Code like: (or_, ow_) <- createPipe or <- fdToHandle or_ ow <- fdToHandle ow_ hSetBuffering ow LineBuffering hSetBuffering or LineBuffering h <- runProcess cmd [] Nothing Nothing Nothing (Just ow) Nothing In the cmd process, the ow is not LineBuffering.... -- ??????? ??????? From allbery at ece.cmu.edu Tue Jul 28 21:22:26 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Jul 28 21:04:15 2009 Subject: [Haskell-cafe] runProcess does not care about hSetBuffering? In-Reply-To: <3bd412d40907281814g7320bf4bm49f302eee9fc1f22@mail.gmail.com> References: <3bd412d40907281814g7320bf4bm49f302eee9fc1f22@mail.gmail.com> Message-ID: <8168D6B6-2EAF-456C-A55C-F4881197C879@ece.cmu.edu> On Jul 28, 2009, at 21:14 , Magicloud Magiclouds wrote: > (or_, ow_) <- createPipe > or <- fdToHandle or_ > ow <- fdToHandle ow_ > hSetBuffering ow LineBuffering > hSetBuffering or LineBuffering > h <- runProcess cmd [] Nothing Nothing Nothing (Just ow) Nothing > In the cmd process, the ow is not LineBuffering.... Buffering is not an attribute of a filehandle, but of the I/O library. There is no way for you to tell cmd how you want it to buffer, unless it has an option to do so (cat -u, tcpdump -l, etc.), although you can hint by using a pty instead of a pipe: many programs will switch to line buffering in that case, some will go unbuffered; usually, a pipe, FIFO, or ordinary file will be block buffered. -- 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/20090728/d7ccfe3f/PGP.bin From fernanbolando at mailc.net Tue Jul 28 21:32:20 2009 From: fernanbolando at mailc.net (Fernan Bolando) Date: Tue Jul 28 21:13:29 2009 Subject: [Haskell-cafe] Hugs used in circuit simulations code Message-ID: <1d5d51400907281832w32c96f99tb1d8ac2d73c01cc@mail.gmail.com> Hi all thanks to everyone that reviewed my code. The good news 1. I happy to say that it has become useful enough for me to use it in some matlab type caluculations. includes transient and dc op 2. The simple pivtoing code I added into the DSP Lu appears to be useable for this application. The bad news 1. If you dont use some strategy in simplifying circuits and use the simulator only, it would take a considerable amount of time to converge. A simple 10x10 non linear matrix will take 13 minutes. In a high-end circuit simulator this would have taken less than a second. What is everybodies expereience in speed difference between C and interpreted haskell? I am hoping to achieve at least 10x an equivalent C code. So if a 10x10 matrix takes 1 second for C I want it to take 10seconds for hugs. regards fernan -- http://www.fernski.com From ryani.spam at gmail.com Tue Jul 28 22:11:42 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jul 28 21:52:52 2009 Subject: [Haskell-cafe] Deepest polymorphic functor In-Reply-To: <24709303.post@talk.nabble.com> References: <24709303.post@talk.nabble.com> Message-ID: <2f9b2d30907281911n15ad4698q4cc705a4fc81d87f@mail.gmail.com> What would this do with instance Num a => Num [a] in scope? On Tue, Jul 28, 2009 at 3:51 PM, Eduard Sergeev wrote: > > I was wondering if it is possible to somehow change "deep" f_map from > http://okmij.org/ftp/Haskell/deepest-functor.lhs article in a such a way > that it would work not only for monotypes like in the provided example: > > test1 = f_map (+1) [[[1::Int,2,3]]] > > But for polymorphic types as well (e.g. behaves like simple map) so the > following line would compile as well: > > test1 = f_map (+1) [[[1,2,3]]] > > ? > > -- > View this message in context: http://www.nabble.com/Deepest-polymorphic-functor-tp24709303p24709303.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at web.de Tue Jul 28 22:54:45 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Jul 28 22:36:42 2009 Subject: [Haskell-cafe] Hugs used in circuit simulations code In-Reply-To: <1d5d51400907281832w32c96f99tb1d8ac2d73c01cc@mail.gmail.com> References: <1d5d51400907281832w32c96f99tb1d8ac2d73c01cc@mail.gmail.com> Message-ID: <200907290454.45351.daniel.is.fischer@web.de> Am Mittwoch 29 Juli 2009 03:32:20 schrieb Fernan Bolando: > What is everybodies expereience in speed difference between C and > interpreted haskell? That depends on what you do, unsurprisingly. But usually it's huge. A factor of several hundred is not uncommon, but 10-100 is the normal range (in my limited experience, I almost always compile). > I am hoping to achieve at least 10x an equivalent C code. Then you should definitely *not* run interpreted code, but compile it. With compiled code, I usually have a factor of less than 10, mostly 2-4, sometimes even better. But some things take longer in Haskell. > So if a 10x10 matrix takes 1 second for C I want it to take 10seconds for > hugs. Execution speed is not one of hugs' strongest points, so I'd be surprised. I recommend you get a GHC. > > regards > fernan Cheers, Daniel From dons at galois.com Tue Jul 28 23:39:01 2009 From: dons at galois.com (Don Stewart) Date: Tue Jul 28 23:22:17 2009 Subject: [Haskell-cafe] Hugs used in circuit simulations code In-Reply-To: <200907290454.45351.daniel.is.fischer@web.de> References: <1d5d51400907281832w32c96f99tb1d8ac2d73c01cc@mail.gmail.com> <200907290454.45351.daniel.is.fischer@web.de> Message-ID: <20090729033901.GA16138@whirlpool.galois.com> daniel.is.fischer: > Am Mittwoch 29 Juli 2009 03:32:20 schrieb Fernan Bolando: > > What is everybodies expereience in speed difference between C and > > interpreted haskell? Why are you using hugs? Hugs is slower than GHCi, which is around 30x slower on average than GHC, (measured a couple of years ago). Please use ghc -O2 if you care about performance! -- Don From dagit at codersbase.com Tue Jul 28 23:50:17 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue Jul 28 23:31:28 2009 Subject: [Haskell-cafe] Hugs used in circuit simulations code In-Reply-To: <1d5d51400907281832w32c96f99tb1d8ac2d73c01cc@mail.gmail.com> References: <1d5d51400907281832w32c96f99tb1d8ac2d73c01cc@mail.gmail.com> Message-ID: On Tue, Jul 28, 2009 at 6:32 PM, Fernan Bolando wrote: > Hi all > > thanks to everyone that reviewed my code. > > The good news > 1. I happy to say that it has become useful enough for me to use it in > some matlab type caluculations. includes transient and dc op > 2. The simple pivtoing code I added into the DSP Lu appears to be > useable for this application. > > The bad news > 1. If you dont use some strategy in simplifying circuits and use the > simulator only, it would take a considerable amount of time to > converge. > A simple 10x10 non linear matrix will take 13 minutes. In a high-end > circuit simulator this would have taken less than a second. > > What is everybodies expereience in speed difference between C and > interpreted haskell? I am hoping to achieve at least 10x an equivalent > C code. > So if a 10x10 matrix takes 1 second for C I want it to take 10seconds for > hugs. Use GHC's profiler. Figure out why and where the code is slow and then you can do something about it: http://book.realworldhaskell.org/read/profiling-and-optimization.html Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090728/377c9d14/attachment.html From wss at cs.nott.ac.uk Wed Jul 29 04:26:51 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Wed Jul 29 04:08:03 2009 Subject: [Haskell-cafe] ANN: The Monad.Reader - Issue 14 Message-ID: <1CF5B234-D964-4931-BE81-91BD92150BFE@cs.nott.ac.uk> Dear all, I am pleased to announce that a new issue of The Monad.Reader is now available: http://themonadreader.wordpress.com/ Issue 14 consists of the following three articles: * Fun with Morse Code by Heinrich Apfelmus * Hieroglyph 2: Purely Functional Information Graphics Revisited by Jefferson Heard * Lloyd Allison?s Corecursive Queues: Why Continuations Matter by Leon P Smith Please note that I've moved the Monad.Reader to a new Wordpress blog. You may want to update your bookmarks. 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 just yet, but expect a deadline late 2009. Wouter From jon.fairbairn at cl.cam.ac.uk Wed Jul 29 05:00:54 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Wed Jul 29 04:42:13 2009 Subject: [Haskell-cafe] Re: Need feedback on my Haskell code References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <404396ef0907280614o707e9e4rf7280bb948d18949@mail.gmail.com> <569734.60828.qm@web112506.mail.gq1.yahoo.com> Message-ID: CK Kashyap writes: > line' (x1, y1) (x2, y2) deltax deltay ystep isSteep error > | x1 == x2 = if isSteep then [(y1, x1)] else [(x1, y1)] > | isSteep = > (y1, x1) : > line' (newX, newY) (x2, y2) deltax deltay ystep isSteep newError > | otherwise = > (x1, y1) : > line' (newX, newY) (x2, y2) deltax deltay ystep isSteep newError > where newX = x1 + 1 > tempError = error + deltay > (newY, newError) > = if (2 * tempError) >= deltax then > (y1 + ystep, tempError - deltax) else (y1, tempError) It's early in my day, so I'm not very awake, but this looks like it could be an iterate or something like that, rather than explicit recursion. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From jon.fairbairn at cl.cam.ac.uk Wed Jul 29 05:06:27 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Wed Jul 29 04:47:50 2009 Subject: [Haskell-cafe] Re: Adding a field to a data record References: Message-ID: Henry Laxen writes: > It seems to me this should be easy, but I can't quite figure out > how to do it without a lot of typing. Here is the question: > > Suppose you have a data type like: > Data Foo = Foo { a :: Int, b :: Int, > ... many other fields ... > y :: Int } deriving (Eq, Read, Show, Typeable, Data) > > Now I would like to add a field z :: Int to the end of Foo. If > I have a ton of data out on disk, which I wrote with, say > writeFile "a.data" (show foo) -- where foo is a [Foo] say 1000 > long, I would like to get a new "a.data" file which has a new > z::Int field. One approach to this would be to temporarily redefine Foo data Foo = Foo { a :: Int, b :: Int, ... many other fields ... y :: Int } deriving (Eq, Read, Show, Typeable, Data) | NuFu {a :: Int, b :: Int, ... many other fields ... y :: Int, z :: Int} deriving (Eq, Read, Show, Typeable, Data) read the file, map Foo to NuFoo + whatever the initial value of z is and write it out again. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From jpm at cs.uu.nl Wed Jul 29 05:20:49 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Wed Jul 29 05:02:19 2009 Subject: [Haskell-cafe] Adding a field to a data record In-Reply-To: References: Message-ID: <52f14b210907290220o4105a3f7rbeb2129aa0b97bf4@mail.gmail.com> Hello Henry, The paper "A Lightweight Approach To Datatype-Generic Rewriting" [1] describes a way to generically add a constructor to any regular datatype using type-indexed datatypes [2]. A similar technique could be used to add a new field to each constructor. Then you get something like: data Foo > type Extended f = ... > |Extended Foo| represents your |Foo| datatype with an added |z| field of type |Int|. Since the underlying generic programming library used (regular [3]) has Template Haskell generation, you don't even have to write the generic representations for your many datatypes. (As far as I know, SYB does not mix with type-indexed datatypes.) Cheers, Pedro [1] Thomas van Noort, Alexey Rodriguez, Stefan Holdermans, Johan Jeuring, Bastiaan Heeren. A Lightweight Approach to Datatype-Generic Rewriting. Submitted to the Workshop on Generic Programming 2008. http://www.cs.uu.nl/wiki/bin/view/Alexey/ALightweightApproachToDatatype-GenericRewriting [2] http://www.iai.uni-bonn.de/~ralf/publications/SCP2004.pdf [3] http://www.cs.uu.nl/wiki/GenericProgramming/Regular On Tue, Jul 28, 2009 at 16:29, Henry Laxen wrote: > Dear Group, > > It seems to me this should be easy, but I can't quite figure out > how to do it without a lot of typing. Here is the question: > > Suppose you have a data type like: > Data Foo = Foo { a :: Int, b :: Int, > ... many other fields ... > y :: Int } deriving (Eq, Read, Show, Typeable, Data) > > Now I would like to add a field z :: Int to the end of Foo. If > I have a ton of data out on disk, which I wrote with, say > writeFile "a.data" (show foo) -- where foo is a [Foo] say 1000 > long, I would like to get a new "a.data" file which has a new > z::Int field. > > So far the only way I can think of is to make a new Data Foo1, > which includes the z::Int, read in a.data as a list of Foo, > write a function like: > > fooTofoo1 :: Foo -> Foo1 > fooTofoo1 xx = Foo1 {a = a xx, ... y = y xx, z = 1} > > then write the file back out, and perhaps use emacs to > query-replace all the Foo1's back to Foo's, add the z::Int field > back into Foo, and read it back. > > Please tell me there is a better way. Thanks in advance. > Best wishes, > Henry Laxen > > PS: > I have read syb1, and syb2 a couple of times now, but so far > haven't been able to connect it with this kind of problem. > > > > > _______________________________________________ > 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/20090729/50cf7ec9/attachment.html From ck_kashyap at yahoo.com Wed Jul 29 06:04:55 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Wed Jul 29 05:46:04 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> Message-ID: <906251.73778.qm@web112509.mail.gq1.yahoo.com> It worked like a charm!!! I'd need more time to get my head around "unfoldr" I'd appreciate it very much if you could explain this line "map maySwitch . unfoldr go $ (x1,y1,0)" I did not fully understand the "$" in that line - I tried putting parenthesis in various places to get rid of "$" but did not seem to work. Regards, Kashyap ________________________________ From: Chadda? Fouch? To: CK Kashyap Cc: haskell-cafe@haskell.org Sent: Tuesday, July 28, 2009 7:10:38 PM Subject: Re: [Haskell-cafe] Need feedback on my Haskell code On Tue, Jul 28, 2009 at 3:04 PM, CK Kashyap wrote: > Hi Everyone, > I managed to write up the line drawing function using the following links - > http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html > http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell > I tried to simplify your function a little bit : line :: Point -> Point -> [Point] line pa@(xa,ya) pb@(xb,yb) = map maySwitch . unfoldr go $ (x1,y1,0) where steep = abs (yb - ya) > abs (xb - xa) maySwitch = if steep then (\(x,y) -> (y,x)) else id [(x1,y1),(x2,y2)] = sort [maySwitch pa, maySwitch pb] deltax = x2 - x1 deltay = abs (y2 - y1) ystep = if y1 < y2 then 1 else -1 go (xTemp, yTemp, error) | xTemp > x2 = Nothing | otherwise = Just ((xTemp, yTemp), (xTemp + 1, newY, newError)) where tempError = error + deltay (newY, newError) = if (2*tempError) >= deltax then (yTemp+ystep,tempError-deltax) else (yTemp,tempError) I think it will be a bit better, tell me what you think ? -- Jeda? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090729/19712da3/attachment.html From lennart at augustsson.net Wed Jul 29 06:23:17 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Wed Jul 29 06:04:25 2009 Subject: [Haskell-cafe] Re: Adding a field to a data record In-Reply-To: References: <44549581-0DF7-426B-9AFF-321C50B04B15@cs.york.ac.uk> Message-ID: With the RecordWildCard extension you should be able to write newFoo Old.Foo{..} = New.Foo { .., z=1 } On Tue, Jul 28, 2009 at 3:47 PM, Henry Laxen wrote: > Malcolm Wallace cs.york.ac.uk> writes: > >> >> > and perhaps use emacs to >> > query-replace all the Foo1's back to Foo's >> >> At least this bit can be avoided easily enough, by using >> module qualification during the conversion process. >> >> ? ? ?module Original (Foo(..)) where >> ? ? ?data Foo = Foo { ... y :: Int } deriving ... >> >> ? ? ?module New (Foo(..)) where >> ? ? ?data Foo = Foo { ... y, z :: Int } deriving ... >> >> ? ? ?module Convert where >> ? ? ?import Original as Old >> ? ? ?import New as New >> ? ? ?newFoo :: Old.Foo -> New.Foo >> ? ? ?newFoo old{..} = New.Foo { a=a, b=b, ... z=1 } >> >> Finally rename module New. >> >> Regards, >> ? ? ?Malcolm >> > > Thanks Malcolm, yes, that keeps me out of emacs, but the part I would really > like to avoid is writing the New.Foo { a=a, b=b, ... z=1 } part, where the field > names are many, long, and varied. ?Yes, I could cut and paste, but I'm hoping > for a "better way." ?Thanks. > Best wishes, > Henry Laxen > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From Ben.Lippmeier at anu.edu.au Wed Jul 29 06:55:22 2009 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Wed Jul 29 06:36:36 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <20090727204137.GE14826@colquitt.org> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <89ca3d1f0907271010r359baf22q6a1e66a4d91fd8a2@mail.gmail.com> <20090727204137.GE14826@colquitt.org> Message-ID: <51CD42B5-E9D5-48DA-845C-E1E5CEA47878@anu.edu.au> On 28/07/2009, at 6:41 AM, John Dorsey wrote: > I'm assuming that name resolution is currently independent of type > inference, and will happen before type inference. With the proposal > this is > no longer true, and in general some partial type inference will have > to > happen before conflicting unqualified names are resolved. > > My worry is that the proposal will require a compliant compiler to > interweave name resolution and type inference iteratively. > > To my untrained eye it looks complicated and invasive, even without > the > mutually recursive case. Can anyone shed light on whether this > would be a > problem for, say, GHC? My experimental compiler DDC [1] implements TDNR almost exactly as given on the Haskell' wiki. Yes, you have to interweave name resolution with type inference, because there is no way to compute the binding dependency graph/call graph before type inference proper. This is discussed in section 3.5 of my thesis [2] (which is currently under examination). For DDC I used a constraint based inference algorithm to compute the binding dependency graph "on the fly", but I don't know how easy it would be to retrofit this method into GHC. Cheers, Ben. [1] http://www.haskell.org/haskellwiki/DDC [2] http://cs.anu.edu.au/people/Ben.Lippmeier/project/thesis/thesis-lippmeier-sub.pdf From johan.tibell at gmail.com Wed Jul 29 07:06:31 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Wed Jul 29 06:48:00 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <906251.73778.qm@web112509.mail.gq1.yahoo.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <906251.73778.qm@web112509.mail.gq1.yahoo.com> Message-ID: <90889fe70907290406l53fe3d0cq7878f6f34ed23246@mail.gmail.com> On Wed, Jul 29, 2009 at 12:04 PM, CK Kashyap wrote: > It worked like a charm!!! I'd need more time to get my head around > "unfoldr" > I'd appreciate it very much if you could explain this line "map maySwitch > . unfoldr go $ (x1,y1,0)" > I did not fully understand the "$" in that line - I tried putting > parenthesis in various places to get rid of "$" but did not seem to work. > (map maySwitch . unfoldr go) (x1,y1,0) should work. Cheers, Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090729/3e6d3404/attachment-0001.html From dav.vire+haskell at gmail.com Wed Jul 29 07:13:52 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Jul 29 06:55:00 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <906251.73778.qm@web112509.mail.gq1.yahoo.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <906251.73778.qm@web112509.mail.gq1.yahoo.com> Message-ID: <4c88418c0907290413g1b520c3bt52c9b5546b5216d7@mail.gmail.com> On Wed, Jul 29, 2009 at 12:04 PM, CK Kashyap wrote: > map maySwitch . unfoldr go $ (x1,y1,0) I'm not an expert and I might say things the wrong way or without the required rigor, so with this disclaimer here's my explanation : go calculates a step of the line, given the current coordinates and the error value it returns nothing if the line is done. unfoldr go calculates a list of lines coordinates, keeping calling go, and stopping when go returns nothing. maySwitch takes a coordinate, and switches the x and y values depending on the axis we're following map maySwitch does the same for the entire list of coordinates. when you compose the two, map maySwitch . unfoldr go is then a function that takes initial coordinates, makes a list of coordinates and may switch the x's and y's depending on the axis we're following. Now (.) takes two functions, namely map maySwitch and unfoldr go. If you don't write the $, what you actually mean is (map maySwitch) . ( unfoldr go (x1,y1,0)) this ( unfoldr go (x1,y1,0)) is not of the right type for (.) : it should take a parameter and return a value, but here it just returns a value. so you have to find a way to give (x1,y1,0) to the whole composed function map maySwitch . unfoldr go. the obvious way to do it is by writing: ( map maySwitch . unfoldr go ) (x1,y1,0 ) the $ is just a more readable way to write it : since $ binds with less priority, in map maySwitch . unfoldr go $ (x1,y1,0) what's on the right of $ will be applied to what's on the left David. From jeanphilippe.bernardy at gmail.com Wed Jul 29 08:47:04 2009 From: jeanphilippe.bernardy at gmail.com (Jean-Philippe Bernardy) Date: Wed Jul 29 08:28:26 2009 Subject: [Haskell-cafe] RFC: Unicode support in Alex Message-ID: Hello, I have modified the Alex lexer generator to support unicode. The general idea is that the state-machine works on the UTF8 representation of the text. I submit my work here for review in order to off-load the maintainer (Simon Marlow) as far as possible. The prototype is available on github: git://github.com/jyp/Alex.git Be sure to * checkout the "utf8" branch (so "git diff master" shows the changes) * Do a 2-stage bootstrapping before testing Caveats: * The generated code depends on some utf8 packages; * There is no attempt to fix the bytestring-based wrappers; * Left-context recognition is not table-based any more; * Presence of debug code. Bug reports, comments, and especially patches are welcome :) Thanks, -- JP From waldmann at imn.htwk-leipzig.de Wed Jul 29 08:54:04 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Wed Jul 29 08:35:14 2009 Subject: [Haskell-cafe] Re: Re: Proposal: TypeDirectedNameResolution Message-ID: <4A70466C.5050809@imn.htwk-leipzig.de> While the discussion centers around overload resolution let me re-iterate a point that (e.g.,) Java does nicely: for their "x.f", if x :: T, then you write .f (unqualified) instead of .T.f (qualified), even if you needed qualification to declare the type of x, as in "foo.bar.T x;" This requires a mixture of type checking (for x) and name resolution (for f), which probably wouldn't fit with Haskell's current module and type system. Too bad ... Best - Johannes. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 257 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090729/71d523b9/signature.bin From psujkov at gmail.com Wed Jul 29 10:27:07 2009 From: psujkov at gmail.com (Paul Sujkov) Date: Wed Jul 29 10:08:15 2009 Subject: [Haskell-cafe] [Haskell Cafe] Data construction: how to avoid boilerplate code? Message-ID: <9760562b0907290727n44f49252jbd3a5a4c142da69a@mail.gmail.com> Hi haskellers, I have a datatype of this sort: data Type = Status | Message | Warning | Error | StepIn | StepOut deriving (Eq, Show) and (at this moment) two fabric-like functions: makeType :: String -> Type makeType c = case c of "-$-" -> Status "-M-" -> Message "-W-" -> Warning "-E-" -> Error "->>" -> StepIn "<<-" -> StepOut otherwise -> error "Uknown Message Type" deduceType :: Integer -> Type deduceType n = case n of 240 -> Status 64 -> Message 32 -> Warning 8 -> StepOut 4 -> StepIn 2 -> Error otherwise -> error "Unknown Message Type" how can I avoid boilerplate code at this stage? The thing that I really need is some n-type constructor, kind of a fabric for a variety of types with the possibility to add them on the fly (I have simple Integer and String here, but they could be much more sophisticated). I don't need the possibility to unpack the original value (e.g. "-$-" or 240) once the Type is created - in this case I can always have some sort of mapping to deduce it at any moment, so it will be redundant to carry it through the code explicitly The example is rather short and simple, but I have some more places in code, where the same problem is observed. Is there any generic solution? Thanks in advance -- Regards, Paul Sujkov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090729/0b2a7ede/attachment.html From felipe.lessa at gmail.com Wed Jul 29 12:55:25 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Jul 29 12:43:40 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <200907291826.30307.Sven.Panne@aedion.de> References: <200907291826.30307.Sven.Panne@aedion.de> Message-ID: <20090729165525.GA23329@kira.casa> On Wed, Jul 29, 2009 at 06:26:30PM +0200, Sven Panne wrote: > Apart from that, a bug in vertexAttribPointer has been fixed. ...and the new ObjectName, StateVar and Tensor packages are being used, and this is great! Thanks for the release. -- Felipe. From lrpalmer at gmail.com Wed Jul 29 13:58:44 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jul 29 13:39:52 2009 Subject: [Haskell-cafe] [Haskell Cafe] Data construction: how to avoid boilerplate code? In-Reply-To: <9760562b0907290727n44f49252jbd3a5a4c142da69a@mail.gmail.com> References: <9760562b0907290727n44f49252jbd3a5a4c142da69a@mail.gmail.com> Message-ID: <7ca3f0160907291058q3b961195q67b47d04423718cf@mail.gmail.com> On Wed, Jul 29, 2009 at 6:27 AM, Paul Sujkov wrote: > Hi haskellers, > > I have a datatype of this sort: > > data Type = Status > ????????? | Message > ????????? | Warning > ????????? | Error > ????????? | StepIn > ????????? | StepOut deriving (Eq, Show) > > and (at this moment) two fabric-like functions: > > makeType :: String -> Type > makeType c = case c of > ?????????????? "-$-"?????? -> Status > ?????????????? "-M-"?????? -> Message > ?????????????? "-W-"?????? -> Warning > ?????????????? "-E-"?????? -> Error > ?????????????? "->>"?????? -> StepIn > ?????????????? "<<-"?????? -> StepOut > ?????????????? otherwise?? -> error "Uknown Message Type" > > deduceType :: Integer -> Type > deduceType n = case n of > ???????????????? 240?????? -> Status > ???????????????? 64??????? -> Message > ???????????????? 32??????? -> Warning > ???????????????? 8???????? -> StepOut > ???????????????? 4???????? -> StepIn > ???????????????? 2???????? -> Error > ???????????????? otherwise -> error "Unknown Message Type" > > how can I avoid boilerplate code at this stage? The thing that I really need > is some n-type constructor, kind of a fabric for a variety of types with the > possibility to add them on the fly (I have simple Integer and String here, > but they could be much more sophisticated). I don't need the possibility to > unpack the original value (e.g. "-$-" or 240) once the Type is created - in > this case I can always have some sort of mapping to deduce it at any moment, > so it will be redundant to carry it through the code explicitly I am not sure what you're asking. Are you saying that what you have written is boilerplate? What code are you writing that could be automatically deduced with enough smartness? Give an example of what you might like the solution to look like. Luke > The example is rather short and simple, but I have some more places in code, > where the same problem is observed. Is there any generic solution? Thanks in > advance > > -- > Regards, Paul Sujkov > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lrpalmer at gmail.com Wed Jul 29 14:28:15 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jul 29 14:09:22 2009 Subject: [Haskell-cafe] [Haskell Cafe] Data construction: how to avoid boilerplate code? In-Reply-To: <9760562b0907291115t4dcca218p2ca66f9dd1cff1df@mail.gmail.com> References: <9760562b0907290727n44f49252jbd3a5a4c142da69a@mail.gmail.com> <7ca3f0160907291058q3b961195q67b47d04423718cf@mail.gmail.com> <9760562b0907291115t4dcca218p2ca66f9dd1cff1df@mail.gmail.com> Message-ID: <7ca3f0160907291128i33d6185bl8bfae003afc66ec0@mail.gmail.com> On Wed, Jul 29, 2009 at 10:15 AM, Paul Sujkov wrote: > Hi Luke, > > I'm not pretty sure. The thing I don't like is the need to copy-and-paste > all the code with enumeration constructors. So, now I have two types to make > Type data from, but they could be many, so I'll have many almost identical > makeTypeFromFoo-functions. The thing I need is something like (*): > > makeType :: ? -> Type > makeType c = case c of > ?????????????? ("-$-" or 240) ????? -> Status > ?????????????? ("-M-" or 64) ????? -> Message > ?????????????? ("-W-" or 32) ????? -> Warning Well, you could write a helper like this: matchType :: (Eq a) => (a,a,a) -> a -> Type matchType (status,message,warning) x | x == status = Status | x == message = Message | x == warning = Warning To reduce the size of your specifications: makeTypeStr = matchType ("-$-", "-M-", "-W-") makeTypeInt = matchType (240, 64, 32) There are trade-offs to doing something like this. It's smaller, but harder to read as specification. But, because it uses a tuple, it will catch you if you add a new case but forget to add it to one of the makeType*s (providing you remember to change matchType). What you're asking for puts all the conversions in the same place, which forbids them from being split out, decoupled, and modularlized. What if, instead of simple values, you had a more involved parser for these things? Even though it's kind of verbose, I think what you already have is fine. You do have to repeat the names, but it is still content code, and the relationship of the content to the names is explicit. You might find tables like this in a user's manual for your software... Luke > > then I have all this fabric code in one place. I could use something like > Either for this example, but it will scale fine up to two types to build > value from; while I want to have arbitrary numbers of them > > And from another point, it would be great if I could avoid doubling the code > for datatype declaration with empty (no parameter) constructors, and actual > "constructing" code from the different types. So it could look somewhat > alike this (pseudo-code) (**): > > data Type = Status <-- (String "-$-", Integer 240) > ????????? | Message <-- (String "-M-", Integer 64) > ????????? | Warning <-- (String "-W-", Integer 32) > > however, I'm not sure this one is really needed. Something for the (*) is > much more interesting > > 2009/7/29 Luke Palmer >> >> On Wed, Jul 29, 2009 at 6:27 AM, Paul Sujkov wrote: >> > Hi haskellers, >> > >> > I have a datatype of this sort: >> > >> > data Type = Status >> > ????????? | Message >> > ????????? | Warning >> > ????????? | Error >> > ????????? | StepIn >> > ????????? | StepOut deriving (Eq, Show) >> > >> > and (at this moment) two fabric-like functions: >> > >> > makeType :: String -> Type >> > makeType c = case c of >> > ?????????????? "-$-"?????? -> Status >> > ?????????????? "-M-"?????? -> Message >> > ?????????????? "-W-"?????? -> Warning >> > ?????????????? "-E-"?????? -> Error >> > ?????????????? "->>"?????? -> StepIn >> > ?????????????? "<<-"?????? -> StepOut >> > ?????????????? otherwise?? -> error "Uknown Message Type" >> > >> > deduceType :: Integer -> Type >> > deduceType n = case n of >> > ???????????????? 240?????? -> Status >> > ???????????????? 64??????? -> Message >> > ???????????????? 32??????? -> Warning >> > ???????????????? 8???????? -> StepOut >> > ???????????????? 4???????? -> StepIn >> > ???????????????? 2???????? -> Error >> > ???????????????? otherwise -> error "Unknown Message Type" >> > >> > how can I avoid boilerplate code at this stage? The thing that I really >> > need >> > is some n-type constructor, kind of a fabric for a variety of types with >> > the >> > possibility to add them on the fly (I have simple Integer and String >> > here, >> > but they could be much more sophisticated). I don't need the possibility >> > to >> > unpack the original value (e.g. "-$-" or 240) once the Type is created - >> > in >> > this case I can always have some sort of mapping to deduce it at any >> > moment, >> > so it will be redundant to carry it through the code explicitly >> >> I am not sure what you're asking. ?Are you saying that what you have >> written is boilerplate? ?What code are you writing that could be >> automatically deduced with enough smartness? >> >> Give an example of what you might like the solution to look like. >> >> Luke >> >> > The example is rather short and simple, but I have some more places in >> > code, >> > where the same problem is observed. Is there any generic solution? >> > Thanks in >> > advance >> > >> > -- >> > Regards, Paul Sujkov >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> > > > > > -- > Regards, Paul Sujkov > From jvranish at gmail.com Wed Jul 29 19:42:32 2009 From: jvranish at gmail.com (Job Vranish) Date: Wed Jul 29 19:23:40 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: <910ddf450907280744j6e1b7635kdb1c68760718ac44@mail.gmail.com> References: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> <910ddf450907280744j6e1b7635kdb1c68760718ac44@mail.gmail.com> Message-ID: lol, yep you're right. I'd assumed the haskell platform shipped with the latest parsec, when in fact it does not :) my bad... However, I fixed the cabal issue by installing ghc 6.10.3 and rebuilding the haskell platform. Apparently there is either a compiler issue or incompatibility with 6.10.4 that causes the cabal: : openFile: does not exist (No such file or directory) error. - Job On Tue, Jul 28, 2009 at 10:44 AM, Thomas Hartman wrote: > did you verify parsec-2.1.0.1 exports > > Text.Parsec.Language > > ? > > This might be a parsec 2 versus parsec 3 issue > > ghc-pkg describe parsec-2.1.0.1 > > should tell you the answer to that. > > > > 2009/7/27 Job Vranish : > > I tried updating to ghc-6.10.4 and have exactly the same error. > > Also ghc doesn't seem to be able to find any of the haskell platform > > packages, even though it ghc-pkg finds them just fine. > > > > For example (trimmed for brevity): > > > > ghc-pkg list > > /usr/local/lib/ghc-6.10.4/./package.conf: > > Cabal-1.6.0.3, > > ... > > parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, > > ... > > > > ghci -v readModel.hs > > GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help > > Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98, stage 2 booted > by > > GHC version 6.8.2 > > Using package config file: /usr/local/lib/ghc-6.10.4/./package.conf > > ... > > > > readModel.hs:9:7: > > Could not find module `Text.Parsec.Language': > > locations searched: > > Text/Parsec/Language.hs > > Text/Parsec/Language.lhs > > Failed, modules loaded: none. > > ... > > > > > > ghc-pkg finds parsec, but ghci can't find it. > > > > And if I do a cabal -v3 update I get a: > > cabal: 3: openFile: does not exist (No such file or directory) > > > > Anybody figured it out? > > > > - Job Vranish > > > > On Fri, Jul 17, 2009 at 11:17 AM, Thomas Hartman > wrote: > >> > >> cabal -v3 update > >> > >> will give you a more verbose version of what is going wrong. > >> > >> cabal --help > >> > >> regrettably, cabal --help doesn't tell you this but there is always > >> the man page I suppose. > >> > >> 2009/7/16 Tony Hannan : > >> > Hello, > >> > > >> > I'm on Ubuntu 8.10. > >> > I installed ghc 6.10.4 (from binary package: > >> > ghc-6.10.4-i386-unknown-linux-n.tar.bz2). > >> > I installed haskell-platform-2009.2.0.1 (from source package: > >> > haskell-platform-2009.2.0.1.tar.gz). It contains cabal-install-0.6.2. > >> > > >> > Then when I run "cabal update", I get the following error: > >> > cabal: : openFile: does not exist (No such file or directory) > >> > > >> > Any ideas? > >> > > >> > Thanks, > >> > Tony > >> > > >> > _______________________________________________ > >> > Libraries mailing list > >> > Libraries@haskell.org > >> > http://www.haskell.org/mailman/listinfo/libraries > >> > > >> > > >> _______________________________________________ > >> 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/20090729/5913f5a9/attachment.html From RafaelGCPP.Linux at gmail.com Wed Jul 29 21:17:23 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Wed Jul 29 20:58:29 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <20090729165525.GA23329@kira.casa> References: <200907291826.30307.Sven.Panne@aedion.de> <20090729165525.GA23329@kira.casa> Message-ID: <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> Just a heads up: I did a cabal install Tensor on my Ubuntu box, and got the following message: src/Data/Tensor.hs:333:18: Not in scope: `mapAccumL' I will investigate a little more and let you know. On Wed, Jul 29, 2009 at 13:55, Felipe Lessa wrote: > On Wed, Jul 29, 2009 at 06:26:30PM +0200, Sven Panne wrote: > > Apart from that, a bug in vertexAttribPointer has been fixed. > > ...and the new ObjectName, StateVar and Tensor packages are being > used, and this is great! Thanks for the release. > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090729/c9758e7e/attachment.html From RafaelGCPP.Linux at gmail.com Wed Jul 29 21:24:23 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Wed Jul 29 21:05:29 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> References: <200907291826.30307.Sven.Panne@aedion.de> <20090729165525.GA23329@kira.casa> <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> Message-ID: <351ff25e0907291824g68de211id52c58939c2d275@mail.gmail.com> That was quick! mapAccumL was added to Data.Traversable in package base-4. GHC 6.8.2 uses base-3... I think I will be forced to upgrade my GHC by hand... I just can't stand 6.8.2 anymore... On Wed, Jul 29, 2009 at 22:17, Rafael Gustavo da Cunha Pereira Pinto < RafaelGCPP.Linux@gmail.com> wrote: > Just a heads up: > > I did a cabal install Tensor on my Ubuntu box, and got the following > message: > > src/Data/Tensor.hs:333:18: Not in scope: `mapAccumL' > > I will investigate a little more and let you know. > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090729/9d4ca9fc/attachment.html From felipe.lessa at gmail.com Wed Jul 29 21:47:03 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Jul 29 21:28:14 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <351ff25e0907291824g68de211id52c58939c2d275@mail.gmail.com> References: <200907291826.30307.Sven.Panne@aedion.de> <20090729165525.GA23329@kira.casa> <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> <351ff25e0907291824g68de211id52c58939c2d275@mail.gmail.com> Message-ID: <20090730014703.GA19555@kira.casa> On Wed, Jul 29, 2009 at 10:24:23PM -0300, Rafael Gustavo da Cunha Pereira Pinto wrote: > mapAccumL was added to Data.Traversable in package base-4. GHC 6.8.2 uses > base-3... But this means that Tensor's dependencies should be on base >= 4, not 3. -- Felipe. From noteed at gmail.com Thu Jul 30 03:06:50 2009 From: noteed at gmail.com (minh thu) Date: Thu Jul 30 02:55:31 2009 Subject: [Haskell-cafe] [Haskell Cafe] Data construction: how to avoid boilerplate code? In-Reply-To: <7ca3f0160907291128i33d6185bl8bfae003afc66ec0@mail.gmail.com> References: <9760562b0907290727n44f49252jbd3a5a4c142da69a@mail.gmail.com> <7ca3f0160907291058q3b961195q67b47d04423718cf@mail.gmail.com> <9760562b0907291115t4dcca218p2ca66f9dd1cff1df@mail.gmail.com> <7ca3f0160907291128i33d6185bl8bfae003afc66ec0@mail.gmail.com> Message-ID: <40a414c20907300006h1877270bnb53e480716554737@mail.gmail.com> 2009/7/29 Luke Palmer : > On Wed, Jul 29, 2009 at 10:15 AM, Paul Sujkov wrote: >> Hi Luke, >> >> I'm not pretty sure. The thing I don't like is the need to copy-and-paste >> all the code with enumeration constructors. So, now I have two types to make >> Type data from, but they could be many, so I'll have many almost identical >> makeTypeFromFoo-functions. The thing I need is something like (*): >> >> makeType :: ? -> Type >> makeType c = case c of >> ("-$-" or 240) -> Status >> ("-M-" or 64) -> Message >> ("-W-" or 32) -> Warning > > Well, you could write a helper like this: > > matchType :: (Eq a) => (a,a,a) -> a -> Type > matchType (status,message,warning) x > | x == status = Status > | x == message = Message > | x == warning = Warning > > To reduce the size of your specifications: > > makeTypeStr = matchType ("-$-", "-M-", "-W-") > makeTypeInt = matchType (240, 64, 32) > > There are trade-offs to doing something like this. It's smaller, but > harder to read as specification. But, because it uses a tuple, it > will catch you if you add a new case but forget to add it to one of > the makeType*s (providing you remember to change matchType). > > What you're asking for puts all the conversions in the same place, > which forbids them from being split out, decoupled, and modularlized. > What if, instead of simple values, you had a more involved parser for > these things? > > Even though it's kind of verbose, I think what you already have is > fine. You do have to repeat the names, but it is still content code, > and the relationship of the content to the names is explicit. You > might find tables like this in a user's manual for your software... Hi, Maybe two simple association lists would be acceptable ? Cheers, Thu From qdunkan at gmail.com Thu Jul 30 04:33:47 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Jul 30 04:23:07 2009 Subject: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with qualified names? In-Reply-To: <5ab17e790907241648x77999baft925cac5d9af116d7@mail.gmail.com> References: <2518b95d0907171556l3745912na56481698094b2dd@mail.gmail.com> <638ABD0A29C8884A91BC5FB5C349B1C34B7FA6CABB@EA-EXMSG-C334.europe.corp.microsoft.com> <5ab17e790907241648x77999baft925cac5d9af116d7@mail.gmail.com> Message-ID: <2518b95d0907300133m6defcba2yca9f7ea77551bae2@mail.gmail.com> On Fri, Jul 24, 2009 at 4:48 PM, Iavor Diatchki wrote: > Hello, > I think that Even refers to an example like this: ... Yeah, that's exactly what I meant, sorry if it wasn't clear initially. From barsoap at web.de Thu Jul 30 05:20:14 2009 From: barsoap at web.de (Achim Schneider) Date: Thu Jul 30 04:59:54 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <20090730112014.2984d4f5@solaris> Jason Dagit wrote: > My biggest fear is that of usability. > > If I understand you correctly, then as you change module imports you > change the meaning of the code in potentially non-obvious ways. So > this isn't too different than using unqualified imports and flipping > between two modules that export the same function. Except that as > you increase the 'automatic'ness of it, it has the potential to trip > up people. > My biggest fear is seeing it actually implemented as a language switch, resulting in chaotic inferance behaviour as soon as imports change. I think the Right Place to do this is on the editor/ide level: Help the programmer to use the right function by scanning through types, leave the display uncluttered (but make precise information about what function is referenced easily available) and save the source code fully qualified. Source code is not only made for human consumption but also as fodder for batch processes, re-compilation with other compilers etc, so we shouldn't put anything into it that can break way too easily, be it because type inferance changes in subtle ways or some library merely happens to export an additional function. Thus is the way of Malbolge, be ye warned, ye who construeth isomorphic brainb0rkz0rage. >| Book 4 - Coding >| >| Thus spake the master programmer: >| >| ``A well-written program is its own heaven; a poorly-written program >| is its own hell.'' >| [...] >| A program should follow the `Law of Least Astonishment'. What is this >| law? It is simply that the program should always respond to the user >| in the way that astonishes him least. >| >| A program, no matter how complex, should act as a single unit. The >| program should be directed by the logic within rather than by outward >| appearances. >| >| If the program fails in these requirements, it will be in a state of >| disorder and confusion. The only way to correct this is to rewrite >| the program. >| [...] etc. pp. qed. -- (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 mike.pentney at physics.org Thu Jul 30 06:52:48 2009 From: mike.pentney at physics.org (Mike Pentney) Date: Thu Jul 30 06:33:54 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: References: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> <910ddf450907280744j6e1b7635kdb1c68760718ac44@mail.gmail.com> Message-ID: <4A717B80.3060207@physics.org> I had a similar problem (on Ubuntu Incontinent Ibex). I'd previously installed ghc 6.8.x, and (among other things) cabal. When I decided to upgrade to the Haskell platform, I deleted ghc but not my original cabal installation. When I got the error, I deleted my (old) copy of ~/.cabal/config and it seemed to fix the problem. I'd assumed something in the config file was pointing to a file or directory that had been removed when I uninstalled ghc 6.8.x... HTH Mike. Job Vranish wrote: > lol, yep you're right. I'd assumed the haskell platform shipped with the > latest parsec, when in fact it does not :) my bad... > > However, I fixed the cabal issue by installing ghc 6.10.3 and rebuilding > the haskell platform. Apparently there is either a compiler issue or > incompatibility with 6.10.4 that causes the cabal: : openFile: does not > exist (No such file or directory) error. > > - Job > > On Tue, Jul 28, 2009 at 10:44 AM, Thomas Hartman > wrote: > > did you verify parsec-2.1.0.1 exports > > Text.Parsec.Language > > ? > > This might be a parsec 2 versus parsec 3 issue > > ghc-pkg describe parsec-2.1.0.1 > > should tell you the answer to that. > > > > 2009/7/27 Job Vranish >: > > I tried updating to ghc-6.10.4 and have exactly the same error. > > Also ghc doesn't seem to be able to find any of the haskell platform > > packages, even though it ghc-pkg finds them just fine. > > > > For example (trimmed for brevity): > > > > ghc-pkg list > > /usr/local/lib/ghc-6.10.4/./package.conf: > > Cabal-1.6.0.3, > > ... > > parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, > > ... > > > > ghci -v readModel.hs > > GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help > > Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98, stage 2 > booted by > > GHC version 6.8.2 > > Using package config file: /usr/local/lib/ghc-6.10.4/./package.conf > > ... > > > > readModel.hs:9:7: > > Could not find module `Text.Parsec.Language': > > locations searched: > > Text/Parsec/Language.hs > > Text/Parsec/Language.lhs > > Failed, modules loaded: none. > > ... > > > > > > ghc-pkg finds parsec, but ghci can't find it. > > > > And if I do a cabal -v3 update I get a: > > cabal: 3: openFile: does not exist (No such file or directory) > > > > Anybody figured it out? > > > > - Job Vranish > > > > On Fri, Jul 17, 2009 at 11:17 AM, Thomas Hartman > > wrote: > >> > >> cabal -v3 update > >> > >> will give you a more verbose version of what is going wrong. > >> > >> cabal --help > >> > >> regrettably, cabal --help doesn't tell you this but there is always > >> the man page I suppose. > >> > >> 2009/7/16 Tony Hannan >: > >> > Hello, > >> > > >> > I'm on Ubuntu 8.10. > >> > I installed ghc 6.10.4 (from binary package: > >> > ghc-6.10.4-i386-unknown-linux-n.tar.bz2). > >> > I installed haskell-platform-2009.2.0.1 (from source package: > >> > haskell-platform-2009.2.0.1.tar.gz). It contains > cabal-install-0.6.2. > >> > > >> > Then when I run "cabal update", I get the following error: > >> > cabal: : openFile: does not exist (No such file or directory) > >> > > >> > Any ideas? > >> > > >> > Thanks, > >> > Tony > >> > > >> > _______________________________________________ > >> > Libraries mailing list > >> > Libraries@haskell.org > >> > http://www.haskell.org/mailman/listinfo/libraries > >> > > >> > > >> _______________________________________________ > >> 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 ck_kashyap at yahoo.com Thu Jul 30 07:11:07 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Thu Jul 30 06:52:13 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <4c88418c0907290413g1b520c3bt52c9b5546b5216d7@mail.gmail.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <906251.73778.qm@web112509.mail.gq1.yahoo.com> <4c88418c0907290413g1b520c3bt52c9b5546b5216d7@mail.gmail.com> Message-ID: <78997.29492.qm@web112511.mail.gq1.yahoo.com> Thanks David Regards, Kashyap ________________________________ From: david48 To: CK Kashyap Cc: Chadda? Fouch? ; haskell-cafe@haskell.org Sent: Wednesday, July 29, 2009 4:43:52 PM Subject: Re: [Haskell-cafe] Need feedback on my Haskell code On Wed, Jul 29, 2009 at 12:04 PM, CK Kashyap wrote: > map maySwitch . unfoldr go $ (x1,y1,0) I'm not an expert and I might say things the wrong way or without the required rigor, so with this disclaimer here's my explanation : go calculates a step of the line, given the current coordinates and the error value it returns nothing if the line is done. unfoldr go calculates a list of lines coordinates, keeping calling go, and stopping when go returns nothing. maySwitch takes a coordinate, and switches the x and y values depending on the axis we're following map maySwitch does the same for the entire list of coordinates. when you compose the two, map maySwitch . unfoldr go is then a function that takes initial coordinates, makes a list of coordinates and may switch the x's and y's depending on the axis we're following. Now (.) takes two functions, namely map maySwitch and unfoldr go. If you don't write the $, what you actually mean is (map maySwitch) . ( unfoldr go (x1,y1,0)) this ( unfoldr go (x1,y1,0)) is not of the right type for (.) : it should take a parameter and return a value, but here it just returns a value. so you have to find a way to give (x1,y1,0) to the whole composed function map maySwitch . unfoldr go. the obvious way to do it is by writing: ( map maySwitch . unfoldr go ) (x1,y1,0 ) the $ is just a more readable way to write it : since $ binds with less priority, in map maySwitch . unfoldr go $ (x1,y1,0) what's on the right of $ will be applied to what's on the left David. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090730/1ef59336/attachment.html From cgibbard at gmail.com Thu Jul 30 09:18:46 2009 From: cgibbard at gmail.com (Cale Gibbard) Date: Thu Jul 30 08:59:51 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B03B9F826@ELON17P32001A.csfb.cs-group.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B03B9F826@ELON17P32001A.csfb.cs-group.com> Message-ID: <89ca3d1f0907300618m464ea247v40878b2c7b3e2f0c@mail.gmail.com> 2009/7/28 Sittampalam, Ganesh : > Cale Gibbard wrote: > >> There was a great related idea on #haskell the other day: Make >> explicit qualification unnecessary whenever there is a *unique* >> choice of module qualifications from those imported which would make >> the expression typecheck. Ambiguities would still need to be >> qualified, but I feel that this would eliminate 99% of all ugly >> qualified names from code. It would be especially good in the case of >> infix operators, which as far as I know, nobody actually enjoys >> qualifying explicitly. >> > [...] >> What do people think of this idea? Personally, it really annoys me >> whenever I'm forced to give explicit module qualifications, and I >> think this would really help. It would also subsume the >> DisambiguateRecordFields extension rather handily. > > I think this idea would severely damage compositionality. One example of > this is that it would make it substantially less likely that > subexpressions could be abstracted into a separate declaration without > giving a type signature to fix the type of the new declaration. > > Ganesh Ah, now that does seem a rather good point, the worry being that generalisation happens at the top of that new declaration, thereby suddenly making more than one of the options typecheck, even though the function/value being defined is still used at the appropriate type. That might be enough of a hindrance to kill the idea, yeah, though I wonder exactly how often it would happen relative to the annoyance of always having to make the obvious qualifications. It would be nice to have as an extension at least, I think, to get a sense for this. I wouldn't advocate putting anything in a standard which we haven't actually tried of course. (However, I also think we should also have a bit less respect in regard to keeping things in line with the standard, so long as a compliant implementation exists...) - Cale From Eduard.Sergeev at gmail.com Thu Jul 30 18:10:21 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Thu Jul 30 17:51:24 2009 Subject: [Haskell-cafe] Deepest polymorphic functor In-Reply-To: <2f9b2d30907281911n15ad4698q4cc705a4fc81d87f@mail.gmail.com> References: <24709303.post@talk.nabble.com> <2f9b2d30907281911n15ad4698q4cc705a4fc81d87f@mail.gmail.com> Message-ID: <24748175.post@talk.nabble.com> Ryan Ingram wrote: > > What would this do with > > instance Num a => Num [a] > > in scope? > It should work not only for Num a anyway (like normal Functor would do) but if you could give me an example, how exactly could I use Num a here... -- View this message in context: http://www.nabble.com/Deepest-polymorphic-functor-tp24709303p24748175.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From Eduard.Sergeev at gmail.com Thu Jul 30 18:16:30 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Thu Jul 30 17:57:33 2009 Subject: [Haskell-cafe] Deepest polymorphic functor In-Reply-To: <24709303.post@talk.nabble.com> References: <24709303.post@talk.nabble.com> Message-ID: <24748240.post@talk.nabble.com> PS In regards to the original http://okmij.org/ftp/Haskell/deepest-functor.lhs Am I right that the following code from the sample: class IsCollection t coll | t -> coll instance IsCollection (m a) (m ()) instance TypeCast Atom coll => IsCollection t coll class TypeCast a b | a -> b, b->a where typeCast :: a -> b class TypeCast' t a b | t a -> b, t b -> a where typeCast' :: t->a->b class TypeCast'' t a b | t a -> b, t b -> a where typeCast'' :: t->a->b instance TypeCast' () a b => TypeCast a b where typeCast x = typeCast' () x instance TypeCast'' t a b => TypeCast' t a b where typeCast' = typeCast'' instance TypeCast'' () a a where typeCast'' _ x = x may now be reduced to: class IsCollection t coll | t -> coll instance IsCollection (m a) (m ()) instance (Atom ~ coll) => IsCollection t coll ? -- View this message in context: http://www.nabble.com/Deepest-polymorphic-functor-tp24709303p24748240.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ketil at malde.org Thu Jul 30 18:56:28 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Jul 30 18:37:30 2009 Subject: [Haskell-cafe] Proposal: TypeDirectedNameResolution In-Reply-To: <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> (Cale Gibbard's message of "Mon\, 27 Jul 2009 12\:29\:45 -0400") References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> Message-ID: <87ljm54w6b.fsf@malde.org> Cale Gibbard writes: > There was a great related idea on #haskell the other day: Make > explicit qualification unnecessary whenever there is a *unique* choice > of module qualifications from those imported which would make the > expression typecheck. [...] > This would mean that if we had, say, Data.List, Data.Map and Data.Set > imported, and there was an occurrence of insert that happened to be > applied to a couple of values and then something known to be a Map, [...] > What do people think of this idea? Personally, it really annoys me > whenever I'm forced to give explicit module qualifications, and I > think this would really help. It would also subsume the > DisambiguateRecordFields extension rather handily. My favorite annoyance is repeated import lines for each library just to be able to use some unique identifiers unqualified, e.g.: import qualified Data.ByteString as B import Data.ByteString (ByteString) import qualified Data.Map as M import Data.Map (Map) and so on. I'm all for it, if for no other reason, then just to get rid of this. But I agree about the syntax: leave the dot out of it. -k -- If I haven't seen further, it is by standing in the footprints of giants From RafaelGCPP.Linux at gmail.com Thu Jul 30 19:31:23 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Thu Jul 30 19:12:28 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <20090730014703.GA19555@kira.casa> References: <200907291826.30307.Sven.Panne@aedion.de> <20090729165525.GA23329@kira.casa> <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> <351ff25e0907291824g68de211id52c58939c2d275@mail.gmail.com> <20090730014703.GA19555@kira.casa> Message-ID: <351ff25e0907301631h2ab2201cwf854ce294ada1d83@mail.gmail.com> BTW, OpenGL-2.3 breaks GLFW-0.3 On Wed, Jul 29, 2009 at 22:47, Felipe Lessa wrote: > On Wed, Jul 29, 2009 at 10:24:23PM -0300, Rafael Gustavo da Cunha Pereira > Pinto wrote: > > mapAccumL was added to Data.Traversable in package base-4. GHC 6.8.2 uses > > base-3... > > But this means that Tensor's dependencies should be on base >= 4, not 3. > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090730/374f8fad/attachment-0001.html From phil at beadling.co.uk Thu Jul 30 20:06:37 2009 From: phil at beadling.co.uk (Phil) Date: Thu Jul 30 19:47:40 2009 Subject: [Haskell-cafe] Retrieving inner state from outside the transformer Message-ID: <89bc5e540907301706t46c0a9c6neb4abc4249618660@mail.gmail.com> Hi, I've hit a brick wall trying to work out, what should be (and probably is!) a simple problem. I have a StateT stack (1 State monad, 2 StateT transformers) which works fine and returns the result of the outer monad. I thought I understood this fine, but perhaps not. My understanding is that the result returned by the inner-most monad is always 'transformed' by the outer monads and thus the result you get is that computed in the outer transformer. The problem I have is now I'd like not only to get the final state of the outer most transformer, but I'd also like to know the final states of the the inner StateT and the inner State at the end of the computation (so that at a later point in time I can reinitialize a similar stack and continue with the same set of states I finished with). So I figured I could have a separate (parent) State Monad (not part of this stack) that would store the final state of the sequence below. I figured it couldn't be part of this stack, as one computation on the stack does not lead to one result in the parent State Monad; it is only the end states of the sequence I care about. Anyway, currently I just have the stack evaluated as below. Is there anyway from outside of the computation that I can interrogate the states of the inner layers? The only way I can see to do this is inside the outer monad itself. As I'm not using the result I could use 'lift get' and 'lift lift get' to make the outer transformer return the two inner states as it's result. I could ignore this result for the first (iterations-1) and bind a final iteration which uses replicateM instead of replicateM_. This strikes me as pretty horrible tho! So, in the example below if I want to modify the 'result' function so it returns no only the outer state, but also the two inners states as a tuple (Double,Double,Double) is there an easier way of doing this? result :: RngClass a => NormalClass b => a -> b -> MonteCarloUserData -> Double result initRngState initNormState userData = evalState a initRngState where a = evalStateT b initNormState b = execStateT ( do replicateM_ (iterations userData) (mc userData)) 0 Any advice greatly appreciated! Thanks, Phil. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090730/b8f1851c/attachment.html From RafaelGCPP.Linux at gmail.com Thu Jul 30 20:23:30 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Thu Jul 30 20:04:35 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <351ff25e0907301631h2ab2201cwf854ce294ada1d83@mail.gmail.com> References: <200907291826.30307.Sven.Panne@aedion.de> <20090729165525.GA23329@kira.casa> <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> <351ff25e0907291824g68de211id52c58939c2d275@mail.gmail.com> <20090730014703.GA19555@kira.casa> <351ff25e0907301631h2ab2201cwf854ce294ada1d83@mail.gmail.com> Message-ID: <351ff25e0907301723m479cd3b6yb5090067c6d14a23@mail.gmail.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: GLFW.hs.patch Type: text/x-patch Size: 228349 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090730/5e74e1a0/GLFW.hs-0001.bin From aslatter at gmail.com Thu Jul 30 23:11:49 2009 From: aslatter at gmail.com (Antoine Latter) Date: Thu Jul 30 22:52:52 2009 Subject: [Haskell-cafe] Retrieving inner state from outside the transformer In-Reply-To: <89bc5e540907301706t46c0a9c6neb4abc4249618660@mail.gmail.com> References: <89bc5e540907301706t46c0a9c6neb4abc4249618660@mail.gmail.com> Message-ID: <694519c50907302011p4ce87cecw9b1866dbf11264cd@mail.gmail.com> On Thu, Jul 30, 2009 at 7:06 PM, Phil wrote: > Hi, > > I've hit a brick wall trying to work out, what should be (and probably is!) > a simple problem. > > I have a StateT stack (1 State monad, 2 StateT transformers) which works > fine and returns the result of the outer monad.? I thought I understood this > fine, but perhaps not.? My understanding is that the result returned by the > inner-most monad is always 'transformed' by the outer monads and thus the > result you get is that computed in the outer transformer. > What I would do is not use transformers - I would have computations of type 'State MyState a' where 'MyState' would be something like: data MyState = MyState { component_one :: TypeOne , component_two :: TypeTwo , component_three :: TypeThree } instead of three separate transformers/monads for each data type. I would then have helper functions: getThingOne :: State MyState TypeOne setThingOne :: TypeOne -> State MyState () modifyThingOne :: (TypeOne -> TypeOne) -> State MyState TypeOne etc. You'll want to pick better names for your types and helper functions as suits your program. Antoine From ryani.spam at gmail.com Thu Jul 30 23:25:05 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Jul 30 23:06:07 2009 Subject: [Haskell-cafe] Deepest polymorphic functor In-Reply-To: <24748175.post@talk.nabble.com> References: <24709303.post@talk.nabble.com> <2f9b2d30907281911n15ad4698q4cc705a4fc81d87f@mail.gmail.com> <24748175.post@talk.nabble.com> Message-ID: <2f9b2d30907302025m3752093x665cf53276baed47@mail.gmail.com> The problem is this: > instance Num a => Num [a] where ... > > test = deep_fmap (+1) [[[ 1, 2, 3 :: Int ]]] What (+1) should be used? (+1) :: Int -> Int (+1) :: [Int] -> [Int] (+1) :: [[Int]] -> [[Int]] (+1) :: [[[Int]]] -> [[[Int]]] They could all be type-correct, so the snippet is ambiguous. Monotypes are required to avoid the ambiguity. As to why you might want an instance of this form, they are very nice for representing (possibly infinite) power series[1] of the form c0 + c1 * x + c2 * x^2 + c3 * x^3 + ... As to your other question, in my experience it seems that yes, type equality constraints can replace the awkward "TypeCast" classes of oleg-ery. -- ryan [1] Mcilroy: Functional Pearl: Power Series, Power Serious. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.9450 Code here: http://journals.cambridge.org/fulltext_content/supplementary/JFP/online/jfpvol9-3/power-pearl/appendix.hs From ryani.spam at gmail.com Thu Jul 30 23:39:45 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Jul 30 23:20:48 2009 Subject: [Haskell-cafe] Retrieving inner state from outside the transformer In-Reply-To: <89bc5e540907301706t46c0a9c6neb4abc4249618660@mail.gmail.com> References: <89bc5e540907301706t46c0a9c6neb4abc4249618660@mail.gmail.com> Message-ID: <2f9b2d30907302039u7d4b5f23n5d2ebfe9d2681fbe@mail.gmail.com> StateT is really simple, so you should be able to figure it out: runStateT :: StateT s m a -> s -> m (a,s) runState :: State s a -> s -> (a,s) So if you have m :: StateT s1 (StateT s2 (State s3)) a runStateT m :: s1 -> StateT s2 (State s3) (a,s) \s1 s2 s3 -> runState (runStateT (runStateT m s1) s2) s3) :: s1 -> s2 -> s3 -> (((a,s1), s2), s3) A different way to do it: transformStateT :: (m1 (a,s) -> m2 (a,s)) -> StateT s m1 a -> StateT s m2 a transformStateT f sm1 = StateT (f . runStateT sm1) upgradeStateT :: StateT s1 (State s2) a -> State (s1,s2) a upgradeStateT m = State $ \(s1,s2) -> let ((a,s1'), s2') = runState (runStateT m s1) s2 in (a, (s1', s2')) upgradeStateT2 :: StateT s1 (StateT s2 (State s3)) a -> State (s1,(s2,s3)) a upgradeStateT2 = upgradeStateT . transformStateT upgradeStateT You should be able to write downgradeStateT similarily to get back to your monad stack representation. -- ryan On Thu, Jul 30, 2009 at 5:06 PM, Phil wrote: > Hi, > > I've hit a brick wall trying to work out, what should be (and probably is!) > a simple problem. > > I have a StateT stack (1 State monad, 2 StateT transformers) which works > fine and returns the result of the outer monad.? I thought I understood this > fine, but perhaps not.? My understanding is that the result returned by the > inner-most monad is always 'transformed' by the outer monads and thus the > result you get is that computed in the outer transformer. > > The problem I have is now I'd like not only to get the final state of the > outer most transformer, but I'd also like to know the final states of the > the inner StateT and the inner State at the end of the computation (so that > at a later point in time I can reinitialize a similar stack and continue > with the same set of states I finished with). > > So I figured I could have a separate (parent) State Monad (not part of this > stack) that would store the final state of the sequence below.? I figured it > couldn't be part of this stack, as one computation on the stack does not > lead to one result in the parent State Monad; it is only the end states of > the sequence I care about. > > Anyway, currently I just have the stack evaluated as below.? Is there anyway > from outside of the computation that I can interrogate the states of the > inner layers?? The only way I can see to do this is inside the outer monad > itself.? As I'm not using the result I could use 'lift get' and 'lift lift > get' to make the outer transformer return the two inner states as it's > result.? I could ignore this result for the first (iterations-1) and bind a > final iteration which uses replicateM instead of replicateM_. > > This strikes me as pretty horrible tho! > > So, in the example below if I want to modify the 'result' function so it > returns no only the outer state, but also the two inners states as a tuple > (Double,Double,Double) is there an easier way of doing this? > > result :: RngClass a => NormalClass b => a -> b -> MonteCarloUserData -> > Double > result initRngState initNormState userData = evalState a initRngState > > where? a = evalStateT b initNormState > > ? ? ? ? ?? b = execStateT ( do replicateM_ (iterations userData) (mc > userData)) 0 > > > Any advice greatly appreciated! > > Thanks, > > Phil. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ryani.spam at gmail.com Thu Jul 30 23:53:02 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Jul 30 23:34:04 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <90889fe70907290406l53fe3d0cq7878f6f34ed23246@mail.gmail.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <906251.73778.qm@web112509.mail.gq1.yahoo.com> <90889fe70907290406l53fe3d0cq7878f6f34ed23246@mail.gmail.com> Message-ID: <2f9b2d30907302053g27450046h9290ec89a7812d7d@mail.gmail.com> On Wed, Jul 29, 2009 at 4:06 AM, Johan Tibell wrote: > (map maySwitch . unfoldr go) (x1,y1,0) > > should work. which is the same as > map maySwitch (unfoldr go (x1,y1,0)) People have stylistic differences with ($) vs. (.); I would write it as > map maySwitch $ unfoldr go $ (x1,y1,0) (or, more likely) > map maySwitch $ unfoldr go (x1,y1,0) but some people like to make the function pipelines more explicit (with the composition operator (.) instead of the application operator ($)). Read ($) as a parenthesis that extends as far to the right as possible; so you can write, for example: > map (+1) $ map (*2) $ map (+3) [1,2,3] which is the same as > map (+1) (map (*2) (map (+3) [1,2,3])) but without having to count how many parentheses you need on the right. Due to the precedences of (.) and ($), you can use either > blah $ blah2 $ blah3 $ something or > blah . blah2 . blah3 $ something After inlining ($) and (.), the former is > blah (blah2 (blah3 (something))) whereas the latter is > (\x -> blah ((\y -> blah2 (blah3 y)) x)) (something) which beta reduces to the same thing: => blah ((\y -> blah2 (blah3 y)) (something)) => blah (blah2 (blah3 (something))) -- ryan From Eduard.Sergeev at gmail.com Fri Jul 31 02:26:08 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Fri Jul 31 02:07:11 2009 Subject: [Haskell-cafe] Deepest polymorphic functor In-Reply-To: <2f9b2d30907302025m3752093x665cf53276baed47@mail.gmail.com> References: <24709303.post@talk.nabble.com> <2f9b2d30907281911n15ad4698q4cc705a4fc81d87f@mail.gmail.com> <24748175.post@talk.nabble.com> <2f9b2d30907302025m3752093x665cf53276baed47@mail.gmail.com> Message-ID: <24751663.post@talk.nabble.com> Ryan Ingram wrote: > > The problem is this: > >> instance Num a => Num [a] where ... >> >> test = deep_fmap (+1) [[[ 1, 2, 3 :: Int ]]] > > What (+1) should be used? > > (+1) :: Int -> Int > (+1) :: [Int] -> [Int] > (+1) :: [[Int]] -> [[Int]] > (+1) :: [[[Int]]] -> [[[Int]]] > > They could all be type-correct, so the snippet is ambiguous. But why then the following snippet doesn't cause ambiguity: deep_fmap (++"a") "b" // -> "ba" deep_fmap (++"a") ["b"] // -> ["ba"] deep_fmap (++"a") [["b"]] // -> [["ba"]] -- View this message in context: http://www.nabble.com/Deepest-polymorphic-functor-tp24709303p24751663.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dav.vire+haskell at gmail.com Fri Jul 31 02:26:17 2009 From: dav.vire+haskell at gmail.com (david48) Date: Fri Jul 31 02:07:21 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <2f9b2d30907302053g27450046h9290ec89a7812d7d@mail.gmail.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <906251.73778.qm@web112509.mail.gq1.yahoo.com> <90889fe70907290406l53fe3d0cq7878f6f34ed23246@mail.gmail.com> <2f9b2d30907302053g27450046h9290ec89a7812d7d@mail.gmail.com> Message-ID: <4c88418c0907302326k7244c468p7c8cc9157f881c05@mail.gmail.com> On Fri, Jul 31, 2009 at 5:53 AM, Ryan Ingram wrote: > Read ($) as a parenthesis that extends as far to the right as > possible; so you can write, for example: That doesn't always work, for example : map (+2) . map (*1) $ [1,2,3] = [4,6,8] Now replacing the $ by a parenthesis that extends as far to the right as possible : map (+2) . map (*1) ( [1,2,3] ) :1:11: Couldn't match expected type `a -> [a1]' against inferred type `[a2]' In the second argument of `(.)', namely `map (* 2) ([1, 2, 3])' In the expression: map (+ 2) . map (* 2) ([1, 2, 3]) In the definition of `it': it = map (+ 2) . map (* 2) ([1, 2, 3]) From Eduard.Sergeev at gmail.com Fri Jul 31 03:05:05 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Fri Jul 31 02:46:06 2009 Subject: [Haskell-cafe] Deepest polymorphic functor In-Reply-To: <2f9b2d30907302025m3752093x665cf53276baed47@mail.gmail.com> References: <24709303.post@talk.nabble.com> <2f9b2d30907281911n15ad4698q4cc705a4fc81d87f@mail.gmail.com> <24748175.post@talk.nabble.com> <2f9b2d30907302025m3752093x665cf53276baed47@mail.gmail.com> Message-ID: <24752047.post@talk.nabble.com> Ryan Ingram wrote: > >> instance Num a => Num [a] where ... > O... I see what you mean. So... no way around? e.g. no way to define deep_fmap for not grounded types? -- View this message in context: http://www.nabble.com/Deepest-polymorphic-functor-tp24709303p24752047.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Fri Jul 31 03:07:12 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Jul 31 02:48:42 2009 Subject: [Haskell-cafe] Deepest polymorphic functor In-Reply-To: <24751663.post@talk.nabble.com> References: <24709303.post@talk.nabble.com> <2f9b2d30907281911n15ad4698q4cc705a4fc81d87f@mail.gmail.com> <24748175.post@talk.nabble.com> <2f9b2d30907302025m3752093x665cf53276baed47@mail.gmail.com> <24751663.post@talk.nabble.com> Message-ID: <451195444.20090731110712@gmail.com> Hello Eduard, Friday, July 31, 2009, 10:26:08 AM, you wrote: >>> instance Num a => Num [a] where ... > But why then the following snippet doesn't cause ambiguity: > deep_fmap (++"a") "b" // -> "ba" > deep_fmap (++"a") ["b"] // -> ["ba"] > deep_fmap (++"a") [["b"]] // -> [["ba"]] because it doesn't involve any instances. if you will declare class Appendable a where (++) :: a -> a -> a instance Appendable String ... instance Appendable a => Appendable [a] ... instance IsString [a] ... -- class IsString, like class Num, defines conversion rules for string constants you will get into the same trouble -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bartdevylder at gmail.com Fri Jul 31 04:59:08 2009 From: bartdevylder at gmail.com (Bart De Vylder) Date: Fri Jul 31 04:40:10 2009 Subject: [Haskell-cafe] gtksourceview link problem with leksah on windows Message-ID: <2f42c05b0907310159y268b9b3cuaed38636b932abfd@mail.gmail.com> Dear Haskellers, i'm having troubles linking Leksah against gtksourceview on windows (XP). I've installed gtk2hs (using the windows installer) but am not sure whether/where to specify the library search path for ld. Here is the output I get: C:\Documents and Settings\bartdv>cabal install leksah Resolving dependencies... Configuring leksah-0.6.1... Preprocessing executables for leksah-0.6.1... Building leksah-0.6.1... [ 1 of 55] Compiling DeepSeq ( src\DeepSeq.hs, > dist\build\leksah\leksah-tmp\DeepSeq.o ) > ... > [55 of 55] Compiling Main ( src\Main.hs, > dist\build\leksah\leksah-tmp\Main.o ) Linking dist\build\leksah\leksah.exe ... C:\app\Haskell_Platform\2009.2.0.1\gcc-lib\ld.exe: cannot find > -lgtksourceview-2.0 collect2: ld returned 1 exit status cabal: Error: some packages failed to install: leksah-0.6.1 failed during the building phase. The exception was: exit: ExitFailure 1 any help/ tips are very welcome, I'm eager to leave emacs... Bart -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090731/4ab1e393/attachment.html From ketil at malde.org Fri Jul 31 05:06:08 2009 From: ketil at malde.org (Ketil Malde) Date: Fri Jul 31 04:47:01 2009 Subject: [Haskell-cafe] Strange memory usage problem Message-ID: <878wi543y7.fsf@malde.org> Hi, I'm observing something I find quite strange. I have a program that normally streams through a file, and it runs in the expected constant space, consuming about 5MB, according to 'top'. When I uncomment a certain block of code in the library it uses, space consumption appears to grow linearly with the input size. This is a bit surprising to me, since the code in question isn't used by the program at all, and yesterday, Cale confirmed this behavior on a recent GHC (6.10.3, I think - mine is 6.8.2 as shipped with Ubuntu 9.04). Since this appears to be reproducible, I put together a test case. The steps are: darcs get http://malde.org/~ketil/biohaskell/biolib-unstable darcs get http://malde.org/~ketil/biohaskell/flower Build them using the usual incantations (./Setup.hs configure/build/install). Download the test input file: wget http://malde.org/~ketil/test.sff Run for instance this command line: fselect "And (Func GT len 100) (Func GT k2 0.5)" test.sff This should now run in constant space. To observe the linear growth space, unpull the last patch from biolib, i.e. this one: Fri Jul 31 00:14:09 CEST 2009 Ketil Malde * comment out recover functionality - otherwise FSelect leaks memory! M ./Bio/Sequence/SFF.hs -1 +7 This uncomments some otherwise unused code, which apparently triggers this behavior. I'm unable to see what causes this, so any suggestions welcome. -k -- If I haven't seen further, it is by standing in the footprints of giants From apfelmus at quantentunnel.de Fri Jul 31 05:50:28 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Jul 31 05:32:02 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution In-Reply-To: <2f9b2d30907281005u5bff3db4h19c59290b166a9ef@mail.gmail.com> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <2f9b2d30907281005u5bff3db4h19c59290b166a9ef@mail.gmail.com> Message-ID: Ryan Ingram wrote: > Heinrich wrote: >> While I do agree that qualified names are annoying at times, I think >> that type directed name disambiguation is a Pandora's box. > > I see where you are going, but I'm not sure I agree. Let me give an > example from another language with this kind of resolution: C++. From > a purely practical point of view, function overloading in C++ does > what I want almost all the time. And when it doesn't do what I want, > it's always been immediately obvious, and it's a sign that my design > is flawed. > > But those cases where it does what I want have been incredibly useful. Sure, overloading is useful. But to avoid headache in a polymorphic language, I'd prefer a principled approach to it. Hence, I'm convinced that there should be only one mechanism for overloading in Haskell; which is type classes at the moment. It appears that type direction name disambiguation can be implemented with (automatically generated) type classes? Something like this class Function_lookup t where lookup :: t instance Function_lookup (k -> [(k,a)] -> Maybe a) where lookup = ... instance Function_lookup (k -> Map k a -> Maybe a) where lookup = ... For each ambiguous function, the compiler creates a type class and corresponding instances and type inference will sort out the rest (or throw a type error). Regards, apfelmus -- http://apfelmus.nfshost.com From apfelmus at quantentunnel.de Fri Jul 31 06:00:59 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Jul 31 05:41:49 2009 Subject: [Haskell-cafe] Re: Proposal: TypeDirectedNameResolution In-Reply-To: <87ljm54w6b.fsf@malde.org> References: <4A6DCE93.5020700@imn.htwk-leipzig.de> <89ca3d1f0907270929u53c3ae8ey14758557bf07e29b@mail.gmail.com> <87ljm54w6b.fsf@malde.org> Message-ID: Ketil Malde wrote: > Cale Gibbard writes: > >> There was a great related idea on #haskell the other day: Make >> explicit qualification unnecessary whenever there is a *unique* choice >> of module qualifications from those imported which would make the >> expression typecheck. > > My favorite annoyance is repeated import lines for each library just > to be able to use some unique identifiers unqualified, e.g.: > > import qualified Data.ByteString as B > import Data.ByteString (ByteString) > import qualified Data.Map as M > import Data.Map (Map) > > and so on. I'm all for it, if for no other reason, then just to get > rid of this. Note that there are alternative solution for this particular problem. For instance, a version of qualified with different semantics will do; something like this import Data.List import sometimes qualified Data.Map as Map foo :: Map k a -- accepted with out qualifier 'Map' -- because it's unambiguous bar m = map show m -- defaults to Data.List.map , -- 'Map' prefix would be need in -- cases of ambiguity The idea being that names only need to be qualified when they are ambiguous, which Map and ByteString are not. Regards, apfelmus -- http://apfelmus.nfshost.com From ck_kashyap at yahoo.com Fri Jul 31 08:12:32 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Fri Jul 31 07:53:35 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <4c88418c0907302326k7244c468p7c8cc9157f881c05@mail.gmail.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <906251.73778.qm@web112509.mail.gq1.yahoo.com> <90889fe70907290406l53fe3d0cq7878f6f34ed23246@mail.gmail.com> <2f9b2d30907302053g27450046h9290ec89a7812d7d@mail.gmail.com> <4c88418c0907302326k7244c468p7c8cc9157f881c05@mail.gmail.com> Message-ID: <160790.82894.qm@web112510.mail.gq1.yahoo.com> I personally find map maySwitch (unfoldr go (x1,y1,0)) and map maySwitch $ unfoldr go (x1,y1,0) more intuitive. I can read it as map the maySwitch function over the list generated from the unfolding. Is there any difference in the evaluation steps between the composition version and the non-composition version? Regards, Kashyap ________________________________ From: david48 To: Ryan Ingram Cc: Johan Tibell ; haskell-cafe@haskell.org; CK Kashyap Sent: Friday, July 31, 2009 11:56:17 AM Subject: Re: [Haskell-cafe] Need feedback on my Haskell code On Fri, Jul 31, 2009 at 5:53 AM, Ryan Ingram wrote: > Read ($) as a parenthesis that extends as far to the right as > possible; so you can write, for example: That doesn't always work, for example : map (+2) . map (*1) $ [1,2,3] = [4,6,8] Now replacing the $ by a parenthesis that extends as far to the right as possible : map (+2) . map (*1) ( [1,2,3] ) :1:11: Couldn't match expected type `a -> [a1]' against inferred type `[a2]' In the second argument of `(.)', namely `map (* 2) ([1, 2, 3])' In the expression: map (+ 2) . map (* 2) ([1, 2, 3]) In the definition of `it': it = map (+ 2) . map (* 2) ([1, 2, 3]) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090731/a345da40/attachment.html From chaddai.fouche at gmail.com Fri Jul 31 08:25:00 2009 From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=) Date: Fri Jul 31 08:06:03 2009 Subject: [Haskell-cafe] Need feedback on my Haskell code In-Reply-To: <160790.82894.qm@web112510.mail.gq1.yahoo.com> References: <549911.34300.qm@web112502.mail.gq1.yahoo.com> <906251.73778.qm@web112509.mail.gq1.yahoo.com> <90889fe70907290406l53fe3d0cq7878f6f34ed23246@mail.gmail.com> <2f9b2d30907302053g27450046h9290ec89a7812d7d@mail.gmail.com> <4c88418c0907302326k7244c468p7c8cc9157f881c05@mail.gmail.com> <160790.82894.qm@web112510.mail.gq1.yahoo.com> Message-ID: On Fri, Jul 31, 2009 at 2:12 PM, CK Kashyap wrote: > I personally find > map maySwitch (unfoldr go (x1,y1,0)) and map maySwitch $ unfoldr go > (x1,y1,0) more intuitive. > > I can read it as map the maySwitch function over the list generated from the > unfolding. > > Is there any difference in the evaluation steps between the composition > version and the non-composition version? There may be small differences in the result after optimisation but you shouldn't worry about that right now (if you really want to optimise this function, the first thing to do is to change your data structure for points : a strict pair of int (data Point = P !Int !Int) could easily go more than 5 times faster, I tried). I tend to always use this "map maySwitch . unfoldr go $ (x1,y1,0)" style since I like to see things in terms of functions compositions and it is easier to refactor this kind of code with copy and paste (not really relevant here but for longer chains it's interesting). -- Jeda? From nonowarn at gmail.com Fri Jul 31 09:56:57 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Fri Jul 31 09:38:28 2009 Subject: [Haskell-cafe] ANN: tkhs-0.1.* Presentation Utility Message-ID: <3B29AB6E-96E1-40BA-B43D-5496FCE6F52F@gmail.com> Hi, I'm pleased to announce the release of tkhs-0.1.*, Simple presentation utility. If you are thinking PowerPoint is overkill for your presentation, Tkhs may fit the purpose. See screenshot of running tkhs in my terminal: http://nonowarn.tumblr.com/post/152324109 When you invoke tkhs with slide file written in simple format text, tkhs displays the first slide. And you can operate a presentation by some keys. Details like slide file format and keybinds for operating slide are available at README[1] file included by the package. Project is hosted at patch-tag[2], Feel free to send me patch. Finally, I'm very grateful Evan Klizke and Brian Lewis. Evan is the author of hspresent[3] which inspired me to write tkhs. Brian sent me patch improving English. [1]: http://patch-tag.com/r/tkhs/snapshot/current/content/pretty/README [2]: http://patch-tag.com/r/tkhs/pullrepo [3]: http://hackage.haskell.org/package/hspresent Thanks, nwn From roma at ro-che.info Fri Jul 31 12:02:26 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Fri Jul 31 11:43:18 2009 Subject: [Haskell-cafe] ANN: tkhs-0.1.* Presentation Utility In-Reply-To: <3B29AB6E-96E1-40BA-B43D-5496FCE6F52F@gmail.com> References: <3B29AB6E-96E1-40BA-B43D-5496FCE6F52F@gmail.com> Message-ID: <20090731160226.GA31729@flit> * Yusaku Hashimoto [2009-07-31 22:56:57+0900] > Hi, > > I'm pleased to announce the release of tkhs-0.1.*, Simple presentation > utility. If you are thinking PowerPoint is overkill for your > presentation, > Tkhs may fit the purpose. For real presentations one would probably use beamer or similar, but this tool indeed might be useful occasionally -- e.g. as notes for himself when talking about something. Thanks! -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From carter.schonwald at gmail.com Fri Jul 31 16:24:25 2009 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Fri Jul 31 16:05:47 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <351ff25e0907301723m479cd3b6yb5090067c6d14a23@mail.gmail.com> References: <200907291826.30307.Sven.Panne@aedion.de> <20090729165525.GA23329@kira.casa> <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> <351ff25e0907291824g68de211id52c58939c2d275@mail.gmail.com> <20090730014703.GA19555@kira.casa> <351ff25e0907301631h2ab2201cwf854ce294ada1d83@mail.gmail.com> <351ff25e0907301723m479cd3b6yb5090067c6d14a23@mail.gmail.com> Message-ID: <931b9490907311324p2d974f4dnc25d9572d3ad0714@mail.gmail.com> I just the the rebuild of the haskell glut / opengl libs and I got the following message Configuring OpenGLRaw-1.0.1.0... cabal: Missing dependency on a foreign library: * Missing C library: GL 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. cabal: Error: some packages failed to install: GLURaw-1.0.0.0 depends on OpenGLRaw-1.0.1.0 which failed to install. OpenGL-2.3.0.0 depends on OpenGLRaw-1.0.1.0 which failed to install. OpenGLRaw-1.0.1.0 failed during the configure step. The exception was: and I don't see how to get the openglraw to build or what has changed thanks for any help -Carter On Thu, Jul 30, 2009 at 8:23 PM, Rafael Gustavo da Cunha Pereira Pinto < RafaelGCPP.Linux@gmail.com> wrote: > Here is a patch that makes it compile, but then it breaks all code > developed for GLFW-0.3, as all Floats need to be changed to CFloat. > > For all haskellers here: > > Sorry for all this annoyance, but I was starting to study those libraries > (OpenGL, GLUT and GLFW) using Haskell and the update broke some of my code. > > > Best Regards, > > Rafael > > > _______________________________________________ > 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/20090731/0036aaea/attachment.html From p.f.moore at gmail.com Fri Jul 31 16:39:53 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Fri Jul 31 16:20:53 2009 Subject: [Haskell-cafe] Efficient functional idiom for histogram Message-ID: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> How would I efficiently write a function in Haskell to count occurrences of unique elements in a (potentially very large) list? For example, given the list [1,2,3,4,5,3,4,2,4] I would like the output [[1,1], [2,2], [3,2], [4,3], [5,1]] (or some equivalent representation). Clearly, this won't be possible for infinite input, but I would like it to be as efficient as possible for (lazy) input lists containing many millions of elements. So an implementation based on group . sort is not going to work. In an imperative language like Python, I'd use a dictionary as an accumulator - something like for el in input: accums[i] = accums.get(i, 0) + 1 That's about as efficient as you can hope for (assuming an efficient dictionary implementation). How would I code something equivalent in Haskell? Thanks, Paul. From tomahawkins at gmail.com Fri Jul 31 16:49:30 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Fri Jul 31 16:30:31 2009 Subject: [Haskell-cafe] ANN: atom 0.1.0 Message-ID: <594c1e830907311349q50fb4e5dyc67457de4840b2e3@mail.gmail.com> Atom is a Haskell DSL for hard realtime applications. This release includes support for assertions and functional coverage to aid simulation and testing. The rev of the minor version indicates a bit of library stability. This is the version we're using for our application, which officially went into production and hit the road last month -- literally. http://hackage.haskell.org/package/atom -Tom From greg at gregorycollins.net Fri Jul 31 16:52:10 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Fri Jul 31 16:33:10 2009 Subject: [Haskell-cafe] Efficient functional idiom for histogram In-Reply-To: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> (Paul Moore's message of "Fri, 31 Jul 2009 21:39:53 +0100") References: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> Message-ID: <87y6q4lgn9.fsf@gregorycollins.net> Paul Moore writes: > How would I efficiently write a function in Haskell to count > occurrences of unique elements in a (potentially very large) list? For > example, given the list [1,2,3,4,5,3,4,2,4] I would like the output > [[1,1], [2,2], [3,2], [4,3], [5,1]] (or some equivalent > representation). import qualified Data.Map as Map import Data.Map (Map) histogram :: Ord a => [a] -> [(a,Int)] histogram = Map.assocs . foldl f Map.empty where f m k = Map.insertWith (+) k 1 m G. -- Gregory Collins From greg at gregorycollins.net Fri Jul 31 16:53:25 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Fri Jul 31 16:34:25 2009 Subject: [Haskell-cafe] Efficient functional idiom for histogram In-Reply-To: <87y6q4lgn9.fsf@gregorycollins.net> (Gregory Collins's message of "Fri, 31 Jul 2009 16:52:10 -0400") References: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> <87y6q4lgn9.fsf@gregorycollins.net> Message-ID: <87tz0slgl6.fsf@gregorycollins.net> Gregory Collins writes: > Paul Moore writes: > >> How would I efficiently write a function in Haskell to count >> occurrences of unique elements in a (potentially very large) list? For >> example, given the list [1,2,3,4,5,3,4,2,4] I would like the output >> [[1,1], [2,2], [3,2], [4,3], [5,1]] (or some equivalent >> representation). > > import qualified Data.Map as Map > import Data.Map (Map) > > histogram :: Ord a => [a] -> [(a,Int)] > histogram = Map.assocs . foldl f Map.empty > where > f m k = Map.insertWith (+) k 1 m Here "foldl" should be "foldl'" (d'oh!) G -- Gregory Collins From malcolm.wallace at cs.york.ac.uk Fri Jul 31 16:54:23 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Jul 31 16:35:24 2009 Subject: [Haskell-cafe] Efficient functional idiom for histogram In-Reply-To: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> References: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> Message-ID: <365CD5AF-E65C-4616-A551-46D780585483@cs.york.ac.uk> > In an imperative language like Python, I'd use a dictionary as an > accumulator - something like > > for el in input: > accums[i] = accums.get(i, 0) + 1 Haskell has efficient dictionary structures too, e.g. Data.Map List.foldl' (\m x-> Map.insertWith' (+) x 1 m) Map.empty Regards, Malcolm From jeremy at n-heptane.com Fri Jul 31 16:56:05 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Jul 31 16:37:07 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? Message-ID: <87prbg607u.wl%jeremy@n-heptane.com> Hello, Using encode/decode from Binary seems to permamently increase my memory consumption by 60x fold. I am wonder if I am doing something wrong, or if this is an issue with Binary. If I run the following program, it uses sensible amounts of memory (1MB) (note that the bin and list' thunks won't actully be evaluated): import Data.Binary main :: IO () main = let list = [1..1000000] :: [Int] bin = encode list list' = decode bin :: [Int] in putStrLn (show . length $ takeWhile (< 10000000) list) >> getLine >> return () /tmp $ ghc --make -O2 Bin.hs -o bin /tmp $ ./bin +RTS -s /tmp/bin +RTS -s 1000000 68,308,156 bytes allocated in the heap 6,700 bytes copied during GC 18,032 bytes maximum residency (1 sample(s)) 22,476 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 130 collections, 0 parallel, 0.00s, 0.00s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 0.05s ( 0.92s elapsed) GC time 0.00s ( 0.00s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 0.05s ( 0.92s elapsed) %GC time 0.0% (0.1% elapsed) Alloc rate 1,313,542,603 bytes per MUT second Productivity 100.0% of total user, 5.7% of total elapsed According to top: VIRT RSS SHR 3880 1548 804 Now, if I change *list* in the last line to *list'* so that the encode/decode stuff actually happens: /tmp $ ./bin +RTS -s /tmp/bin +RTS -s 1000000 617,573,932 bytes allocated in the heap 262,281,412 bytes copied during GC 20,035,672 bytes maximum residency (10 sample(s)) 2,187,296 bytes maximum slop 63 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 1151 collections, 0 parallel, 0.47s, 0.48s elapsed Generation 1: 10 collections, 0 parallel, 0.36s, 0.40s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 0.47s ( 20.32s elapsed) GC time 0.84s ( 0.88s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 1.30s ( 21.19s elapsed) %GC time 64.1% (4.1% elapsed) Alloc rate 1,319,520,653 bytes per MUT second Productivity 35.9% of total user, 2.2% of total elapsed And top reports: VIRT RSS SHR 67368 64m 896 63 times as much total memory in use. And, this is while the program is waiting around at 'getLine' after it is 'done' with the data. I am using GHC 6.10.4 on GNU/Linux. Thanks! - jeremy From daniel.is.fischer at web.de Fri Jul 31 17:14:28 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Jul 31 16:56:20 2009 Subject: [Haskell-cafe] Efficient functional idiom for histogram In-Reply-To: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> References: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> Message-ID: <200907312314.28706.daniel.is.fischer@web.de> Am Freitag 31 Juli 2009 22:39:53 schrieb Paul Moore: > How would I efficiently write a function in Haskell to count > occurrences of unique elements in a (potentially very large) list? For > example, given the list [1,2,3,4,5,3,4,2,4] I would like the output > [[1,1], [2,2], [3,2], [4,3], [5,1]] (or some equivalent > representation). > > Clearly, this won't be possible for infinite input, but I would like > it to be as efficient as possible for (lazy) input lists containing > many millions of elements. So an implementation based on group . sort > is not going to work. > > In an imperative language like Python, I'd use a dictionary as an > accumulator - something like > > for el in input: > accums[i] = accums.get(i, 0) + 1 > > That's about as efficient as you can hope for (assuming an efficient > dictionary implementation). How would I code something equivalent in > Haskell? If the elements come from a relatively small range and are suitable for array indexing, import Data.Array.IArray import Data.Array.Unboxed accumArray :: (IArray a e, Ix i) => (e -> e' -> e) -- ^ An accumulating function -> e -- ^ A default element -> (i,i) -- ^ The bounds of the array -> [(i, e')] -- ^ List of associations -> a i e -- ^ Returns: the array accumArray (+) 0 (mini,maxi) $ zip list (repeat 1) is pretty fast (beats the hell out of Data.Map). If your elements can't be unboxed, the accumArray function from Data.Array does it too, albeit much slower (still faster than Data.Map, in my experience). > > Thanks, > Paul. From dons at galois.com Fri Jul 31 17:20:14 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 31 17:03:18 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <87prbg607u.wl%jeremy@n-heptane.com> References: <87prbg607u.wl%jeremy@n-heptane.com> Message-ID: <20090731212014.GU809@whirlpool.galois.com> I just need a small test case to reproduce the problem. Thanks! -- Don jeremy: > Hello, > > Using encode/decode from Binary seems to permamently increase my > memory consumption by 60x fold. I am wonder if I am doing something > wrong, or if this is an issue with Binary. > > If I run the following program, it uses sensible amounts of memory > (1MB) (note that the bin and list' thunks won't actully be evaluated): > > import Data.Binary > > main :: IO () > main = > let list = [1..1000000] :: [Int] > bin = encode list > list' = decode bin :: [Int] > in putStrLn (show . length $ takeWhile (< 10000000) list) >> getLine >> return () > > /tmp $ ghc --make -O2 Bin.hs -o bin > /tmp $ ./bin +RTS -s > /tmp/bin +RTS -s > 1000000 > > 68,308,156 bytes allocated in the heap > 6,700 bytes copied during GC > 18,032 bytes maximum residency (1 sample(s)) > 22,476 bytes maximum slop > 1 MB total memory in use (0 MB lost due to fragmentation) > > Generation 0: 130 collections, 0 parallel, 0.00s, 0.00s elapsed > Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed > > INIT time 0.00s ( 0.00s elapsed) > MUT time 0.05s ( 0.92s elapsed) > GC time 0.00s ( 0.00s elapsed) > EXIT time 0.00s ( 0.00s elapsed) > Total time 0.05s ( 0.92s elapsed) > > %GC time 0.0% (0.1% elapsed) > > Alloc rate 1,313,542,603 bytes per MUT second > > Productivity 100.0% of total user, 5.7% of total elapsed > > According to top: > > VIRT RSS SHR > 3880 1548 804 > > > Now, if I change *list* in the last line to *list'* so that the > encode/decode stuff actually happens: > > /tmp $ ./bin +RTS -s > /tmp/bin +RTS -s > 1000000 > > 617,573,932 bytes allocated in the heap > 262,281,412 bytes copied during GC > 20,035,672 bytes maximum residency (10 sample(s)) > 2,187,296 bytes maximum slop > 63 MB total memory in use (0 MB lost due to fragmentation) > > Generation 0: 1151 collections, 0 parallel, 0.47s, 0.48s elapsed > Generation 1: 10 collections, 0 parallel, 0.36s, 0.40s elapsed > > INIT time 0.00s ( 0.00s elapsed) > MUT time 0.47s ( 20.32s elapsed) > GC time 0.84s ( 0.88s elapsed) > EXIT time 0.00s ( 0.00s elapsed) > Total time 1.30s ( 21.19s elapsed) > > %GC time 64.1% (4.1% elapsed) > > Alloc rate 1,319,520,653 bytes per MUT second > > Productivity 35.9% of total user, 2.2% of total elapsed > > And top reports: > > VIRT RSS SHR > 67368 64m 896 > > 63 times as much total memory in use. And, this is while the program > is waiting around at 'getLine' after it is 'done' with the data. > > I am using GHC 6.10.4 on GNU/Linux. > > Thanks! > - jeremy > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From bos at serpentine.com Fri Jul 31 17:26:18 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Jul 31 17:07:21 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <87prbg607u.wl%jeremy@n-heptane.com> References: <87prbg607u.wl%jeremy@n-heptane.com> Message-ID: On Fri, Jul 31, 2009 at 1:56 PM, Jeremy Shaw wrote: > > Using encode/decode from Binary seems to permamently increase my > memory consumption by 60x fold. I am wonder if I am doing something > wrong, or if this is an issue with Binary. > It's an issue with the Binary instance for lists, which forces the entire spine of the list too early. This gives you a gigantic structure to hold onto. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090731/76517d4a/attachment-0001.html From dons at galois.com Fri Jul 31 17:27:30 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 31 17:10:33 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: References: <87prbg607u.wl%jeremy@n-heptane.com> Message-ID: <20090731212730.GX809@whirlpool.galois.com> bos: > On Fri, Jul 31, 2009 at 1:56 PM, Jeremy Shaw wrote: > > > Using encode/decode from Binary seems to permamently increase my > memory consumption by 60x fold. I am wonder if I am doing something > wrong, or if this is an issue with Binary. > > > It's an issue with the Binary instance for lists, which forces the entire spine > of the list too early. This gives you a gigantic structure to hold onto. This is the current instance instance Binary a => Binary [a] where put l = put (length l) >> mapM_ put l get = do n <- get :: Get Int getMany n -- | 'getMany n' get 'n' elements in order, without blowing the stack. getMany :: Binary a => Int -> Get [a] getMany n = go [] n where go xs 0 = return $! reverse xs go xs i = do x <- get -- we must seq x to avoid stack overflows due to laziness in -- (>>=) x `seq` go (x:xs) (i-1) It used to be this, though, xs <- replicateM n get -- now the elems. -- Don From thomas.dubuisson at gmail.com Fri Jul 31 17:33:34 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Fri Jul 31 17:14:34 2009 Subject: [Haskell-cafe] ANN: atom 0.1.0 In-Reply-To: <594c1e830907311349q50fb4e5dyc67457de4840b2e3@mail.gmail.com> References: <594c1e830907311349q50fb4e5dyc67457de4840b2e3@mail.gmail.com> Message-ID: <4c44d90b0907311433q44b29308h1173e365f0a668b8@mail.gmail.com> Tom, I was asking earlier about any good sources of information for atom. It seems the once-good wiki is gone - are there tutorials for Atom hiding in forgotten corners? Thomas On Fri, Jul 31, 2009 at 1:49 PM, Tom Hawkins wrote: > Atom is a Haskell DSL for hard realtime applications. ?This release > includes support for assertions and functional coverage to aid > simulation and testing. ?The rev of the minor version indicates a bit > of library stability. ?This is the version we're using for our > application, which officially went into production and hit the road > last month -- literally. > > http://hackage.haskell.org/package/atom > > -Tom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Fri Jul 31 17:36:26 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 31 17:19:29 2009 Subject: [Haskell-cafe] ANN: atom 0.1.0 In-Reply-To: <4c44d90b0907311433q44b29308h1173e365f0a668b8@mail.gmail.com> References: <594c1e830907311349q50fb4e5dyc67457de4840b2e3@mail.gmail.com> <4c44d90b0907311433q44b29308h1173e365f0a668b8@mail.gmail.com> Message-ID: <20090731213626.GY809@whirlpool.galois.com> We've had a few people playing with Atom to program the Arduino, and John van Enk's been hacking too, Atom & Arduino :: Some Hacking (pt. 1) http://blog.sw17ch.com/wordpress/?p=84 An Atomic Fibonacci Server: Exploring the Atom (Haskell) DSL http://leepike.wordpress.com/2009/05/05/an-atomic-fibonacci-server-exploring-the-atom-haskell-dsl/ Galois will prob. have a tech talk soon. -- Don thomas.dubuisson: > Tom, > I was asking earlier about any good sources of information for atom. > It seems the once-good wiki is gone - are there tutorials for Atom > hiding in forgotten corners? > > Thomas > > On Fri, Jul 31, 2009 at 1:49 PM, Tom Hawkins wrote: > > Atom is a Haskell DSL for hard realtime applications. ?This release > > includes support for assertions and functional coverage to aid > > simulation and testing. ?The rev of the minor version indicates a bit > > of library stability. ?This is the version we're using for our > > application, which officially went into production and hit the road > > last month -- literally. > > > > http://hackage.haskell.org/package/atom > > > > -Tom > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jeremy at n-heptane.com Fri Jul 31 17:42:40 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Jul 31 17:23:42 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <20090731212730.GX809@whirlpool.galois.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> Message-ID: <87ocr05y27.wl%jeremy@n-heptane.com> Hello, Is there a work-around? This is killer for Happstack. Most Happstack applications use IxSet, which in turn uses lists to serialize the data to/from disk. Also, why doesn't the stuff get freed eventually? - jeremy At Fri, 31 Jul 2009 14:27:30 -0700, Don Stewart wrote: > > bos: > > On Fri, Jul 31, 2009 at 1:56 PM, Jeremy Shaw wrote: > > > > > > Using encode/decode from Binary seems to permamently increase my > > memory consumption by 60x fold. I am wonder if I am doing something > > wrong, or if this is an issue with Binary. > > > > > > It's an issue with the Binary instance for lists, which forces the entire spine > > of the list too early. This gives you a gigantic structure to hold onto. > > This is the current instance > > instance Binary a => Binary [a] where > put l = put (length l) >> mapM_ put l > get = do n <- get :: Get Int > getMany n > > -- | 'getMany n' get 'n' elements in order, without blowing the stack. > getMany :: Binary a => Int -> Get [a] > getMany n = go [] n > where > go xs 0 = return $! reverse xs > go xs i = do x <- get > -- we must seq x to avoid stack overflows due to laziness in > -- (>>=) > x `seq` go (x:xs) (i-1) > > It used to be this, though, > > xs <- replicateM n get -- now the elems. > > > -- Don From dons at galois.com Fri Jul 31 17:49:03 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 31 17:32:06 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <87ocr05y27.wl%jeremy@n-heptane.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> <87ocr05y27.wl%jeremy@n-heptane.com> Message-ID: <20090731214903.GA809@whirlpool.galois.com> Why don't you use your own instance to serialize IxSet lazily (or however you would like?) There's no reason to be constrained to use the [a] instance. -- Don jeremy: > Hello, > > Is there a work-around? This is killer for Happstack. Most Happstack > applications use IxSet, which in turn uses lists to serialize the data > to/from disk. > > Also, why doesn't the stuff get freed eventually? > > - jeremy > > At Fri, 31 Jul 2009 14:27:30 -0700, > Don Stewart wrote: > > > > bos: > > > On Fri, Jul 31, 2009 at 1:56 PM, Jeremy Shaw wrote: > > > > > > > > > Using encode/decode from Binary seems to permamently increase my > > > memory consumption by 60x fold. I am wonder if I am doing something > > > wrong, or if this is an issue with Binary. > > > > > > > > > It's an issue with the Binary instance for lists, which forces the entire spine > > > of the list too early. This gives you a gigantic structure to hold onto. > > > > This is the current instance > > > > instance Binary a => Binary [a] where > > put l = put (length l) >> mapM_ put l > > get = do n <- get :: Get Int > > getMany n > > > > -- | 'getMany n' get 'n' elements in order, without blowing the stack. > > getMany :: Binary a => Int -> Get [a] > > getMany n = go [] n > > where > > go xs 0 = return $! reverse xs > > go xs i = do x <- get > > -- we must seq x to avoid stack overflows due to laziness in > > -- (>>=) > > x `seq` go (x:xs) (i-1) > > > > It used to be this, though, > > > > xs <- replicateM n get -- now the elems. > > > > > > -- Don From jason.dusek at gmail.com Fri Jul 31 18:15:35 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Jul 31 17:56:35 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <87ocr05y27.wl%jeremy@n-heptane.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> <87ocr05y27.wl%jeremy@n-heptane.com> Message-ID: <42784f260907311515q1a78b0bes847caa37427e7f2b@mail.gmail.com> 2009/07/31 Jeremy Shaw : > ...why doesn't the stuff get freed eventually? It is my understanding that the GHC runtime never lets go of memory once it has requested it. (Confirmation either way would be informative.) -- Jason Dusek From dons at galois.com Fri Jul 31 18:14:23 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 31 17:57:26 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <42784f260907311515q1a78b0bes847caa37427e7f2b@mail.gmail.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> <87ocr05y27.wl%jeremy@n-heptane.com> <42784f260907311515q1a78b0bes847caa37427e7f2b@mail.gmail.com> Message-ID: <20090731221423.GE809@whirlpool.galois.com> jason.dusek: > 2009/07/31 Jeremy Shaw : > > ...why doesn't the stuff get freed eventually? > > It is my understanding that the GHC runtime never lets go of > memory once it has requested it. (Confirmation either way > would be informative.) It doesn't return memory to the OS. -- Don From jeremy at n-heptane.com Fri Jul 31 18:35:47 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Jul 31 18:16:49 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <20090731214903.GA809@whirlpool.galois.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> <87ocr05y27.wl%jeremy@n-heptane.com> <20090731214903.GA809@whirlpool.galois.com> Message-ID: <87my6k5vlo.wl%jeremy@n-heptane.com> At Fri, 31 Jul 2009 14:49:03 -0700, Don Stewart wrote: > > Why don't you use your own instance to serialize IxSet lazily (or > however you would like?) > > There's no reason to be constrained to use the [a] instance. Well, the Set instance might actually be a better choice. But the Set instance in Binary uses [a] anyway :) Plus, happstack applications do also use Set and List in addition to IxSet. Is this issue with list fixable? If list can't be fixed, then perhaps Set and IxSet can't be fixed for the same reason. But, I don't really understand the reason yet. - jeremy From p.f.moore at gmail.com Fri Jul 31 18:39:14 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Fri Jul 31 18:20:15 2009 Subject: [Haskell-cafe] Efficient functional idiom for histogram In-Reply-To: <87y6q4lgn9.fsf@gregorycollins.net> References: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> <87y6q4lgn9.fsf@gregorycollins.net> Message-ID: <79990c6b0907311539t545c650bw521a437324c58922@mail.gmail.com> 2009/7/31 Gregory Collins : > Paul Moore writes: > >> How would I efficiently write a function in Haskell to count >> occurrences of unique elements in a (potentially very large) list? For >> example, given the list [1,2,3,4,5,3,4,2,4] I would like the output >> [[1,1], [2,2], [3,2], [4,3], [5,1]] (or some equivalent >> representation). > > ? ?import qualified Data.Map as Map > ? ?import ? ? ? ? ? Data.Map (Map) > > ? ?histogram :: Ord a => [a] -> [(a,Int)] > ? ?histogram = Map.assocs . foldl f Map.empty > ? ? ?where > ? ? ? ?f m k = Map.insertWith (+) k 1 m Right. I see how that works, and can work out how to think about this sort of thing from your example. Thanks very much. BTW, I did know that Haskell had an efficient map implementation, I just wasn't sure how to use it "functionally" - I probably should have searched a bit harder for examples before posting. Thanks for the help in any case. Paul. From RafaelGCPP.Linux at gmail.com Fri Jul 31 18:41:05 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Fri Jul 31 18:22:05 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <931b9490907311324p2d974f4dnc25d9572d3ad0714@mail.gmail.com> References: <200907291826.30307.Sven.Panne@aedion.de> <20090729165525.GA23329@kira.casa> <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> <351ff25e0907291824g68de211id52c58939c2d275@mail.gmail.com> <20090730014703.GA19555@kira.casa> <351ff25e0907301631h2ab2201cwf854ce294ada1d83@mail.gmail.com> <351ff25e0907301723m479cd3b6yb5090067c6d14a23@mail.gmail.com> <931b9490907311324p2d974f4dnc25d9572d3ad0714@mail.gmail.com> Message-ID: <351ff25e0907311541g523632ebx427817d771f8e6cc@mail.gmail.com> Carter, It seems you need to install opengl-dev or something like that in your Linux instalation (using apt-get, yum or similar tool). Regards, Rafael On Fri, Jul 31, 2009 at 17:24, Carter Schonwald wrote: > I just the the rebuild of the haskell glut / opengl libs and I got the > following message > Configuring OpenGLRaw-1.0.1.0... > cabal: Missing dependency on a foreign library: > * Missing C library: GL > 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. > cabal: Error: some packages failed to install: > GLURaw-1.0.0.0 depends on OpenGLRaw-1.0.1.0 which failed to install. > OpenGL-2.3.0.0 depends on OpenGLRaw-1.0.1.0 which failed to install. > OpenGLRaw-1.0.1.0 failed during the configure step. The exception was: > > > and I don't see how to get the openglraw to build or what has changed > > thanks for any help > -Carter > > On Thu, Jul 30, 2009 at 8:23 PM, Rafael Gustavo da Cunha Pereira Pinto < > RafaelGCPP.Linux@gmail.com> wrote: > >> Here is a patch that makes it compile, but then it breaks all code >> developed for GLFW-0.3, as all Floats need to be changed to CFloat. >> >> For all haskellers here: >> >> Sorry for all this annoyance, but I was starting to study those libraries >> (OpenGL, GLUT and GLFW) using Haskell and the update broke some of my code. >> >> >> Best Regards, >> >> Rafael >> >> >> _______________________________________________ >> 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 > > -- Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090731/4ee2ea09/attachment.html From dons at galois.com Fri Jul 31 18:43:49 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 31 18:26:51 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <87my6k5vlo.wl%jeremy@n-heptane.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> <87ocr05y27.wl%jeremy@n-heptane.com> <20090731214903.GA809@whirlpool.galois.com> <87my6k5vlo.wl%jeremy@n-heptane.com> Message-ID: <20090731224349.GB3854@whirlpool.galois.com> jeremy: > At Fri, 31 Jul 2009 14:49:03 -0700, > Don Stewart wrote: > > > > Why don't you use your own instance to serialize IxSet lazily (or > > however you would like?) > > > > There's no reason to be constrained to use the [a] instance. > > Well, the Set instance might actually be a better choice. But the Set > instance in Binary uses [a] anyway :) Plus, happstack applications do > also use Set and List in addition to IxSet. > > Is this issue with list fixable? If list can't be fixed, then perhaps > Set and IxSet can't be fixed for the same reason. But, I don't really > understand the reason yet. Oh, it is entirely possible to use a different instance, that has different semantics for lists. You want to write the list incrementally? -- Don From carter.schonwald at gmail.com Fri Jul 31 18:47:39 2009 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Fri Jul 31 18:29:00 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: OpenGL 2.3.0.0 In-Reply-To: <351ff25e0907311541g523632ebx427817d771f8e6cc@mail.gmail.com> References: <200907291826.30307.Sven.Panne@aedion.de> <20090729165525.GA23329@kira.casa> <351ff25e0907291817i2391f592qff2441deb0bfaf7d@mail.gmail.com> <351ff25e0907291824g68de211id52c58939c2d275@mail.gmail.com> <20090730014703.GA19555@kira.casa> <351ff25e0907301631h2ab2201cwf854ce294ada1d83@mail.gmail.com> <351ff25e0907301723m479cd3b6yb5090067c6d14a23@mail.gmail.com> <931b9490907311324p2d974f4dnc25d9572d3ad0714@mail.gmail.com> <351ff25e0907311541g523632ebx427817d771f8e6cc@mail.gmail.com> Message-ID: <931b9490907311547s5b2dc5f1oee7d63e13c041c67@mail.gmail.com> pardon if this is the wrong context to ask, but whats the approriate way to do that on os x? 2009/7/31 Rafael Gustavo da Cunha Pereira Pinto > Carter, > > It seems you need to install opengl-dev or something like that in your > Linux instalation (using apt-get, yum or similar tool). > > Regards, > > Rafael > > > On Fri, Jul 31, 2009 at 17:24, Carter Schonwald < > carter.schonwald@gmail.com> wrote: > >> I just the the rebuild of the haskell glut / opengl libs and I got the >> following message >> Configuring OpenGLRaw-1.0.1.0... >> cabal: Missing dependency on a foreign library: >> * Missing C library: GL >> 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. >> cabal: Error: some packages failed to install: >> GLURaw-1.0.0.0 depends on OpenGLRaw-1.0.1.0 which failed to install. >> OpenGL-2.3.0.0 depends on OpenGLRaw-1.0.1.0 which failed to install. >> OpenGLRaw-1.0.1.0 failed during the configure step. The exception was: >> >> >> and I don't see how to get the openglraw to build or what has changed >> >> thanks for any help >> -Carter >> >> On Thu, Jul 30, 2009 at 8:23 PM, Rafael Gustavo da Cunha Pereira Pinto < >> RafaelGCPP.Linux@gmail.com> wrote: >> >>> Here is a patch that makes it compile, but then it breaks all code >>> developed for GLFW-0.3, as all Floats need to be changed to CFloat. >>> >>> For all haskellers here: >>> >>> Sorry for all this annoyance, but I was starting to study those libraries >>> (OpenGL, GLUT and GLFW) using Haskell and the update broke some of my code. >>> >>> >>> Best Regards, >>> >>> Rafael >>> >>> >>> _______________________________________________ >>> 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 >> >> > > > -- > Rafael Gustavo da Cunha Pereira Pinto > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090731/9d4928ef/attachment.html From jeremy at n-heptane.com Fri Jul 31 19:15:02 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Jul 31 18:56:05 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <20090731224349.GB3854@whirlpool.galois.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> <87ocr05y27.wl%jeremy@n-heptane.com> <20090731214903.GA809@whirlpool.galois.com> <87my6k5vlo.wl%jeremy@n-heptane.com> <20090731224349.GB3854@whirlpool.galois.com> Message-ID: <87ljm45ts9.wl%jeremy@n-heptane.com> At Fri, 31 Jul 2009 15:43:49 -0700, Don Stewart wrote: > Oh, it is entirely possible to use a different instance, that has > different semantics for lists. You want to write the list > incrementally? I don't think so. In happstack, the idea is to have all your state in RAM. But, since your machine sometimes goes down, etc, we also want to back it up to disk so we can restore the state after a reboot. There has also been talk recently about writing the state to /dev/null after we restore to make sure it has really been successful decoded. We don't want to lazily find out that there is undecodable data. So, the desired experience would be: 1. A program starts running and populates an IxSet. At this point in time n MB of RAM are being used. 2. We use Binary to snapshot the entire IxSet to disk. Since encode outputs an lazy ByteString, I would expect only a modest amount of additional memory to be required during this process. After the snapshot has been completed, I would expect the app to only be using around n MB of RAM. 3. the application exits and restarts 4. the application reads in the saved IxSet from disk. Afterwords it uses only around n MB of RAM. Instead, it seems like reading the state in from disk results in, n * 60, the amount of RAM being used. I am not really clear on why. It seems like the serialized version of the list is going to be *smaller* than original list, since the original list has all sorts of pointers and thunks. So, even if decode used a strict ByteString I would expect less than 2x the memory usage... Where am I going wrong here? Thanks! - jeremy From jeremy at n-heptane.com Fri Jul 31 19:32:53 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Jul 31 19:13:53 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <87ljm45ts9.wl%jeremy@n-heptane.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> <87ocr05y27.wl%jeremy@n-heptane.com> <20090731214903.GA809@whirlpool.galois.com> <87my6k5vlo.wl%jeremy@n-heptane.com> <20090731224349.GB3854@whirlpool.galois.com> <87ljm45ts9.wl%jeremy@n-heptane.com> Message-ID: <87k51o5syi.wl%jeremy@n-heptane.com> Hrm, I think actually, that my test program was a bit bogus... investigating now. - jeremy From jeremy at n-heptane.com Fri Jul 31 19:38:16 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Jul 31 19:19:18 2009 Subject: [Haskell-cafe] why does the binary library require so much memory? In-Reply-To: <87k51o5syi.wl%jeremy@n-heptane.com> References: <87prbg607u.wl%jeremy@n-heptane.com> <20090731212730.GX809@whirlpool.galois.com> <87ocr05y27.wl%jeremy@n-heptane.com> <20090731214903.GA809@whirlpool.galois.com> <87my6k5vlo.wl%jeremy@n-heptane.com> <20090731224349.GB3854@whirlpool.galois.com> <87ljm45ts9.wl%jeremy@n-heptane.com> <87k51o5syi.wl%jeremy@n-heptane.com> Message-ID: <87iqh85spj.wl%jeremy@n-heptane.com> Ok, I fixed my test program, and now things seem more reasonable. The original version was allowing the GC to collect the list in the first case, but not the second. However, I don't want the list to be collected. The new version seems to fix that issue. Now the control uses 40MB and when I change it to list' it uses 64MB. Which is more reasonable. main :: IO () main = let list = [1..1000000] :: [Int] bin = encode list list' = decode bin :: [Int] in do putStrLn (show . length $ takeWhile (< 10000000) list) getLine putStrLn (show . length $ takeWhile (< 10000001) list) From jwlato at gmail.com Fri Jul 31 19:45:58 2009 From: jwlato at gmail.com (John Lato) Date: Fri Jul 31 19:26:59 2009 Subject: [Haskell-cafe] Re: Strange memory usage problem Message-ID: <9979e72e0907311645m598444b6vf362cf12d909b304@mail.gmail.com> > From: Ketil Malde > > Hi, > > I'm observing something I find quite strange. ?I have a program that > normally streams through a file, and it runs in the expected constant > space, consuming about 5MB, according to 'top'. ?When I uncomment a > certain block of code in the library it uses, space consumption > appears to grow linearly with the input size. > > This is a bit surprising to me, since the code in question isn't used > by the program at all, and yesterday, Cale confirmed this behavior on > a recent GHC (6.10.3, I think - mine is 6.8.2 as shipped with Ubuntu > 9.04). > I can confirm this behavior on GHC 6.10.4 on OSX 10.5.7. Try adding {-# INLINE getRB #-} above the getRB definition. That fixes it for me. I think that when the rest of the code is commented out, getRB is only called in one location, so GHC inlines it automatically. Since getRB is also called in the commented-out code, it probably isn't automatically inlined when that code is available. I suspect that the inlining allows GHC to infer some strictness property it otherwise can't. Cheers, John Lato From deniz.a.m.dogan at gmail.com Fri Jul 31 19:54:56 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Fri Jul 31 19:35:57 2009 Subject: [Haskell-cafe] Efficient functional idiom for histogram In-Reply-To: <79990c6b0907311539t545c650bw521a437324c58922@mail.gmail.com> References: <79990c6b0907311339o17930eaej193b39e176f601a4@mail.gmail.com> <87y6q4lgn9.fsf@gregorycollins.net> <79990c6b0907311539t545c650bw521a437324c58922@mail.gmail.com> Message-ID: <7b501d5c0907311654k1ea83162ud7ac33821ac8b3c8@mail.gmail.com> 2009/8/1 Paul Moore : > BTW, I did know that Haskell had an efficient map implementation, I > just wasn't sure how to use it "functionally" - I probably should have > searched a bit harder for examples before posting. Thanks for the help > in any case. Know that Data.Map uses size balanced trees and is not e.g. a hash map. -- Deniz Dogan From dons at galois.com Fri Jul 31 20:01:07 2009 From: dons at galois.com (Don Stewart) Date: Fri Jul 31 19:44:10 2009 Subject: [Haskell-cafe] ANNOUNCE: The Haskell Platform 2009.2.0.2 Message-ID: <20090801000107.GM3854@whirlpool.galois.com> We're pleased to announce the third release of the Haskell Platform: a single, standard Haskell distribution for everyone. The specification, along with installers (including Windows and Unix installers for a full Haskell environment) are available. Download the Haskell Platform 2009.2.0.2: http://hackage.haskell.org/platform/ The Haskell Platform is a single, standard Haskell distribution for every system, in the form of a blessed library and tool suite for Haskell distilled from the thousands of libraries on Hackage, along with installers for a wide variety of systems. It saves developers work picking and choosing the best Haskell libraries and tools to use for a task. When you install the Haskell Platform, you get the latest stable compiler, an expanded set of core libraries, additional development tools, and cabal-install ? so you can download anything else you need from Hackage. What you get: http://hackage.haskell.org/platform/contents.html With regular time-based releases, we expect the platform will grow into a rich, indispensable development environment for all Haskell projects. Since the first release, there have been over 100,000 downloads of the installers. Thanks! -- The Platform Infrastructure Team