> {-# OPTIONS_GHC -XDisambiguateRecordFields -XNamedFieldPuns -XRecordWildCards #-}
> {-# OPTIONS_GHC -XTypeFamilies	-XFlexibleContexts			#-}
> {-# OPTIONS_GHC -XRankNTypes  -XImpredicativeTypes -XGADTs -XEmptyDataDecls	#-}
> {-# OPTIONS_GHC -XMultiParamTypeClasses -XFlexibleInstances -XUndecidableInstances   #-}

> module DORFCRM	where
>
>  import DORF    hiding (lastName, firstName, Proxy_lastName, Proxy_firstName)
>                                                         -- Note: import is _not_ qualified


------------------ fieldLabel decls (for 'monomorphic' fields) -------------------------------------

   -- fieldLabel customer_id :: r -> Int                  -- already decl'd in Module DORF
                                                          -- so we're going to share it


   fieldLabel firstName :: r -> String                    -- same Label as in the imported module, but we've hidden the import

>  data Proxy_firstName
>  -- firstName :: (Has r Proxy_firstName t, t ~ String) => r -> String
>  firstName r = get r (undefined :: Proxy_firstName)
>
>  type instance GetResult r Proxy_firstName t = String    -- firstName always a String, for all record types
>

   fieldLabel lastName :: r -> String                     -- also same label as in imported DORF

>  data Proxy_lastName
>  -- lastName :: (Has r Proxy_lastName t, t ~ String) => r -> String
>  lastName r = get r (undefined :: Proxy_lastName)
>
>  type instance GetResult r Proxy_lastName t = String    -- firstName always a String, for all record types


------------------Virtual field definition (note no Has instance needed, so no need to worry about set) ----

>  -- fullName r = firstName r ++ " " ++ lastName r           -- is imported from DORF
>                                                             -- but defined only for DORF.firstName, DORF.lastName



------------------Record decl, and Has instance generated (for 'monomorphic' fields)----------------------------

>  data Customer_Contact = Cust_Cont { customer_id____ :: Int, firstName__, lastName__ :: String }
>                              deriving (Eq, Show, Read)
>                                                    -- suffixing the field name to avoid clash
>
>  type instance SetResult Customer_Contact fld t = Customer_Contact
>                                        -- Customer_Contact has no type params
>
>                                        -- note: GetResult type instances already decl'd, by field
>
>  instance (t ~ Int) => Has Customer_Contact Proxy_customer_id t         where   -- using imported customer_id
>      get Cust_Cont{customer_id____} _ = customer_id____
>      set _ x Cust_Cont{..}  = Cust_Cont{customer_id____ = x, .. }
>
>  instance (t ~ String) => Has Customer_Contact Proxy_firstName t        where   -- using local firstName
>      get Cust_Cont{firstName__} _ = firstName__
>      set _ x Cust_Cont{..}  = Cust_Cont{firstName__ = x, .. }
>
>  instance (t ~ String) => Has Customer_Contact Proxy_lastName t         where   -- using local lastName
>      get Cust_Cont{lastName__} _ = lastName__
>      set _ x Cust_Cont{..}  = Cust_Cont{lastName__ = x, .. }
>

----------------- tests ---------------------------------------------------------------------------------------

>  rCC1 =   Cust_Cont{ customer_id____ = 57, firstName__ = "Fred", lastName__ = "Daggy" }
>
>  -- customer_id rCC1    ==> 57                                -- sharing customer_id
>  -- firstName rCC1 ++ " " ++ lastName tCC1      ==> "Fred Daggy"
>
>  -- lastName rCN0       ==>  No instance for (Has Customer_NameAddress Proxy_lastName t0)
>  --                               arising from a use of `lastName'
>  -- DORF.lastName rCC1  ==> No instance for (Has Customer_Contact DORF.Proxy_lastName t0)
>  --                              arising from a use of `DORF.lastName'
>
>  -- fullName    rCC1    ==> No instances for (Has Customer_Contact DORF.Proxy_firstName t0,
>  --                                            Has Customer_Contact DORF.Proxy_lastName t10)
>  --                              arising from a use of `fullName'
>

     To explain that failure on fullName:
          We imported fullName, defined against the fieldLabel proxys in Module DORF.
          And we imported customer_id defined similarly,
                 instanced Customer_contact against the shared Proxy_customer_id
          But we defined local versions of the name fieldLabels,
                 so fullName wasn't instanced against them.

     This shows that within a single record decl:
          1. You can create fields that share Labels with imports.
          2. You can create fields that don't share, even with the same Label name.
                 (That is, the module system continues to control the namespace.)
          3. You can prevent using the wrong field selector with the wrong record type,
                 even if they have the same Label name.


