<div style="font-family: 'Times New Roman'; font-size: 16px;">{-<br _moz_dirty="" />I am trying to apply model theoretic concepts to Haskell by considering type classes as theories and instances as models.<br _moz_dirty="" />Then the declaration of a sub-class specifies a signature morphism from the superclass to the subclass.<br _moz_dirty="" />In case below the theories (classes) are signature only (no default methods) so a signature morphisms can be considered as a theory morphisms.<br _moz_dirty="" />The only purpose of the code below is to explore the concepts of model expansion[1] and model reduct [2] in Haskell<br _moz_dirty="" />I am not trying to improve or rewrite the code itself for any particular application.<br _moz_dirty="" />Neither am I trying to find OO style inheritance semantics in Haskell type classes.<br _moz_dirty="" />Rather, I am wondering if the last instance of Worker (commented out) demonstrates that there is no model expansion in this case.<br _moz_dirty="" />That is, for theory morphism the theory(Person) =&gt; theory(Worker) we do not get (model(Person) sub-model model(Worker)).<br _moz_dirty="" /><br _moz_dirty="" />If there is no model expansion could it be because of the constructor discipline, which only allows variables, and constructors in the LHS argument patterns.<br _moz_dirty="" /><br _moz_dirty="" />[1] http://www.informatik.uni-bremen.de/~cxl/papers/wadt04b.pdf<br _moz_dirty="" />[2] http://en.wikipedia.org/wiki/Reduct<br _moz_dirty="" /><br _moz_dirty="" />-}<br _moz_dirty="" /><br _moz_dirty="" />constant::Int<br _moz_dirty="" />constant = (1::Int)<br _moz_dirty="" />fun1::Int -&gt; Int<br _moz_dirty="" />fun1 (constant::Int) = 8<br _moz_dirty="" /><br _moz_dirty="" />class Person i n | i -&gt; n where<br _moz_dirty="" /> pid :: i<br _moz_dirty="" /> name :: i -&gt; n<br _moz_dirty="" /><br _moz_dirty="" />-- There is a signature/theory morphism from Person to Worker<br _moz_dirty="" />class Person i n =&gt; Worker i n s | i -&gt; s where<br _moz_dirty="" /> salary :: i -&gt; s<br _moz_dirty="" />   <br _moz_dirty="" />-- model(Person)<br _moz_dirty="" />instance Person Int [Char] where<br _moz_dirty="" /> pid = (1::Int)<br _moz_dirty="" /> name (1::Int)  = (&quot;john&quot;::[Char])<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" />-- We can say that a model(Worker) can use model(Person).<br _moz_dirty="" />instance Worker Int [Char] Int where<br _moz_dirty="" />-- Hypothesis: pid on the RHS shows that a model(Person) is *available* in model(Person) (reduct)?<br _moz_dirty="" />  salary i = if i == pid then 100 else 0<br _moz_dirty="" /> <br _moz_dirty="" />-- instance Worker Int [Char] Int where<br _moz_dirty="" />-- Hypothesis: The model of Person cannot be expanded to a model of Worker(no model expansion)<br _moz_dirty="" />-- pid below is not inherited from Person, it is just a local variable<br _moz_dirty="" />--   salary pid = 100<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" /><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>