Field labels must be globally unique?
Andrew J Bromage
ajb@spamcop.net
Wed, 8 Jan 2003 15:10:59 +1100
G'day all.
On Tue, Jan 07, 2003 at 10:01:38PM -0600, Kim-Ee Yeoh wrote:
> Why can't field labels have the same name in different types?
Because it would generate two functions with the same name.
> I'm not an expert on programming languages, but doesn't it seem
> that Haskell, as a strongly-typed language, should not have any problem
> distinguishing the field labels of different datatypes?
There are two possible ways to get around it.
One is to allow function overloading. This is probably not desirable
because it turns type checking into an NP-hard problem.
The other is to make a record introduce a new namespace. We've
discussed this previously, and I think the consensus was that it's
a good idea in theory, but it was too incompatible with Haskell 98.
Were there any other objections? I can't remember.
Cheers,
Andrew Bromage