b4942bb9c2b908ec6c3d98380558583e6c8e1fd1
[ghc-hetmet.git] / ghc / CONTRIB / pphs / docs / Haskell_internalalign1.tex
1 % From Haskell report PreludeComlex.hs
2 \begin{verbatim}
3 instance  (RealFloat a) => Num (Complex a)  where
4     (x:+y) + (x':+y')   =  (x+x') :+ (y+y')
5     (x:+y) - (x':+y')   =  (x-x') :+ (y-y')
6     (x:+y) * (x':+y')   =  (x*x'-y*y') :+ (x*y'+y*x')
7     negate (x:+y)       =  negate x :+ negate y
8     abs z               =  magnitude z :+ 0
9     signum 0            =  0
10     signum z@(x:+y)     =  x/r :+ y/r  where r = magnitude z
11     fromInteger n       =  fromInteger n :+ 0
12 \end{verbatim}