[Haskell-cafe] Defining a containing function on polymorphic list
ryani.spam at gmail.com
Wed Dec 24 10:07:14 EST 2008
Here's a tip: leave off the type signature, and ask ghci what it is.
Prelude> let contain x  = False ; contain x (y:ys) = if x == y then
True else contain x ys
Prelude> :t contain
contain :: (Eq a) => a -> [a] -> Bool
2008/12/22 Raeck Zhao <raeck at msn.com>:
> 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
>> 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
> It's the same Hotmail(R). If by "same" you mean up to 70% faster. Get your
> account now.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe