# Newbie question about classes and class parameters

**Dmitry Astapov
**
adept@umc.com.ua

*17 Oct 2001 11:25:40 +0300*

Let's say we have infamous Set class defined this way:
>* class Set s a where
*>* empty :: s a
*>* isEmpty :: s a -> Bool
*
Lets also say that we could define sets as lists:
>* data SetAsList a = SL [a] deriving (Eq,Ord,Show)
*>* instance Set SetAsList a where
*>* empty = SL []
*>* isEmpty (SL []) = True
*>* isEmpty _ = False
*
So far, so good. Lets define type synonim for set of integers:
>* type IntegerSet = SetAsList Integer
*
And set of sets of integers:
>* data IntegerSuperSet = ISS (SetAsList IntegerSet)
*
Testing in Hugs show that everything seems to be working:
Main> :t ISS (SL [ (SL [1,2,3])::IntegerSet, (SL [4,5,6])::IntegerSet ])
ISS (SL [SL [1,2,3],SL [4,5,6]]) :: IntegerSuperSet
However:
Main> isEmpty (ISS (SL [(SL [1,2,3])::IntegerSet, (SL [4,5,6])::IntegerSet]))
ERROR - Type error in application
*** Expression : isEmpty (ISS (SL [SL [1,2,3],SL [4,5,6]]))
*** Term : ISS (SL [SL [1,2,3],SL [4,5,6]])
*** Type : IntegerSuperSet
*** Does not match : a b
This is completely understood - I need to state that IntegerSuperSet is an
instance of Set for isEmpty to be working. But:
>* instance Set IntegerSuperSet where
*>* empty = ISS (SL [])
*>* isEmpty (ISS (SL [])) = True
*>* isEmpty _ = False
*
gives me:
Reading file "/tmp/bug.lhs":
ERROR /tmp/bug.lhs:38 - Wrong number of arguments for class "Set"
Obviously I am missing something very important here. Could someone enlighten me?
--
Dmitry Astapov //ADEpt E-mail: adept@umc.com.ua
Information Systems Expert Office: +380-50-110-3876
Ukrainian Mobile Communications Mobile: +380-50-330-2019
GPG KeyID/fprint: F5D7639D/CA36 E6C4 815D 434D 0498 2B08 7867 4860 F5D7 639D