Re: [Haskell-cafe] A backwards-compatible record proposal

2006-08-20 Thread Brian Hulley
Bulat Ziganshin wrote: Hello Brian, Saturday, August 19, 2006, 12:21:34 PM, you wrote: ie putting a '.' before each field name. The intended meaning is that dotted field names do *not* generate top level functions. Instead they allow the compiler to generate instance decls as follows, where we

Re: [Haskell-cafe] A backwards-compatible record proposal

2006-08-19 Thread Bulat Ziganshin
Hello Brian, Saturday, August 19, 2006, 12:21:34 PM, you wrote: > ie putting a '.' before each field name. The intended meaning is that dotted > field names do *not* generate top level functions. Instead they allow the > compiler to generate instance decls as follows, where we've introduced a new

Re: [Haskell-cafe] A backwards-compatible record proposal

2006-08-19 Thread Brian Hulley
Brian Hulley wrote: However I think it could be solved by a more complex desugaring: The proposed desugarings allow us to either make all dotted fields in a record visible, or none of them visible, but I don't think there exists a desugaring that would allow some to be visible while others we

Re: [Haskell-cafe] A backwards-compatible record proposal

2006-08-19 Thread Brian Hulley
Ooops! ;-) Brian Hulley wrote: module M (Rec, use) where import DotClasses.Dot_f-- every class has its own module (*) data Rec' a = Rec a newtype Rec a = Rec (Rec' a) instance Dot__f (Rec' a) a where instance Dot_f (Rec' a) a where __dot_f (Rec' x) = x

Re: [Haskell-cafe] A backwards-compatible record proposal

2006-08-19 Thread Brian Hulley
Bernard James POPE wrote: On Sat, Aug 19, 2006 at 09:21:34AM +0100, Brian Hulley wrote: Therefore I think the desugaring would need to take place in the compiler so the compiler could avoid exporting the compiler-generated instances when the fields are not present in the module export list. I'

Re: [Haskell-cafe] A backwards-compatible record proposal

2006-08-19 Thread Bernard James POPE
On Sat, Aug 19, 2006 at 09:21:34AM +0100, Brian Hulley wrote: > Therefore I think the desugaring would need to take place in the compiler > so the compiler could avoid exporting the compiler-generated instances when > the fields are not present in the module export list. I'm not entirely sure I

Re: [Haskell-cafe] A backwards-compatible record proposal

2006-08-19 Thread Brian Hulley
Brian Hulley wrote: In the module containing the data decl for the record, the compiler inserts the following: instance (.x) (Vector3 a) a where (.x) v = ... -- compiler generated code to access the field instance (.x) (Vector3 a) a where (.x) Vector3{.x = x} = x

[Haskell-cafe] A backwards-compatible record proposal

2006-08-19 Thread Brian Hulley
Hi - As I've been writing a Haskell program over the past few months the main problem I encounter is that record field names are not local to the record type, and any systematic way of making them local (eg by prepending "_Tycon_") results in names that are just too clunky, and I feel that ide