
Hi all, Will somebody please explain why this wont run, I sure the code is right? data Expression = Val Integer | Add Expression Expression | Subtract Expression Expression | Multiply Expression Expression | Divide Expression Expression deriving Show demo1 = (Add(Add(Add(Val 6)(Val 5))(Val 10))(Val 7)) evalStep :: Expression -> Expression evalStep (Val x)= (Val x) evalStep (Add x y) = case x of (Val a) -> case y of (Val b) -> Val (a+b) left -> Add x (evalStep y) right -> Add y(evalStep x) evaluate :: Expression -> Expression -- Base case evaluate (Val a) = Val a -- Recursive case evaluate e = do putStrLn "Evaluating one more step" e' <- return (evalStep e) putStrLn ("Result is "++(show e')) putStrLn "Do another step (y/n)? :" c <- getChar if (c=='y') then evaluate e' else putStrLn "OK, finished" Its suppose to print out the first step then ask you if you want the next step all the way to the end