[Haskell-beginners] Type signature question
anindya at anindyamozumdar.com
Tue Jul 23 16:55:15 CEST 2013
>>but ghci gives me
>>is Eq a => [a] -> Bool
>>and I don't undestand why the "Eq a =>" shows up.
You are doing the comparison firstHalf == secondHalf. Two lists are equal
only if each element in the same position in the list are equal (and the
lists are of equal length). Thus, you require that the elements of the list
can be compared for equality. A type can be tested for equality only if it
belongs to the Eq typeclass. Thus, automatic type inference in Haskell is
putting this class constraint.
More information about the Beginners