Why can't you have
class Eq a => Member c a | c -> a where member :: Eq a => c -> a -> Bool
OK, so then sequences require Eq on elements, but since Member is a
superclass of sequence, every sequence has a member method,
and so a must be in Eq anyway. Puzzled
Simon
| -----Original Message-----
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
| Sent: 27 June 2000 14:30
| To: [EMAIL PROTECTED]
| Subject: Method contexts
|
|
| The restriction that a method context must constrain at least one
| type variable that is quantified there has biten me:
|
|
| class Member c a | c -> a where member :: Eq a => c -> a -> Bool
| class Member (s a) a => Sequence s a where single :: a -> s a
|
| instance Member [a] a where member s a = elem a s
| instance Sequence [] a where single x = [x]
|
|
| I cannot move the constraint to the class context because it would
| force Eq a on all Sequence methods. I cannot have class Member c
| (where c has kind *->*) because it is used differently in
| other places.
|
| Hugs does accept the above definitions.
|
| Could this restriction be removed in ghc please?
|
| --
| __("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
| \__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
| ^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
| QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-
|
|