... | ... | @@ -40,6 +40,18 @@ record.hs:2:34: |
|
|
In the Persistent data store library, Yesod works around the issue by having the standard of prefixing every record field with the record name (`recordA` and `recordClashA`). But besides being extremely verbose, it also limits us from experimenting with more advanced features like a partial record projection or an unsaved and saved record type.
|
|
|
|
|
|
|
|
|
Never mind experimental/advanced features, it gets in the way of doing utterly dull things like:
|
|
|
|
|
|
- look up an entity by name (such as a customer or dictionary entry)
|
|
|
- get its identifier xxx_id
|
|
|
- link that same field name xxx_id in other record types to create/read/update/delete,
|
|
|
- without having to copy the darn value to xyz_id, pqr_id, ...
|
|
|
|
|
|
|
|
|
And inhibits doing relatively low-level generic/polymorphic stuff like standard print-formatting for any records with lastName and firstName fields.
|
|
|
-- added by AntC 21-Feb-2012
|
|
|
|
|
|
|
|
|
The verbose name-spacing required is an in-your-face, glaring weakness telling you there is something wrong with Haskell. This issue has been solved in almost every modern programming languages, and there are plenty of possible solutions available to Haskell.
|
|
|
|
|
|
## Solutions
|
... | ... | @@ -91,8 +103,10 @@ The advantage of Namespacing is that the implementation is clear, straightforwar |
|
|
|
|
|
The discussion has many similarities with the original Type directed name resolution proposal: the question seems to be largely about nailing down a concrete implementation. The original TDNR proposal had Overloading in mind, but Namespacing ends up having similarities. -- Greg Weber
|
|
|
|
|
|
~~All~~ Most of the name-space mechanisms require some level of user-supplied disambiguation: if there are two fields `a` in scope, you must use a qualified name to disambiguate them. What is tantalising about this is that the *type* of the argument immediately specifies which one you mean. There is really no ambiguity at all, so it is frustrating to have to type qualified names to redundantly specify that information. Object-oriented languages take for granted this form of type-directed disambiguation.
|
|
|
|
|
|
|
|
|
All of the name-space mechanisms require some level of user-supplied disambiguation: if there are two fields `a` in scope, you must use a qualified name to disambiguate them. What is tantalising about this is that the *type* of the argument immediately specifies which one you mean. There is really no ambiguity at all, so it is frustrating to have to type qualified names to redundantly specify that information. Object-oriented languages take for granted this form of type-directed disambiguation.
|
|
|
Haskell already has a (tried and tested) mechanism to disambiguate where "the *type* of the argument immediately specifies which one you mean" -- namely class/method/instance resolution. The DORF proposal uses this mechanism (and this mechanism alone: no funny-hand-shake syntax) -- AntC 21-Feb-2012
|
|
|
|
|
|
|
|
|
One particular way of integrating this idea into Haskell is called (TDNR). Proposed a couple of years ago, the Haskell community didn't like it much. (But I still do; SLPJ.) |