On Wed, Sep 09, 2009 at 07:08:25PM -0400, David Roundy wrote:
But field names are also function names, which are values, and live in the same namespace. That's what makes it so confusing (to me). If you fail to see those two little . then you end up reading the code completely wrong. It remains syntactically valid, but fails to type check. But humans are very bad (or perhaps I should say *I* am very bad) at type inference, so it can take a very long time to figure out where the error lies.
The fact that there happens to be a field name and a function name that are textually the same does not actually cause them to be related. For instance, the following is valid: data Foo = Foo { foo :: Int } deriving(Show) main = do let foo = 4 print Foo { foo = foo } the name to the left of the '=' sign is looked up in the field namespace, the value on the right is looked up in the value namespace, which are unrelated. shadowing in one doesn't affect the other. a decaration like the data Foo above declares both a value 'foo' and a field selector 'foo'. It is annoying that the haskell module system doesn't allow fine control of what you are actually importing and exporting, forcing things like having to have distinct type and class names, even though they are in distinct namespaces and shouldn't collide. John -- John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/