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
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
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
Re: Punning: Don't fix what ain't broken.
| > * 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} This brings us to another issue. Doesn't the following definition look a bit awkward? R{ x = x } At first sight, it looks like it means: R{ x = bottom } But it doesn't. Why does a binding using `=' suddenly have another meaning then usual? I think R{ x = f x } should just mean: let x' = f x' in R{ x = x' }. Moreover, look at the following two expressions: R{ a = b }, let f R{ a = b } = 3 in f. In the first one, the variable (field name) a is bound to b. In the second one, the variable b is bound to the field name a. Why is it suddenly the case that variables on the right hand side of an `=' sign get bound? I can see two solutions to these problems: - make `=' inside records work like they work in `let's. That is, recursive definitions work, and binding is always done on the left hand side. - choose another symbol than `='. It is confusing otherwise! But of course, introducing these kind of changes will break existing Haskell programs... Regards, Koen. -- Koen Claessen, [EMAIL PROTECTED], http://www.cs.chalmers.se/~koen, Chalmers University of Technology.