[Haskell-cafe] type classes and logic

Patrick Browne patrick.browne at dit.ie
Sat Aug 28 06:17:39 EDT 2010


Daniel Fischer wrote:
>> class BEING human  => HUMAN human where
>> Sub-classing is logical implication BEING(human)  => HUMAN(human)
>> All types t that make BEING(t) = true also make HUMAN(t)=true
> 
> No, it's the other way round. Every HUMAN is also a BEING, hence
> 
> HUMAN(t) => BEING(t)

Could I say that HUMAN is a subset of BEING?

Sebastian Fischer wrote:
>> You can define subclasses even if no instances exist. And as Daniel
>> said, the code
>> 
>>     class BEING human => HUMAN human where
>> 
>> defines a subclass HUMAN of BEING which means that every instance of
>> HUMAN must also be a BEING. You can read it as: "a BEING is also a HUMAN
>> by the following definitions".

Thanks for pointing out my error
But I am still not sure of the interpretation of logical implication wrt
to sub-classes. Lets simplify the representation and just regard the
classes in the example as propositions (instead of predicates).
I am not sure if this simplification still makes the example valid.
Below is a reasonable interpretation of propositional logical implication.

a) If I wear a raincoat then I stay dry (sufficient condition)
wareRaincoat => stayDry
b) I will stay dry only if I ware a raincoat(necessary condition)
stayDry => wareRaincoat

In the light of the above examples how should I interpret the
class-to-subclass relation as logical implication? Is it
a)  If BEING then HUMAN (sufficient condition): BEING => HUMAN
b)  HUMAN is true only if BEING (necessary condition): HUMAN => BEING
c) Neither?

Thanks,
Pat


This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie


More information about the Haskell-Cafe mailing list