Perhaps you want something like: class Complex r c | c -> r where makeComplex :: r -> r -> c realPart :: c -> r imagPart :: c -> rdata ComplexNumber t = CN t t instance Complex t (ComplexNumber t) where makeComplex = CN realPart (CN r _) = r imagPart (CN _ i) = i newtype ComplexWithDouble = CWD (ComplexNumber Double) deriving (Complex Double) Having the parameters "backwards" is somewhat annoying, I suppose, but it's unavoidable if you're hoping to use generalized newtype deriving I believe.
Great! Actually, I would never imagine that (ComplexNumber Double) would yield a class with a single type variable... What is the logic behind that? I know about kinds (of types). Do classes have "kinds" of their own? Thanks, Maurício _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
