Haskell: How can I define a type class for sets?

Viewed 1633

Total newbie here, struggling.

I'm trying to define a type class for sets. For this case it would only require the definition of 'exists'. 'exists' would take a set and function on a set item, and return a boolean. How can I define that in Haskell?

Is the following even in the right direction? So there is the type class definition and an implementation of set with list, for which 'exists' returns true for now..

-- Set.hs --

class Set a b where

  exists :: a -> (b -> Bool) -> Bool


-- ListSet.hs --

instance Set ListSet a where 

  exists a f = True

--

(result: Too many parameters for class `Set')

2 Answers
Related