On Mon, Feb 20, 2012 at 4:41 AM, AntC <anthony_clay...@clear.net.nz> wrote: > Folks, I've put my 'Record in Haskell' proposal on the wiki > http://hackage.haskell.org/trac/ghc/wiki/Records as suggestion 5 Declared > Overloaded Record Fields. > > Thanks to the voiciferousness on this thread, dot notation is completely > optional. > > Feedback welcome.
Thanks for writing it up, I admit I was having trouble following across the various email threads. Surprisingly, your ideas are very similar to my own. I'm not sure if this is a good thing or a bad sign, but naturally I'm in favor. I was wondering whether it wouldn't make sense to have some syntax within the record itself, instead of at the top level, to declare, "I'm definitely declaring a new record field", versus "I'm definitely re-using an existing record field", versus "If this record field already exists I'm re-using it, otherwise I'm declaring it". (It doesn't necessarily make sense to have all three - the second one might be cumbersome, or the third one might be error-prone - but they seem like the options.) The existing, unadorned record syntax would mean "I'm definitely declaring a new record field", because that's what it already means. Simply leaving off the type annotation to indicate otherwise sadly wouldn't work because, as you mention, that means that it's the same type as the next field. So something like: data Rec1 = Rec1 { field1 :: Int, field2 :: Char } -- declare field1 :: Int and field2 :: Char fields data Rec2 = Rec2 { import field1, field3 :: String } -- reuse field1 :: Int, declare field3 :: String data Rec3 = Rec3 { field3 :: String } -- declare field3 :: String, but error: already declared Hopefully someone can think of better syntax than my "import field1" above. Regarding the polymorphic update / higher-rank fields issues, I'm not competent to address them in earnest, but: isn't this primarily an ImpredicativeTypes issue? If GHC had full support for ImpredicativeTypes (whatever that means), would it work? ~g _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe