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