I'm trying to write a simple program in Haskell that multiples to fractions together. I have the program working I just cannot get it to out the faction in its most simple form. I have the sum 4/10 * 15/14 which outputs 60/140 which is correct but I need the answer to be 3/7.

type Fraction = (Int, Int) makeFraction:: Int -> Int -> Fraction makeFraction _ 0 = error "Denominator is zero" makeFraction numerator denominator = ((div numerator d), (div denominator d)) where d = gcd numerator denominator multiply:: Fraction -> Fraction -> Fraction multiply (n1, d1) (n2, d2) = makeFraction (n1 * n2, d1 * d2)

As I said without the last makeFraction in the codes works but just outputs the 60/140.. Any help would be much appreciated.