Почему Haskell/GHC не поддерживает перегрузку имени записи

Я новичок в Haskell. Я заметил, что Haskell не поддерживает перегрузку имени записи:

-- Records.hs

data Employee = Employee
  { firstName :: String
  , lastName :: String
  , ssn :: String
  } deriving (Show, Eq)

data Manager = Manager
  { firstName :: String
  , lastName :: String
  , ssn :: String
  , subordinates :: [Employee]
  } deriving (Show, Eq)

Когда я компилирую это, я получаю:

[1 of 1] Compiling Main             ( Records.hs, Records.o )

Records.hs:10:5:
    Multiple declarations of `firstName'
    Declared at: Records.hs:4:5
                 Records.hs:10:5

Records.hs:11:5:
    Multiple declarations of `lastName'
    Declared at: Records.hs:5:5
                 Records.hs:11:5

Records.hs:12:5:
    Multiple declarations of `ssn'
    Declared at: Records.hs:6:5
                 Records.hs:12:5

Учитывая «силу» системы типов Haskell, кажется, что компилятору должно быть легко определить, какое поле для доступа в

emp = Employee "Joe" "Smith" "111-22-3333"
man = Manager "Mary" "Jones" "333-22-1111" [emp]
firstName man
firstName emp

Есть ли какая-то проблема, которую я не вижу. Я знаю, что Haskell Report этого не допускает, но почему бы и нет?

15
задан Ralph 19 June 2012 в 11:52
поделиться