data Formula = Term Int Int -- coefficient and exponent
| Int
| Sum Formula Formula deriving Show
derive :: Formula -> Formula | Int
derive (Term coeff expo)| expo > 1 = Term (coeff * expo) (expo - 1)
| expo == 1 = coeff
derive (Sum x y) = Sum (derive x) (derive y)
main = print (derive $ Sum (Term 1 2) (Term (-1) 1))