[Haskell-cafe] data types with overlapping component names (in one module)?

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Tue Apr 16 14:17:08 CEST 2013


What is the current situation: can we have two types 
with overlapping component names in one module?

module M where
data T1 = C1 { foo :: Int }
data T2 = C2 { foo :: String }

It seems not (ghc says: Multiple declarations of 'foo'). This comes close:
http://www.haskell.org/ghc/docs/7.6.2/html/users_guide/syntax-extns.html#disambiguate-fields
but still requires the definitions to reside in different modules?

This is a major pain (it forces me to spread the source over several files),
and also a show-stopper when selling Haskell to OO folks, who "naturally"
assume that a class also denotes a scope. (And that you could nest them.)

Are/were there plans/proposals to address this? 

- J.W.





More information about the Haskell-Cafe mailing list