Changes between Version 44 and Version 45 of Records


Ignore:
Timestamp:
Feb 21, 2012 2:06:02 AM (2 years ago)
Author:
guest
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Records

    v44 v45  
    2828 
    2929In 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. 
     30 
     31Never mind experimental/advanced features, it gets in the way of doing utterly dull things like: 
     32 * look up an entity by name (such as a customer or dictionary entry) 
     33 * get its identifier xxx_id 
     34 * link that same field name xxx_id in other record types to create/read/update/delete, 
     35 * without having to copy the darn value to xyz_id, pqr_id, ... 
     36And inhibits doing relatively low-level generic/polymorphic stuff like standard print-formatting for any records with lastName and firstName fields. 
     37-- added by AntC 21-Feb-2012 
    3038 
    3139The 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. 
     
    7684The 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 
    7785 
    78 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. 
     86~~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. 
     87 
     88Haskell 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 
    7989 
    8090One 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.)