
2009/1/23 Olex P
Well if telepaths on vacation...
class Vector v where (^+^) :: v -> v -> v
data Vector3 = V3 !Double !Double !Double
instance Vector Vector3 where (V3 x1 y1 z1) ^+^ (V3 x2 y2 z2) = V3 (x1 + x2) (y1 + y2) (z1 + z2)
class Matrix m where (^+^) :: m -> m -> m
data Matrix3 = M3 !Vector3 !Vector3 !Vector3
instance Matrix Matrix3 where (M3 r11 r12 r13) ^+^ (M3 r21 r22 r23) = M3 (r11 ^+^ r21) (r12 ^+^ r22) (r13 ^+^ r23)
Hope this is better :) So yeah... r11 ^+^ r21 just doesn't work. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Luke's story about Num and a supposed Vector class is repeated here between Vector and Matrix classes. Either you make a class Add instanciated by both Vector and Matrix, or you use different name for each of them. Cheers, Thu