RE: [Haskell-cafe] RFE: Extensible algebraic user-defined data types?

| Regarding reusing constructor names across several datatypes: is it | possible to qualify them with their enclosing datatype name, like | Maybe.Nothing where there is a name conflict? Then I might reuse | Nothing in my hypothetical data type, and it would be NEither.Nothing | if conflicting with Maybe.Nothing Yes, this'd occasionally be useful regardless of extensible data types, particularly constructor fields too. E.g. "T.x" could mean "field x from type T". There's a difficulty about parsing the name though. Does Neither.Nothing mean the constructor imported from module Neither or the constructor Nothing from type Neither In these days of lazy ambiguity resolution, though, it's not so bad. We could just say that "Neither.Nothing" names *both* of those things, and if both exist in the current scope, you need to disambiguate by adding further module qualifiers. This is one of those features that's hard to evaluate: modest gain in expressiveness, and modest increase in complexity. Simon

On Fri, 29 Apr 2005, Simon Peyton-Jones wrote:
| Regarding reusing constructor names across several datatypes: is it | possible to qualify them with their enclosing datatype name, like | Maybe.Nothing where there is a name conflict? Then I might reuse | Nothing in my hypothetical data type, and it would be NEither.Nothing | if conflicting with Maybe.Nothing
This is one of those features that's hard to evaluate: modest gain in expressiveness, and modest increase in complexity.
For people sticking to the scheme that each module implements one principal data type, give prefix-less function, accessor, and constructor names and call them by qualification, the need for such a feature is reduced.

Please forgive this interruption...
E-mail I try to send to frequent contributor Henning Thielemann
participants (3)
-
Dean Herington
-
Henning Thielemann
-
Simon Peyton-Jones