5 expToString :: Exp -> String
6 expToString (Exp s) = s
8 instance Additive Exp where
10 Exp a + Exp b = Exp ("(" + a + " + " + b + ")")
12 instance Ring Exp where
14 neg (Exp a) = Exp ("(-" + a + ")")
15 Exp a * Exp b = Exp ("(" + a + " * " + b + ")")
16 Exp a - Exp b = Exp ("(" + a + " - " + b + ")")
17 fromInteger x = Exp (show x)
25 main = expToString (a + b*c + d*e)
27 ((a + (b * c)) + (d * e))