X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FComplex.hs;h=621b48ef7f6c062bb5f8c9402244362dcc205b3f;hb=9bc25029ee43b36194a6003dded9a8d800a8a07a;hp=e0738f10b425e4ae7f864caad90cd8a0adb2dfac;hpb=9fa9bc17072a58c0bae2cce4764d38677e96ac29;p=ghc-base.git diff --git a/Data/Complex.hs b/Data/Complex.hs index e0738f1..621b48e 100644 --- a/Data/Complex.hs +++ b/Data/Complex.hs @@ -2,14 +2,12 @@ -- | -- Module : Data.Complex -- Copyright : (c) The University of Glasgow 2001 --- License : BSD-style (see the file libraries/core/LICENSE) +-- License : BSD-style (see the file libraries/base/LICENSE) -- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : portable -- --- $Id: Complex.hs,v 1.3 2002/04/24 16:31:39 simonmar Exp $ --- -- Complex numbers. -- ----------------------------------------------------------------------------- @@ -41,7 +39,13 @@ module Data.Complex import Prelude -import Data.Dynamic +#ifndef __NHC__ +import Data.Typeable +#endif + +#ifdef __HUGS__ +import Hugs.Prelude(Num(fromInt), Fractional(fromDouble)) +#endif infix 6 :+ @@ -90,8 +94,10 @@ phase (x:+y) = atan2 y x -- ----------------------------------------------------------------------------- -- Instances of Complex -#include "Dynamic.h" +#ifndef __NHC__ +#include "Typeable.h" INSTANCE_TYPEABLE1(Complex,complexTc,"Complex") +#endif instance (RealFloat a) => Num (Complex a) where {-# SPECIALISE instance Num (Complex Float) #-} @@ -104,6 +110,9 @@ instance (RealFloat a) => Num (Complex a) where signum 0 = 0 signum z@(x:+y) = x/r :+ y/r where r = magnitude z fromInteger n = fromInteger n :+ 0 +#ifdef __HUGS__ + fromInt n = fromInt n :+ 0 +#endif instance (RealFloat a) => Fractional (Complex a) where {-# SPECIALISE instance Fractional (Complex Float) #-} @@ -115,6 +124,9 @@ instance (RealFloat a) => Fractional (Complex a) where d = x'*x'' + y'*y'' fromRational a = fromRational a :+ 0 +#ifdef __HUGS__ + fromDouble a = fromDouble a :+ 0 +#endif instance (RealFloat a) => Floating (Complex a) where {-# SPECIALISE instance Floating (Complex Float) #-}