Defining a containing function on polymorphic list

I am trying to define a containing function to see if a value is one of the elements within a list which is polymorphic, but failed with the following codes:

contain :: a -> [a] -> Bool
> contain x [] = False
> contain x (y:ys) = if x == y then True else contain x ys

it seems that the problem is the 'operator' == does not support a polymorphic check?

Any way can solve the problem? or any alternative solution to achieve the purpose?



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

the code is running under

the code is running under haskell

This question is not a

This question is not a general question about programming languages, and is not on topic for LtU. You should probably ask your question on a Haskell mailing list.