[Haskell-cafe] RFE: Extensible algebraic user-defined data types?
Simon Peyton-Jones
simonpj at microsoft.com
Fri Apr 29 03:50:15 EDT 2005
| 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
More information about the Haskell-Cafe
mailing list