Reputation: 63
Eq a => [a] -> [(Int,a)]
I don't know what the Eq means or does so I don't know what the whole definition means?
Upvotes: 3
Views: 294
Reputation: 2001
The items of type a must be of Eq typeclass, as said before. The Eq typeclass defines types which can be compared for equality with other types, with th '==' operator/function
This means that your function takes as its only parameter a list of 'a' items
[a] is a list of types a
and returns a list of (Int, a) pairs, i.e a list of 2-tuples where the first item in the tuple is an Int and the second is of same type as the list passed to the function.
(not native english speaker here, sorry :) )
Upvotes: 1
Reputation: 3194
This means that the elements in [a] must be of the Eq typeclass, which means that they must be testable for equality.
Upvotes: 5
Reputation: 8937
That's a constraint about the type a
used in the definition [a] -> [(Int,a)]
: it says that it must define an instance for the Eq
typeclass. Basically, types with an Eq
instance give support for equality and inequality operators, (==)
and (/=)
.
More information about typeclasses here, at learnyouahaskell.com. In nuce, typeclasses are somewhat similar to OOP's interfaces.
Upvotes: 10