Keean Schupke wrote:
You can do this like:
(code)
This was a mouthful for me being a Haskell newbee, I have to chew on
this one ;-)
Thanks!
/Bo Herlin
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Mark Carroll wrote:
On Fri, 8 Apr 2005, Bo Herlin wrote:
(snip)
Is it possible to make this work?
This is an extension beyond the 1998 standard, but
http://haskell.org/hawiki/ExistentialTypes may be
interesting to you.
Yes, I think this is what I was aiming at.
Thanks!
/Bo Herlin
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
You can do this like:
data TTrue = TTrue
data TFalse = TFalse
data Nil = Nil
data Cons a l = Cons a l
class Constrain c a b | c a - b where
constrain :: c - a - b
data ZConstraint = ZConstraint
instance Z a b = Constrain ZConstraint a b
class List c l
instance List c Nil
instance
On Fri, 8 Apr 2005, Bo Herlin wrote:
(snip)
Is it possible to make this work?
This is an extension beyond the 1998 standard, but
http://haskell.org/hawiki/ExistentialTypes may be
interesting to you.
-- Mark
___
Haskell-Cafe mailing list