<div dir="ltr">David,<div>Thanks for you clear and helpful answers.</div><div>Pat</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 21 May 2018 at 13:31, David McBride <span dir="ltr"><<a href="mailto:toad3k@gmail.com" target="_blank">toad3k@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>1, a and b are distinct types. However b is of kind * while a is of kind * -> *, which means it takes a type and returns a type. That means that b can be a type like Int, (), or Char, while a has to be a type like Maybe, [], or (Either ()). That way they fit together into a type like (Maybe Char) or [Int].<br></div><div><br></div><div>2. In the constraint Boats b p, there it says b and p are two types that form an instance the Boats class (the class of boats and the things that are on a boat. usually people). The next constraint says that h and (b p) are each two types that satisfy the Houses constraint (the class of houses and things that are in houses in this case boats, but boats have things aboard them, so that has to be listed).</div><div><br></div><div>3. Haskell98 did not allow classes or instances with two type variables. FlexibleInstances and MultiParamTypeClasses remove that limitation, and they've been around for a very long time and will probably end up as part of the standard at some point. You can read about them here, along with other similar language features. <a href="http://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#class-declarations" target="_blank">http://downloads.haskell.org/~<wbr>ghc/latest/docs/html/users_<wbr>guide/glasgow_exts.html#class-<wbr>declarations</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, May 21, 2018 at 6:20 AM, PATRICK BROWNE <span dir="ltr"><<a href="mailto:patrick.browne@dit.ie" target="_blank">patrick.browne@dit.ie</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>I am trying to understand how to interpret type variables in Haskell class declarations from a <a href="http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=1EA31D76684217BC728F916144BC6C38?doi=10.1.1.109.6853&rep=rep1&type=pdf" target="_blank">paper</a>. <br></div><div>With respect to the code below I have the following questions:<br></div><div>1. What is the difference between "a b" in the header of the Container class and "a b" in the signature of the class methods? Does the whitespace in header mean 2 distinct types and in the methods mean function application?</div><div>2. In the Boathouse class what is the difference between the first ocurance of "b p" and the second bracketed "(b p)"?</div><div>3. When I try to make instance of these classes I seem to need FlexibleInstances. Why is this?</div><div><br></div><div><br></div><div><br></div><div>{-# LANGUAGE MultiParamTypeClasses #-}</div><div>-- Containers a b stands for all container types a holding things of type b.<br></div><div>-- from :info command a has kind *->*, b has kind *</div><div>class Containers a b where</div><div> insert :: b -> a b -> a b</div><div> remove :: b -> a b -> a b</div><div> whatsIn :: a b -> [b]</div><div><br></div><div><br></div><div>class Surfaces a b where</div><div> put :: b -> a b -> a b</div><div> takeOff :: b -> a b -> a b</div><div> whatsOn :: a b -> [b]</div><div><br></div><div>-- from :info command "p" has kind *, "h" and "b" have kind *->*</div><div>class People p</div><div>class Containers h p => Houses h p where </div><div>class (People p, Surfaces h p) => Boats h p where </div><div>class (Boats b p,Houses h (b p)) => BoatHouses h b p where</div><div>class (People p, Houses h (b p),Boats b p) => HouseBoats h b p</div></div>
<br>
</div></div><p><span lang="EN-GB"><font size="2">This email originated from DIT. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited. <a href="http://www.dit.ie/" target="_blank">www.dit.ie</a></font></span></p><p><font size="2">Is ó ITBÁC
a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí earráid, scrios
de do chóras é le do thoil. Tabhair ar aird, mura tú an seolaí ainmnithe, go
bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon dáileadh nó ar aon ghníomh
a dhéanfar bunaithe ar an ábhar atá sa ríomhphost nó sna hiatáin seo. <a href="http://www.dit.ie/" target="_blank">www.dit.ie</a></font></p><p><a href="http://www.dit.ie/grangegorman" target="_blank"><font size="2">Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to Grangegorman</font></a></p><br>______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
<br>
<p><span lang="EN-GB"><font size="2">This email originated from DIT. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited. <a href="http://www.dit.ie/" target="_blank">www.dit.ie</a></font></span></p><p><font size="2">Is ó ITBÁC
a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí earráid, scrios
de do chóras é le do thoil. Tabhair ar aird, mura tú an seolaí ainmnithe, go
bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon dáileadh nó ar aon ghníomh
a dhéanfar bunaithe ar an ábhar atá sa ríomhphost nó sna hiatáin seo. <a href="http://www.dit.ie/" target="_blank">www.dit.ie</a></font></p><p><a href="http://www.dit.ie/grangegorman" target="_blank"><font size="2">Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to Grangegorman</font></a></p>