
24 Jan
2009
24 Jan
'09
1:24 a.m.
On 2009 Jan 23, at 17:58, Olex P wrote:
class Vector v where (^+^) :: v -> v -> v
class Matrix m where (^+^) :: m -> m -> m
You can't reuse the same operator in different classes. Vector "owns" (^+^), so Matrix can't use it itself. You could say
instance Matrix m => Vector m where (^+^) = ...
allowing Matrix to "inherit" Vector's operator (or turn it around the other way, make it Matrix then make Vector a Matrix), but that's only linguistically possible, not necessarily mathematically sane. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH