
17 Nov
2008
17 Nov
'08
6:07 p.m.
On Mon, Nov 17, 2008 at 10:38 AM, Maurício
newtype ComplexWithDouble = ComplexWithDouble (ComplexNumber Double) deriving ...
Perhaps you want something like: class Complex r c | c -> r where makeComplex :: r -> r -> c realPart :: c -> r imagPart :: c -> r data 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. /g -- I am in here