// Implementation of stable names.
// Unlike native GHC, the garbage collector isn't going to move data around
// in a way that we can detect, so each object could serve as its own stable
// name if it weren't for the fact we can't turn a JS reference into an
// integer.
// So instead, each object has a unique integer attached to it, which serves
// as its stable name.
var __next_stable_name = 1;
var __stable_table;
function makeStableName(x) {
if(x instanceof Object) {
if(!x.stableName) {
x.stableName = __next_stable_name;
__next_stable_name += 1;
}
return {type: 'obj', name: x.stableName};
} else {
return {type: 'prim', name: Number(x)};
}
}
function eqStableName(x, y) {
return (x.type == y.type && x.name == y.name) ? 1 : 0;
}