Changes between Version 20 and Version 21 of Records/DeclaredOverloadedRecordFields/ImplementorsView


Ignore:
Timestamp:
Mar 3, 2012 10:28:47 AM (2 years ago)
Author:
AntC
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Records/DeclaredOverloadedRecordFields/ImplementorsView

    v20 v21  
    6464data Cust_AdHoc = CustAH{ customer_id :: Int, x, y :: String } sharing (customer_id) deriving (...) 
    6565}}} 
    66 For the non-shared x and y, saves the burden of a `fieldLabel`, by declaring it for you: 
     66For the non-`shareing` `x` and `y`, saves the burden of a `fieldLabel`, by declaring it for you: 
    6767{{{ 
    6868        data Proxy_x 
     
    7070        x r = get r (undefined :: Proxy_x) 
    7171}}} 
    72 So field selector function x has the same type (in effect) as would have the H98 field selector. 
     72So field selector function `x` has the same type (in effect) as would have the H98 field selector. 
     73 
     74For this variation: 
     75{{{ 
     76        data Customer_Order = Cust_Order { customer_id :: Int, order_num :: Int, ... } 
     77                          sharing (customer_id) share (order_num) deriving (...) 
     78}}} 
     79 
     80The `share` fields are declared at this point -- generate the Proxy and the (overloadable) field selector. 
     81 
     82Pros, compared with Option One or Two: 
     83 * No extra declaration style; nor innocuous-looking declaration with unobvious effects 
     84Cons: 
     85 * This obscures the approach of declaring a data dictionary first. 
     86 * May lead to 'dependency hell' between record types. 
     87 * Prevents putting class constraints on the record type argument to the selector function. 
     88 * Prevents putting class constraints on the field type result from the function. 
     89 
     90Perhaps the data dictionary/dependency hell could be avoided with a dummy record type to declare all the shared fields: 
     91{{{ 
     92        data Customer_fieldLabels = Cust_fLabs{ customer_id :: Int, lastName, firstName :: String, 
     93                                                product_id :: Int, ... 
     94                                                order_num :: Int, ... 
     95                                              }                          share (All) 
     96}}} 
     97 
     98(This was a typical kludge on the System/38.) 
    7399 
    74100