Ok I partly solved my problem but I am still stuck.  I would like to
make both a [(a,b)] and Array a b instances of the Find class however I
can't figure out how to do it.

import Array

class Listable c a where
  toList     :: c a -> [a]

class Find c a b where
  find       :: a -> c (a,b) -> Maybe b

instance Listable [] a where
  toList c = c

--Line 16--
instance (Eq a, Listable c (a,b)) => Find c a b where
  find a c = lookup a (toList c)

instance Eq a => Find Array a b where
  find a c = Just (c!a)

produces ERROR "test.hs" (line 18): Illegal type in class constraint by
Hugs.

And changing the find method to

class Find c a b where
  find       :: a -> c a b -> Maybe b

produces ERROR "test.hs" (line 14): Illegal type in class constraint by
Hugs

Is it possible to do this?

More important how could I make Array an instance of Listable. 

Thanks in advance.

-- 
Kevin Atkinson
[EMAIL PROTECTED]
http://metalab.unc.edu/kevina/


Reply via email to