Skip to content

Commit

Permalink
only show unique predicates in hiji
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattis Jeppsson committed May 30, 2010
1 parent fad206d commit 9a6249e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions haskell.hiji.js
Expand Up @@ -220,16 +220,16 @@ commands[":type"] = "TYPE";
var infered = ast.infer(env);
var type = infered.type.apply(env.getSubst());
var predsSubst = infered.preds.map(function(p) { return p.apply(env.getSubst())});
var preds = predsSubst.filter(
var preds = tc.unique(predsSubst.filter(
function (p) {
return tc.any(
p.tv(),
function(t) {
return tc.elem(type.tv(), t);
}
)
);
}
);
));
var predsString = preds.map(function(p) { return p.toString(); }).join(", ");
if (predsString.length > 0) {
predsString = "(" + predsString + ") => ";
Expand Down
9 changes: 9 additions & 0 deletions haskell.typechecker.js
Expand Up @@ -66,6 +66,15 @@
return ys;
};

var unique = function(arr) {
return uniqueBy(
arr,
function(a, b) {
return a.compare(b);
});
};
typechecker.unique = unique;

var flatten = function(arr) {
return inject(
arr,
Expand Down

0 comments on commit 9a6249e

Please sign in to comment.