I am getting the following error:
No instance for (Show Exp) arising from a use of ‘print’
In the expression: print ti1
In an equation for ‘it’: it = print ti1
When I
ghci>ti1 = Add (Lit 8) (Neg (Add (Lit 1) (Lit 2)))
ghci>print ti1
My entire code is:
data Exp = Lit Int
| Neg Exp
| Add Exp Exp
view:: Exp -> String
view (Lit n) = show n
view (Neg e) = "(-" ++ view e ++ ")"
view (Add e1 e2) = "(" ++ view e1 ++ " + " ++ view e2 ++ ")"
How can I print this string?