<div dir="ltr">On Sat, Feb 18, 2012 at 15:16, bahadýr altan <span dir="ltr">&lt;<a href="mailto:doaltan@yahoo.co.uk">doaltan@yahoo.co.uk</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div>Hello. I&#39;m wondering what &quot; (Eq a) =&gt;&quot; part in the code below does.. I couldn&#39;t figure it myself.. Thanks in advance :)</div>
<div><pre style="margin-top:0.8em;margin-right:0.8em;margin-bottom:0.8em;margin-left:0.8em;padding-top:0.3em;padding-right:0.3em;padding-bottom:0.3em;padding-left:0.3em;background-image:initial;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(221,221,221);border-right-color:rgb(221,221,221);border-bottom-color:rgb(221,221,221);border-left-color:rgb(221,221,221);text-align:left">
isPalindrome <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(51,153,51);font-weight:bold">::</span> <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:green">(</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(204,204,0);font-weight:bold">Eq</span> a<span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:green">)</span> <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(51,153,51);font-weight:bold">=&gt;</span> <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:green">[</span>a<span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:green">]</span> <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(51,153,51);font-weight:bold">-&gt;</span> <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(204,204,0);font-weight:bold">Bool</span>
isPalindrome xs <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(51,153,51);font-weight:bold">=</span> xs <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(51,153,51);font-weight:bold">==</span> <span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:green">(</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(85,68,136)!important;font-weight:bold">reverse</span> xs<span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:green">)</span></pre>
</div></div></div></blockquote></div><div>It&#39;s a type constraint.  In this case, it&#39;s saying that, rather than isPalindrome working only for a particular type, instead it works for any type &quot;a&quot; which has an implementation of the Eq class, where &quot;a&quot; is the type of the items in the passed list.  Technically, it&#39;s telling the compiler to pass in the appropriate Eq implementation for whatever type isPalindrome is being applied to; this allows the correct implementation of (==) to be used.  (And it really is passed in; it&#39;s not an accident that constraints look rather similar to parameters.)</div>
<div><br></div>-- <br>brandon s allbery                                      <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><br>wandering unix systems administrator (available)     (412) 475-9364 vm/sms<br>
<br>
</div>