On Mon, Nov 17, 2008 at 10:38 AM, Maurício <[EMAIL PROTECTED]> wrote:
> 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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe