Field labels must be globally unique?

Kim-Ee Yeoh yeoh@cs.wisc.edu
Tue, 7 Jan 2003 22:01:38 -0600 (CST)


Dear Haskellers,

Why can't field labels have the same name in different types?

Here's some actual code on finite state automata I'm working on:

> data BMC
>   = BMC { node      :: !Int, 
>           threshold :: !Float, 
>           edge0     :: BMC, 
>           edge1     :: BMC }

> data BFSM
>   = BFSM { bfsmnode      :: !Int,
>            bfsmstate     :: Maybe Bool,
>            bfsmoutput    :: [Bool],
>            bfsmedge0     :: BFSM, 
>            bfsmedge1     :: BFSM }

What I really want is to use the same field labels of node, edge0, and 
edge1 in the BFSM type, but I can't because otherwise I get the following
in hugs:

ERROR xxx - Repeated definition for selector "edge0"

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?


Kim-Ee