Remove Control.Parallel*, now in package parallel
[haskell-directory.git] / Data / Complex.hs
index 6b9999b..3b37f6c 100644 (file)
@@ -43,8 +43,9 @@ module Data.Complex
 
 import Prelude
 
-#ifndef __NHC__
 import Data.Typeable
+#ifdef __GLASGOW_HASKELL__
+import Data.Generics.Basics( Data )
 #endif
 
 #ifdef __HUGS__
@@ -64,7 +65,11 @@ infix  6  :+
 data (RealFloat a) => Complex a
   = !a :+ !a   -- ^ forms a complex number from its real and imaginary
                -- rectangular components.
-  deriving (Eq, Read, Show)
+# if __GLASGOW_HASKELL__
+       deriving (Eq, Show, Read, Data)
+# else
+       deriving (Eq, Show, Read)
+# endif
 
 -- -----------------------------------------------------------------------------
 -- Functions over Complex
@@ -131,7 +136,7 @@ instance  (RealFloat a) => Num (Complex a)  where
     (x:+y) * (x':+y')  =  (x*x'-y*y') :+ (x*y'+y*x')
     negate (x:+y)      =  negate x :+ negate y
     abs z              =  magnitude z :+ 0
-    signum 0           =  0
+    signum (0:+0)      =  0
     signum z@(x:+y)    =  x/r :+ y/r  where r = magnitude z
     fromInteger n      =  fromInteger n :+ 0
 #ifdef __HUGS__
@@ -160,7 +165,7 @@ instance  (RealFloat a) => Floating (Complex a)     where
                       where expx = exp x
     log z          =  log (magnitude z) :+ phase z
 
-    sqrt 0         =  0
+    sqrt (0:+0)    =  0
     sqrt z@(x:+y)  =  u :+ (if y < 0 then -v else v)
                       where (u,v) = if x < 0 then (v',u') else (u',v')
                             v'    = abs y / (u'*2)