[Haskell-beginners] Type signature question

Louis-Guillaume Gagnon louis.guillaume.gagnon at gmail.com
Tue Jul 23 16:33:35 CEST 2013


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




More information about the Beginners mailing list