<div dir="ltr">On Tue, Jul 23, 2013 at 10:33 AM, Louis-Guillaume Gagnon <span dir="ltr"><<a href="mailto:louis.guillaume.gagnon@gmail.com" target="_blank">louis.guillaume.gagnon@gmail.com</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I wrote a isPalindrome function which checks whether a given list is<br>
such a palindrome.<br>
it reads:<br>
isPalindrome xs<br>
| odd (length xs) = False<br>
| firstHalf == secondHalf =True<br>
| otherwise = False<br>
where half = div (length xs) 2<br>
firstHalf = take half xs<br>
secondHalf = reverse (drop half xs)<br>
<br>
I would expect the type signature to be:<br>
isPalindrome :: [a] -> Bool<br>
<br>
but ghci gives me<br>
is Eq a => [a] -> Bool<br>
<br>
and I don't undestand why the "Eq a =>" shows up.<br></blockquote><div><br></div><div>It shows up because of `firstHalf == secondHalf`; you used (==), this requires an Eq constraint so that the type-appropriate implementation of (==) is available.</div>
<div><br></div></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</div></div>