How overload operator in Haskell?

Liu Junfeng liujf@softhome.net
Wed, 9 Jul 2003 22:25:29 +0800


I've learned haskell months, but I still can't understand the type system very well.
I can only write:
-----------------------------------
type Vector = [Double]
vadd,vsub :: Vector->Vector->Vector
v1 `vadd` v2 = zipWith (+) v1 v2
v1 `vsub` v2 = zipWith (-) v1 v2
svmul :: Double->Vector->Vector
s `svmul` v = 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. 

Liu Junfeng
liujf@softhome.net