aboutsummaryrefslogtreecommitdiff
path: root/src/complex.hs
blob: 220fe1f8c0a1a54a1831b61367f2f8d1e5de6186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Complex where

type Imaginary = Float

data Complex = Complex Float Imaginary

-- instance Num Complex where
--     (Complex r1 i1) + (Complex r2 i2) = Complex (r1 + r2) (i1 + i2)
--     (Complex r1 i1) * (Complex r2 i2) = undefined
--     negate (Complex r1 i1) = undefined
--     abs (Complex r1 i1) = undefined
--     signum (Complex r1 i1) = undefined
    -- fromInteger r = Complex r 0

instance Show Complex where
    show (Complex r i) = show r ++ showI ++ "i"
        where showI = if i < 0 then " - " ++ show (-i) else " + " ++ show i