[Haskell-cafe] Type Directed Name Resolution
Richard O'Keefe
ok at cs.otago.ac.nz
Thu Nov 11 17:52:54 EST 2010
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*.
The genius of typeclasses was that it gave us a way to implement
functions differently for different types while still referring
all the implementations to a single interface, so that they should
all in _some_ sense mean the same thing.
If x owns a pet, then x is responsible for providing it with
food, water, shelter, and medical treatment, and can be gaoled
for failing to do so.
If y owns a chair, then y can sit on it, spray it with
mayonnaise, smash it to pieces, burn it to ashes, or do pretty
much anything y pleases. There is no duty to provide a pet
chair with food, water, &c.
There was a German case a couple of years ago where a man
described a fantasy of his on the internet and asked for
a volunteer to help him carry it out in reality. He got
one. The other man came to his flat, they had sex, and
then the first man killed the other and ate him.
My take on this was that there were things you *can't*
consent to. The colleague I discussed it with a couple
of days ago said "If I don't own my body, I own nothing"
and said that owning your own body had to mean having the
right to volunteer to killed and eaten. He's such a nice
man, my colleague, and deeply skilled in logic.
Thinking about this, I came to the conclusion that when
he and I say "my body" we mean different things.
I mean INalienable possession, he means alienable possession.
It's like the difference between a dog's meat (food for the
dog from another animal, take it away and the dog is
hungry) and a dog's flesh (the dog's own matter, take it
away and there is no dog).
There's that rather silly piece in Plato's Republic where
he says "Both the community of property and the community
of families ... tend to make them more truly guardians;
they will not tear the city in pieces by differing about
"mine" and "not mine"; ... but all will be affected as far
as may be by the same pleasures and pains ..."
Since when can my hunger be the same as your hunger?
Since when can my bladder discomfort (I've been sitting at
this keyboard too long) be the same as yours?
Since when can your pleasure in eating onions be the same
as mine (I _hate_ onions, and even if I didn't, I wouldn't
want to eat the _same_ bits of onion you're eating).
Greek didn't distinguish between alienable and inalienable
possession. If that kind of ambiguity can lead the most
famous philospher in history to write twaddle, what is
confusion in our function names going to do to Haskell
programmers?
TDNR has the same attractiveness as a sugar coated laxative
tablet, and I expect the end product of both to be the same.
More information about the Haskell-Cafe
mailing list