import Data.Ratio
import Data.Complex

data ComplexRational = CR (Complex Rational) deriving (Show,Eq)
instance Num (ComplexRational) where
(CR (x:+y)) + (CR (x':+y')) = CR $ (x+x') :+ (y+y')
(CR (x:+y)) * (CR (x':+y'))
= CR $ (x*x'-y*y') :+ (x*y'+y*x')
negate (CR (x:+y)) = CR $ negate x :+ negate y
abs = undefined
signum = undefined
fromInteger n = CR $ fromInteger n :+ 0
instance Fractional (ComplexRational) where
recip (CR (x:+y))= CR $ (x/(x^2+y^2)):+(-y/(x^2+y^2))
toComplex (CR x) = x

i = CR $ 0:+1

onCircle a b c d = (==0) $ imagPart $ toComplex $ ((a-c)/(b-c))/((a-d)/(b-d))

a=0
b=3
c=4*i
d=7/2+7/2*i

main = do
print $(1/2+3/4*i)/(5/6+7/8*i)
print $ onCircle a b c d

-----
CR (618 % 841 :+ 108 % 841)
True