[Haskell-cafe] Type Directed Name Resolution
John Lask
jvlask at hotmail.com
Thu Nov 11 20:16:26 EST 2010
On 12/11/2010 9:22 AM, Richard O'Keefe wrote:
>
> On 12/11/2010, at 2:17 AM, Michael Snoyman wrote:
>>> So why would you ever need to reuse the same field name in the same
>>> module?
>>
>> data PetOwner
>> data FurnitureOwner
>>
>> data Cat = Cat { owner :: PetOwner }
>> data Chair = Chair { owner :: FurnitureOwner }
>>
>> Just the first thing that came to mind, this kind of thing comes up
>> often enough to be an irritant. I'm not sure whether or not TDNR is a
>> good solution to the problem, just pointing out a use case.
>
> I'm afraid it's not a *convincing* use case.
> It's not convincing because here "owner" *means different things*.
consider "length" ...
I have records with the attribute length, length can be given as an Int,
Double, Float or maybe as a constructed type "Length", length's use as a
record selector would also clash with List.length. All these have the
same denotation.
should I then seporate into int_length, float_length, or use
rec1_length, rec2_length etc etc...
for proper name space management why should I have to define each record
that defines a length field with different representation in distinct
modules, or with different names for the field label when they denote
the same thing?
This is easily handled in C, Pascal, PL/1, Cobol why not in Haskell ?
More information about the Haskell-Cafe
mailing list