Skip to content

Commit

Permalink
Made Let take a Declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael Bung committed Mar 13, 2010
1 parent efb0752 commit 8dff67d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions haskell.ast.js
Expand Up @@ -76,16 +76,14 @@
return body.eval(clos.env.substitute(x, new interpreter.Closure(env, this.arg)));
};
};
ast.Let = function(pattern, def, expr) {
expectType(pattern, ast.Pattern);
expectType(def, ast.Expression);
ast.Let = function(declr, expr) {
expectType(declr, ast.Declaration);
expectType(expr, ast.Expression);
this.type = "Let";
this.pattern = pattern;
this.def = def;
this.declr = declr;
this.expr = expr;
this.eval = function(env) {
return this.expr.eval(env.substitute(this.pattern, new Closure(env, this.def)));
return this.expr.eval(env.substitute(this.declr.pattern, new Closure(env, this.declr.expression)));
};
};
ast.Case = function(expr, cases) {
Expand Down

0 comments on commit 8dff67d

Please sign in to comment.