A more serious online partial evaluator
Admittedly, the illustrative partial evaluator of the previous blog post was quite limited. Consider, for example, the following attempts of partially evaluating different applications of the exponentiation function; the last attempt diverges: > peval (lib, (Apply "exp" [Const 2, Const 3])) Const 8 > peval (lib, (Apply "exp" [Var "x", Const 3])) Binary Times (Var "x") (Binary Times (Var "x") (Binary Times (Var "x")(Const 1))) > peval (lib, (Apply "exp" [Const 2, Var "n"])) IfZero (Var "n") (Const 1) (Binary Times (Const 2) (IfZero (Binary Plus (Var "n") (Const (-1))) (Const 1) (Binary Times (Const 2) (IfZero (Binary Plus (Binary Plus (Var "n") (Const (-1))) (Const (-1))) (Const 1) (Binary Times (Const 2) (IfZero (Binary Plus (Binary Plus (Binary Plus (Var "n") (Const (-1))) (Const (-1))) (Const (-1))) (Const 1) (Binary Times (Const 2) (IfZero (Binary Plus (B...