Permalink
Browse files

Reapplied patch because tinyrocket messed up a merge :P

  • Loading branch information...
1 parent bd186b4 commit 891440c56dd5c7758a43f9f11323173d4e6076fe @phyrex1an phyrex1an committed May 30, 2010
Showing with 9 additions and 5 deletions.
  1. +9 −5 haskell.hiji.js
View
@@ -214,11 +214,15 @@ commands[":type"] = "TYPE";
$("ol").append(makeInput(modules));
} else if (commands[command] == "TYPE") {
var arg = trim(input.substr(command.length));
- var ast = haskell.parser.parse("{" + arg + "}").ast;
- var type = ast.infer(/* some env */);
- var newLine = ast.stringify() + " :: " + type.stringify();
- $('.input').after(output).replaceWith(newLine);
- $("ol").append(makeInput(modules));
+ var ast = haskell.parser.parse('{' + arg + '}').ast.expr;
+ var tc = haskell.typechecker;
+ var infered = ast.infer(new tc.Environment(new tc.Assumps(), new tc.Subst(), new tc.NameGen()));
+ var predsString = infered.preds.map(function(p) { return p.toString(); }).join(", ");
+ if (predsString.length > 0) {
+ predsString = "(" + predsString + ") => ";
+ }
+ var newLine = ast.stringify() + " :: " + predsString + infered.type.toString();
+ $("ol").append(makeOutput(newLine));
}
}
};

0 comments on commit 891440c

Please sign in to comment.