[Haskell-cafe] Typeclasses for name punning (was: Re: I miss OO)
Hi all, On Wednesday 25 November 2009 22:46:42 Luke Palmer wrote: I feel like this should be qualified. Type classes are not for name punning ; you wouldn't use a type class for the method bark on types Tree and Dog. But if you have a well-defined *structure* that many types follow, then a type class is how you capture that. It sounds like you do have this structure in your example. Further, with typeclasses, you can write methods that are generic over any type with that structure. So: class Temporal a where time :: a - Time temporalOrder :: Temporal a = [a] - [a] temporalOrder = sortBy (comparing time) The ability to do this indicates why using them for punning is a bad idea. While I agree that this utility of typeclasses is lost if they are used for name punning, I'm still unconvinced that it is actively *harmful* to use classes for this lesser purpose :) I think punning is a worthwhile goal on its own, since I find myself wasting quite some thought on whether to prefix a record field name somehow, and if I do, what I should use as a short but sufficiently unique prefix. Greetings, Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Typeclasses for name punning (was: Re: I miss OO)
2009/11/27 Daniel Schüssler anotheraddr...@gmx.de I think punning is a worthwhile goal on its own, since I find myself wasting quite some thought on whether to prefix a record field name somehow, and if I do, what I should use as a short but sufficiently unique prefix. I agree, especially since it looks like the record situation is not about to be solved; for example by looking at the discussion generated by Simon Peyton-Jones's TDNR proposal (which I like, but I don't feel like my opinion should count on that matter ) David. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: punning in GHC?
Punning was removed from Haskell some while ago, I believe when Haskell 98 was fixed in Feb 1999. Indeed. However, due to popular demand, the feature was retained as an extension in Hugs (turn on with the -98 option) and nhc98 (turn on/off with the -puns/-nopuns options). Regards, Malcolm ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: punning in GHC?
Punning was removed from Haskell some while ago, I believe when Haskell 98 was fixed in Feb 1999. See the Preface section 0.4.1 Simon | -Original Message- | From: Iavor S. Diatchki [mailto:[EMAIL PROTECTED]] | Sent: 26 December 2001 18:55 | To: [EMAIL PROTECTED] | Subject: punning in GHC? | | | hi there, | | i just discovered that GHC does not support punning with the | -fglasgow-exts | option. is there another flag to turn this on or has it been | completely | removed? if so could we have it back - i really like the feature (in | patterns anyways) and use it (hugs -98 supports it). i don't | particularly | care that it is not in haskell 98 as i rarely write haskell | 98 programs. | | by the way before posting this i did a search on punning | through the | mailing list archive to see if someone asked this already. i | couldnt find | anything but it seems that since 1997 there were 7 posts on | punning and | all of them seemed to agree that it was a useful feature, so | why was it | removed? | | bye | iavor | | ___ | Haskell mailing list | [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell | ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
punning in GHC?
hi there, i just discovered that GHC does not support punning with the -fglasgow-exts option. is there another flag to turn this on or has it been completely removed? if so could we have it back - i really like the feature (in patterns anyways) and use it (hugs -98 supports it). i don't particularly care that it is not in haskell 98 as i rarely write haskell 98 programs. by the way before posting this i did a search on punning through the mailing list archive to see if someone asked this already. i couldnt find anything but it seems that since 1997 there were 7 posts on punning and all of them seemed to agree that it was a useful feature, so why was it removed? bye iavor ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Punning
George Russell wrote:Standard ML, I'm glad to say, has punning, and I don't remember it causing me any difficulties at all as a programmer or a compiler writer. (I wrote the parser in the latest version of MLj.) Please reverse this stupid ban in the next version of the Haskell standard! I totally agree. I don't understand why punning was removed. Punning on record creation might be a bit suspect, but on pattern matching I think it can only increase readability. -- -- Lennart
RE: Punning
Hi George, I believe that punning was taken out of Haskell 98 because of some (IMO, mistaken) concerns about renaming. If memory serves me, somebody had complained that punning `broke alpha-renaming'. For example, you can't treat (\x - C{x}) as being equivalent to (\y - C{y}) ... which all seems perfectly reasonable to me, and in just the same way that you wouldn't want (\x - "x") to be treated as being equivalent to (\y - "y"). The correct renaming of (\x - C{x}) is, of course, (\y - C{x=y}). So I think it was a mistake to remove punning. But that was what the Haskell committee decided, so Hugs 98 doesn't allow punning in Haskell 98 mode. It will, however, support punning in extended mode (run with the -98 flag). Hope that helps! Mark
Punning
Is there any chance that someone could send to me in Germany the head of the canting Puritan who outlawed punning in Haskell 98? I'm trying to migrate some code which makes heavy use of punning, and I'm about to yet again (for literally the thirtieth time) fix yet another (subtly different) constructor invocation to work according to the latest standard. I fail to see why XYZ { blahblahblah = blahblahblah, rhubarbrhubarbrhubarb = rhubarbrhubarbrhubarb } is any more maintainable or parsable than XYZ {blahblahblah,rhubarbrhubarbrhubarb} and it is certainly more error-prone and longer. Standard ML, I'm glad to say, has punning, and I don't remember it causing me any difficulties at all as a programmer or a compiler writer. (I wrote the parser in the latest version of MLj.) Please reverse this stupid ban in the next version of the Haskell standard!
Re: Punning: Don't fix what ain't broken.
Tommy Thorn wrote: Koen Claessen: This brings us to another issue. Doesn't the following definition look a bit awkward? R{ x = x } Definitely wierd. The left and right-hand side denotes two different things, which AFAIK is the only place where `=' behaves like this. Wouldn't `-' have been a better choice? `-' bindings are never recursive, thus `R{ x - x } is less surprising, as the two x's can't be the same. What about using constructor syntax: R{ X x } ? Not to be taken too seriously... - Andreas
Re: Punning: Don't fix what ain't broken.
Koen Claessen: This brings us to another issue. Doesn't the following definition look a bit awkward? R{ x = x } Definitely wierd. The left and right-hand side denotes two different things, which AFAIK is the only place where `=' behaves like this. Wouldn't `-' have been a better choice? `-' bindings are never recursive, thus `R{ x - x } is less surprising, as the two x's can't be the same. It would be worth taking into account if completely revising the record handling of Haskell, but in itself it's too small a gain to be worthwhile. My humble opinion, Tommy
Punning: Don't fix what ain't broken.
John Hughes wrote on the Std Haskell board: `Punning' can be used in three places in Haskell. Suppose a record type is defined by data R = R{x :: Int} Then * R{x} constructs a record, and is equivalent to R{x=x} * r{x} updates the x field of record r, and is equivalent to r{x=x} * R{x} can be used as a pattern; its meaning is not defined by the report, but is presumably supposed to be the same as R{x=x} I've used this. It's convenient, but I had a bad taste in my mouth afterwards. I support removing all forms of punning from the language. But this would, of course, break existing programs. I want to do it anyway. Note that the puns become syntactically incorrect in every case, so broken programs can be mended just by correcting the syntax errors. I'm surprised and disappointed with the Standard Haskell effort on punning. A grand total of two messages but absolutely no discussion and *pop* there it went down the pipe. Yes it convenient, and sometimes even very convenient. I can't see the value of arguments like "bad taste in the mouth". Why was it introduced in the first place? Are there any *known* examples where this feature has caused problems? As John notices, the punning form do not overlap syntactically with anything, so you can't used them by accident. Instead of junking it, I would rather have seen the pattern matching punning syntax (R{x}) become official, as this is the most useful of the three punning. /Tommy