How overload operator in Haskell?

Liu Junfeng liujf@softhome.net
Fri, 4 Jul 2003 11:9:42 +0800


I've learned haskell months, but I still can't understand the=
 type system very well.
I can only write:
-----------------------------------
type Vector =3D [Double]
vadd,vsub :: Vector->Vector->Vector
v1 `vadd` v2 =3D zipWith (+) v1 v2
v1 `vsub` v2 =3D zipWith (-) v1 v2
svmul :: Double->Vector->Vector
s `svmul` v =3D map (s*) v
------------------------------------
Tough it works, it is not convenient to use. How to create a=
 Vector type and overload 
mathematical operators? 
Thanks for your help. 

=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1Liu Junfeng
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1liujf@softhome.net
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12003-07-04