# functions not in type classes

¾È±â¿µ kyagrd@bawi.org
Sat, 19 Jan 2002 09:21:37 +0900

Cagdas Ozgenc wrote:

> You shouldn't be using multi paramater type classes in place of type
> constructors. Then you will have the ambiguity problems that you
> mention on you web site. Multi parameter type classes have the
> benefit of using multi dispatch based on two non related types.

Ozgenc's opinion is right. See the code below.
This is a proper Haskell 98 script,
tested under Hugs version December 2001.
No need for multi parameter stuff.

\begin{code}
class Container a where
celem :: Eq b => b -> a b -> Bool
cmap :: (Eq b, Eq c) => (b->c) -> a b -> a c

data MyList a = MyList [a] deriving Show

instance Container MyList where
celem x (MyList l) = elem x l
cmap f (MyList l) = MyList (map f l)
\end{code}