definition module RefactorX\r
\r
+from StdClass import class toString\r
import StdEnv\r
\r
:: Expr = NR Int | VAR Name | OP Expr Operator Expr | LET Name Expr Expr\r
:: Operator = PLUS | MIN | MUL | DIV\r
:: Val = Result Int | Undef\r
\r
-from StdClass import class toString\r
\r
instance toString Expr\r
free :: Expr -> [Name]\r
apply` MUL = *\r
apply` DIV = /\r
\r
-\r
eval:: Expr -> Val\r
-eval e = eval` (remove_unused_lets e) []\r
+eval e = eval` e []\r
where\r
eval`:: Expr [(Name, Val)] -> Val\r
eval` (NR n) _ = Result n\r