It's saying that you can't pass parameters to this function unless they are of the Eq type class, because somewhere in the body of the function is code that expects parameters to be of this type class.eOn Tue, Jul 23, 2013 at 10:33 AM, Louis-Guillaume Gagnon <louis.guillaume.gagnon@gmail.com> wrote:
Hello beginners,
I'm working on the second set of exercises in ch.03 of Real World Haskell
I wrote a palindromize function (:: [a] -> [a]) which transforms a
list in a palindrome (eg. [1,2,3] -> [1,2,3,3,2,1]) .
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.
many thanks,
glg
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners