Hi everyone. Being new to Haskell I wonder how I can make a list contain different types but all implementing the same class, like this:

data X = X
data Y = Y

class Z a where f :: a -> Int

instance Z X where f x = 0
instance Z Y where f y = 1

test1 :: Z a => [a]
test1 = [X,Y]

test2 = map f test1

Is it possible to make this work?

/Bo Herlin
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to