<div style="font-family: 'Times New Roman'; font-size: 16px;">Hi,<br />The runtime behaviour of the two modules below *seems* to be the same.<br />Is this correct? <br />I am not trying to say &quot;every building is a shelter&quot;, rather &quot;anything that is a building must provide sheltering services&quot;.<br />I think that the use of sub-classes makes this explicit, but it *seems* that one gets the same results without the subclass.<br />Any clarification welcome.<br /><br />Regards,<br />Pat<br /><br />-- ========================================<br />module WithSubclass where<br />data SomeWhereToShelter = SomeWhereToShelter <br />class Shelter shelter where<br /> s :: shelter -&gt; String<br />class Shelter building =&gt; Building building where<br /> b :: building -&gt; String<br />class Shelter house =&gt; House house where<br /> h :: house -&gt; String<br /><br />instance Shelter SomeWhereToShelter where<br /> s x = &quot;Shelters afford basic sheltering&quot;  <br />instance Building SomeWhereToShelter where<br /> b x =  (s x) ++ &quot;, Buildings afford better sheltering&quot;<br />instance House SomeWhereToShelter where<br /> h x = (s x) ++ (b x) ++  &quot;, Houses afford even better sheltering&quot;<br /><br /><br />-- =======================================<br />module WithoutSubclass where<br />data SomeWhereToShelter = SomeWhereToShelter <br /><br />class Shelter shelter where<br /> s :: shelter -&gt; String<br />class Building building where<br /> b :: building -&gt; String<br />class House house where<br /> h :: house -&gt; String<br /><br />instance Shelter SomeWhereToShelter where<br /> s x = &quot;Shelters afford basic sheltering&quot;  <br />instance Building SomeWhereToShelter where<br /> b x =  (s x) ++ &quot;, Buildings afford better sheltering&quot;<br />instance House SomeWhereToShelter where<br /> h x = (s x) ++ (b x) ++  &quot;, Houses afford even better sheltering&quot;<br /></div>
<br clear=all> Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a bheith slán.  <a href="http://www.dit.ie">http://www.dit.ie</a><br>
This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean.  <a href="http://www.dit.ie">http://www.dit.ie</a>