Skip to content

Instantly share code, notes, and snippets.

@HomenSimpsor
Created October 10, 2014 00:35
Show Gist options
  • Save HomenSimpsor/8d3cb4b60d21a855ce68 to your computer and use it in GitHub Desktop.
Save HomenSimpsor/8d3cb4b60d21a855ce68 to your computer and use it in GitHub Desktop.
Contracts.js compile
import @ from 'contracts.js';
@ (Num) -> Num
function id(x) {
return x;
}
_c$600 = function () {
'use strict';
if (typeof require === 'function') {
// importing patches Proxy to be in line with the new direct proxies
require('harmony-reflect');
}
var unproxy$1177 = new WeakMap();
var typeVarMap$1178 = new WeakMap();
var Blame$1179 = {
create: function (name$1200, pos$1201, neg$1202, lineNumber$1203) {
var o$1204 = new BlameObj$1180(name$1200, pos$1201, neg$1202, lineNumber$1203);
return o$1204;
},
clone: function (old$1205, props$1206) {
var o$1207 = new BlameObj$1180(typeof props$1206.name !== 'undefined' ? props$1206.name : old$1205.name, typeof props$1206.pos !== 'undefined' ? props$1206.pos : old$1205.pos, typeof props$1206.neg !== 'undefined' ? props$1206.neg : old$1205.neg, typeof props$1206.lineNuber !== 'undefined' ? props$1206.lineNuber : old$1205.lineNumber);
o$1207.expected = typeof props$1206.expected !== 'undefined' ? props$1206.expected : old$1205.expected;
o$1207.given = typeof props$1206.given !== 'undefined' ? props$1206.given : old$1205.given;
o$1207.loc = typeof props$1206.loc !== 'undefined' ? props$1206.loc : old$1205.loc;
o$1207.parents = typeof props$1206.parents !== 'undefined' ? props$1206.parents : old$1205.parents;
return o$1207;
}
};
function BlameObj$1180(name$1208, pos$1209, neg$1210, lineNumber$1211) {
this.name = name$1208;
this.pos = pos$1209;
this.neg = neg$1210;
this.lineNumber = lineNumber$1211;
}
BlameObj$1180.prototype.swap = function () {
return Blame$1179.clone(this, {
pos: this.neg,
neg: this.pos
});
};
BlameObj$1180.prototype.addExpected = function (expected$1212, override$1213) {
if (this.expected === undefined || override$1213) {
return Blame$1179.clone(this, { expected: expected$1212 });
}
return Blame$1179.clone(this, {});
};
BlameObj$1180.prototype.addGiven = function (given$1214) {
return Blame$1179.clone(this, { given: given$1214 });
};
BlameObj$1180.prototype.addLocation = function (loc$1215) {
return Blame$1179.clone(this, { loc: this.loc != null ? this.loc.concat(loc$1215) : [loc$1215] });
};
BlameObj$1180.prototype.addParents = function (parent$1216) {
return Blame$1179.clone(this, { parents: this.parents != null ? this.parents.concat(parent$1216) : [parent$1216] });
};
BlameObj$1180.prototype.setNeg = function (neg$1217) {
return Blame$1179.clone(this, { neg: neg$1217 });
};
function assert$1181(cond$1218, msg$1219) {
if (!cond$1218) {
throw new Error(msg$1219);
}
}
function Contract$1182(name$1220, type$1221, proj$1222) {
this.name = name$1220;
this.type = type$1221;
this.proj = proj$1222.bind(this);
}
Contract$1182.prototype.closeCycle = function closeCycle(contract$1223) {
this.cycleContract = contract$1223;
return contract$1223;
};
Contract$1182.prototype.toString = function toString() {
return this.name;
};
function addQuotes$1183(val$1224) {
if (typeof val$1224 === 'string') {
return '\'' + val$1224 + '\'';
}
return val$1224;
}
function raiseBlame$1184(blame$1225) {
var lineMessage$1226 = blame$1225.lineNumber !== undefined ? 'function ' + blame$1225.name + ' guarded at line: ' + blame$1225.lineNumber + '\n' : '';
var msg$1227 = blame$1225.name + ': contract violation\n' + 'expected: ' + blame$1225.expected + '\n' + 'given: ' + addQuotes$1183(blame$1225.given) + '\n' + 'in: ' + blame$1225.loc.slice().reverse().join('\n ') + '\n' + ' ' + blame$1225.parents[0] + '\n' + lineMessage$1226 + 'blaming: ' + blame$1225.pos + '\n';
throw new Error(msg$1227);
}
function makeCoffer$1185(name$1228) {
return new Contract$1182(name$1228, 'coffer', function (blame$1229, unwrapTypeVar$1230, projOptions$1231) {
return function (val$1232) {
var locationMsg$1233 = 'in the type variable ' + name$1228 + ' of';
if (unwrapTypeVar$1230) {
if (val$1232 && typeof val$1232 === 'object' && unproxy$1177.has(val$1232)) {
var unwraperProj$1234 = typeVarMap$1178.get(this).contract.proj(blame$1229.addLocation(locationMsg$1233));
return unwraperProj$1234(unproxy$1177.get(val$1232));
} else {
raiseBlame$1184(blame$1229.addExpected('an opaque value').addGiven(val$1232).addLocation(locationMsg$1233));
}
} else {
var towrap$1235 = val$1232 && typeof val$1232 === 'object' ? val$1232 : {};
var p$1236 = new Proxy(towrap$1235, {
getOwnPropertyDescriptor: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called Object.getOwnPropertyDescriptor').addLocation(locationMsg$1233));
},
getOwnPropertyName: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called Object.getOwnPropertyName').addLocation(locationMsg$1233));
},
defineProperty: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called Object.defineProperty').addLocation(locationMsg$1233));
},
deleteProperty: function (target$1237, propName$1238) {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called delete on property' + propName$1238).addLocation(locationMsg$1233));
},
freeze: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called Object.freeze').addLocation(locationMsg$1233));
},
seal: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called Object.seal').addLocation(locationMsg$1233));
},
preventExtensions: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called Object.preventExtensions').addLocation(locationMsg$1233));
},
has: function (target$1239, propName$1240) {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called `in` for property ' + propName$1240).addLocation(locationMsg$1233));
},
hasOwn: function (target$1241, propName$1242) {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called Object.hasOwnProperty on property ' + propName$1242).addLocation(locationMsg$1233));
},
get: function (target$1243, propName$1244) {
var givenMsg$1245 = 'performed obj.' + propName$1244;
if (propName$1244 === 'valueOf') {
givenMsg$1245 = 'attempted to inspect the value';
}
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven(givenMsg$1245).addLocation(locationMsg$1233));
},
set: function (target$1246, propName$1247, val$2$1248) {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('performed obj.' + propName$1247 + ' = ' + val$2$1248).addLocation(locationMsg$1233));
},
enumerate: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('value used in a `for in` loop').addLocation(locationMsg$1233));
},
iterate: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('value used in a `for of` loop').addLocation(locationMsg$1233));
},
keys: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('called Object.keys').addLocation(locationMsg$1233));
},
apply: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('attempted to invoke the value').addLocation(locationMsg$1233));
},
construct: function () {
raiseBlame$1184(blame$1229.swap().addExpected('value to not be manipulated').addGiven('attempted to invoke the value with new').addLocation(locationMsg$1233));
}
});
if (!typeVarMap$1178.has(this)) {
var valType$1249 = typeof val$1232;
var inferedContract$1250 = check$1186(function (checkVal$1251) {
return typeof checkVal$1251 === valType$1249;
}, '(x) => typeof x === \'' + valType$1249 + '\'');
typeVarMap$1178.set(this, { contract: inferedContract$1250 });
} else {
var inferedProj$1252 = typeVarMap$1178.get(this).contract.proj(blame$1229.addLocation(locationMsg$1233));
inferedProj$1252(val$1232);
}
unproxy$1177.set(p$1236, val$1232);
return p$1236;
}
}.bind(this);
});
}
function check$1186(predicate$1253, name$1254) {
var c$1255 = new Contract$1182(name$1254, 'check', function (blame$1256) {
return function (val$1257) {
if (predicate$1253(val$1257)) {
return val$1257;
} else {
raiseBlame$1184(blame$1256.addExpected(name$1254).addGiven(val$1257));
}
};
});
return c$1255;
}
function addTh$1187(a0$1258) {
if (a0$1258 === 0) {
return '0th';
}
if (a0$1258 === 1) {
return '1st';
}
if (a0$1258 === 2) {
return '2nd';
}
if (a0$1258 === 3) {
return '3rd';
}
var x$1259 = a0$1258;
return x$1259 + 'th';
}
function pluralize$1188(a0$1260, a1$1261) {
if (a0$1260 === 0) {
var str$1263 = a1$1261;
return str$1263 + 's';
}
if (a0$1260 === 1) {
var str$1263 = a1$1261;
return str$1263;
}
var n$1262 = a0$1260;
var str$1263 = a1$1261;
return str$1263 + 's';
}
function toContract$1189(f$1264) {
return check$1186(f$1264, function () {
if (f$1264.name) {
return f$1264.name;
} else {
return 'custom contract';
}
}.bind(this)());
}
function fun$1190(domRaw$1265, rngRaw$1266, options$1267) {
var dom$1268 = domRaw$1265.map(function (d$1276) {
if (!(d$1276 instanceof Contract$1182)) {
if (typeof d$1276 === 'function') {
return toContract$1189(d$1276);
}
throw new Error(d$1276 + ' is not a contract');
}
return d$1276;
});
var domStr$1269 = dom$1268.map(function (d$1277, idx$1278) {
return options$1267 && options$1267.namesStr ? options$1267.namesStr[idx$1278] + ': ' + d$1277 : d$1277;
}).join(', ');
var domName$1270 = '(' + domStr$1269 + ')';
var rng$1271 = rngRaw$1266;
if (!(rngRaw$1266 instanceof Contract$1182)) {
if (typeof rngRaw$1266 === 'function') {
rng$1271 = toContract$1189(rngRaw$1266);
} else {
throw new Error(rng$1271 + ' is not a contract');
}
}
var rngStr$1272 = options$1267 && options$1267.namesStr ? options$1267.namesStr[options$1267.namesStr.length - 1] + ': ' + rng$1271 : rng$1271;
var thisName$1273 = options$1267 && options$1267.thisContract ? '\n | this: ' + options$1267.thisContract : '';
var contractName$1274 = domName$1270 + ' -> ' + rngStr$1272 + thisName$1273 + (options$1267 && options$1267.dependencyStr ? ' | ' + options$1267.dependencyStr : '');
var c$1275 = new Contract$1182(contractName$1274, 'fun', function (blame$1279, unwrapTypeVar$1280, projOptions$1281) {
return function (f$1282) {
blame$1279 = blame$1279.addParents(contractName$1274);
if (typeof f$1282 !== 'function') {
raiseBlame$1184(blame$1279.addExpected('a function that takes ' + dom$1268.length + pluralize$1188(dom$1268.length, ' argument')).addGiven(f$1282));
}
function applyTrap$1283(target$1284, thisVal$1285, args$1286) {
var checkedArgs$1287 = [];
var depArgs$1288 = [];
for (var i$1289 = 0; i$1289 < dom$1268.length; i$1289++) {
if (dom$1268[i$1289].type === 'optional' && args$1286[i$1289] === undefined) {
continue;
} else {
var location$1295 = 'the ' + addTh$1187(i$1289 + 1) + ' argument of';
var unwrapForProj$1296 = dom$1268[i$1289].type === 'fun' ? !unwrapTypeVar$1280 : unwrapTypeVar$1280;
var domProj$1297 = dom$1268[i$1289].proj(blame$1279.swap().addLocation(location$1295), unwrapForProj$1296);
checkedArgs$1287.push(domProj$1297(args$1286[i$1289]));
if (options$1267 && options$1267.dependency) {
var depProj$1298 = dom$1268[i$1289].proj(blame$1279.swap().setNeg('the contract of ' + blame$1279.name).addLocation(location$1295));
depArgs$1288.push(depProj$1298(args$1286[i$1289]));
}
}
}
checkedArgs$1287 = checkedArgs$1287.concat(args$1286.slice(i$1289));
var checkedThis$1290 = thisVal$1285;
if (options$1267 && options$1267.thisContract || projOptions$1281 && projOptions$1281.overrideThisContract) {
var thisContract$1299 = function () {
if (projOptions$1281 && projOptions$1281.overrideThisContract) {
return projOptions$1281.overrideThisContract;
} else {
return options$1267.thisContract;
}
}.bind(this)();
var thisProj$1300 = thisContract$1299.proj(blame$1279.swap().addLocation('the this value of'));
checkedThis$1290 = thisProj$1300(thisVal$1285);
}
assert$1181(rng$1271 instanceof Contract$1182, 'The range is not a contract');
var rawResult$1291 = target$1284.apply(checkedThis$1290, checkedArgs$1287);
var rngUnwrap$1292 = rng$1271.type === 'fun' ? unwrapTypeVar$1280 : !unwrapTypeVar$1280;
var rngProj$1293 = rng$1271.proj(blame$1279.addLocation('the return of'), rngUnwrap$1292);
var rngResult$1294 = rngProj$1293(rawResult$1291);
if (options$1267 && options$1267.dependency && typeof options$1267.dependency === 'function') {
var depResult$1301 = options$1267.dependency.apply(this, depArgs$1288.concat(rngResult$1294));
if (!depResult$1301) {
raiseBlame$1184(blame$1279.addExpected(options$1267.dependencyStr).addGiven(false).addLocation('the return dependency of'));
}
}
return rngResult$1294;
}
// only use expensive proxies when needed (to distinguish between apply and construct)
if (options$1267 && options$1267.needs_proxy) {
var p$1302 = new Proxy(f$1282, {
apply: function (target$1303, thisVal$1304, args$1305) {
return applyTrap$1283(target$1303, thisVal$1304, args$1305);
}
});
return p$1302;
} else {
return function () {
return applyTrap$1283(f$1282, this, Array.prototype.slice.call(arguments));
};
}
};
});
return c$1275;
}
function optional$1191(contract$1306, options$1307) {
if (!(contract$1306 instanceof Contract$1182)) {
if (typeof contract$1306 === 'function') {
contract$1306 = toContract$1189(contract$1306);
} else {
throw new Error(contract$1306 + ' is not a contract');
}
}
var contractName$1308 = '?' + contract$1306;
return new Contract$1182(contractName$1308, 'optional', function (blame$1309, unwrapTypeVar$1310) {
return function (val$1311) {
var proj$1312 = contract$1306.proj(blame$1309, unwrapTypeVar$1310);
return proj$1312(val$1311);
};
});
}
function repeat$1192(contract$1313, options$1314) {
if (!(contract$1313 instanceof Contract$1182)) {
if (typeof contract$1313 === 'function') {
contract$1313 = toContract$1189(contract$1313);
} else {
throw new Error(contract$1313 + ' is not a contract');
}
}
var contractName$1315 = '....' + contract$1313;
return new Contract$1182(contractName$1315, 'repeat', function (blame$1316, unwrapTypeVar$1317) {
return function (val$1318) {
var proj$1319 = contract$1313.proj(blame$1316, unwrapTypeVar$1317);
return proj$1319(val$1318);
};
});
}
function array$1193(arrContractRaw$1320, options$1321) {
var proxyPrefix$1322 = options$1321 && options$1321.proxy ? '!' : '';
var arrContract$1323 = arrContractRaw$1320.map(function (c$2$1327) {
if (!(c$2$1327 instanceof Contract$1182)) {
if (typeof c$2$1327 === 'function') {
return toContract$1189(c$2$1327);
}
throw new Error(c$2$1327 + ' is not a contract');
}
return c$2$1327;
});
var contractName$1324 = proxyPrefix$1322 + '[' + arrContract$1323.map(function (c$2$1328) {
return c$2$1328;
}).join(', ') + ']';
var contractNum$1325 = arrContract$1323.length;
var c$1326 = new Contract$1182(contractName$1324, 'array', function (blame$1329, unwrapTypeVar$1330) {
return function (arr$1331) {
if (typeof arr$1331 === 'number' || typeof arr$1331 === 'string' || typeof arr$1331 === 'boolean' || arr$1331 == null) {
raiseBlame$1184(blame$1329.addGiven(arr$1331).addExpected('an array with at least ' + contractNum$1325 + pluralize$1188(contractNum$1325, ' field')));
}
for (var ctxIdx$1332 = 0, arrIdx$1333 = 0; ctxIdx$1332 < arrContract$1323.length; ctxIdx$1332++) {
if (arrContract$1323[ctxIdx$1332].type === 'repeat' && arr$1331.length <= ctxIdx$1332) {
break;
}
var unwrapForProj$1334 = arrContract$1323[ctxIdx$1332].type === 'fun' ? !unwrapTypeVar$1330 : unwrapTypeVar$1330;
var fieldProj$1335 = arrContract$1323[ctxIdx$1332].proj(blame$1329.addLocation('the ' + addTh$1187(arrIdx$1333) + ' field of'), unwrapForProj$1334);
var checkedField$1336 = fieldProj$1335(arr$1331[arrIdx$1333]);
arr$1331[arrIdx$1333] = checkedField$1336;
arrIdx$1333++;
if (arrContract$1323[ctxIdx$1332].type === 'repeat') {
if (ctxIdx$1332 !== arrContract$1323.length - 1) {
throw new Error('The repeated contract must come last in ' + contractName$1324);
}
for (; arrIdx$1333 < arr$1331.length; arrIdx$1333++) {
var repeatProj$1337 = arrContract$1323[ctxIdx$1332].proj(blame$1329.addLocation('the ' + addTh$1187(arrIdx$1333) + ' field of'), unwrapForProj$1334);
arr$1331[arrIdx$1333] = repeatProj$1337(arr$1331[arrIdx$1333]);
}
}
}
if (options$1321 && options$1321.proxy) {
return new Proxy(arr$1331, {
set: function (target$1338, key$1339, value$1340) {
var lastContract$1341 = arrContract$1323[arrContract$1323.length - 1];
var fieldProj$2$1342;
if (arrContract$1323[key$1339] !== undefined && arrContract$1323[key$1339].type !== 'repeat') {
fieldProj$2$1342 = arrContract$1323[key$1339].proj(blame$1329.swap().addLocation('the ' + addTh$1187(key$1339) + ' field of'));
target$1338[key$1339] = fieldProj$2$1342(value$1340);
} else if (lastContract$1341 && lastContract$1341.type === 'repeat') {
fieldProj$2$1342 = lastContract$1341.proj(blame$1329.swap().addLocation('the ' + addTh$1187(key$1339) + ' field of'));
target$1338[key$1339] = fieldProj$2$1342(value$1340);
}
}
});
} else {
return arr$1331;
}
};
});
return c$1326;
}
function object$1194(objContract$1343, options$1344) {
var contractKeys$1345 = Object.keys(objContract$1343);
contractKeys$1345.forEach(function (prop$1350) {
if (!(objContract$1343[prop$1350] instanceof Contract$1182)) {
if (typeof objContract$1343[prop$1350] === 'function') {
objContract$1343[prop$1350] = toContract$1189(objContract$1343[prop$1350]);
} else {
throw new Error(objContract$1343[prop$1350] + ' is not a contract');
}
}
});
var proxyPrefix$1346 = options$1344 && options$1344.proxy ? '!' : '';
var contractName$1347 = proxyPrefix$1346 + '{' + contractKeys$1345.map(function (prop$1351) {
return prop$1351 + ': ' + objContract$1343[prop$1351];
}).join(', ') + '}';
var keyNum$1348 = contractKeys$1345.length;
var c$1349 = new Contract$1182(contractName$1347, 'object', function (blame$1352) {
return function (obj$1353) {
if (typeof obj$1353 === 'number' || typeof obj$1353 === 'string' || typeof obj$1353 === 'boolean' || obj$1353 == null) {
raiseBlame$1184(blame$1352.addGiven(obj$1353).addExpected('an object with at least ' + keyNum$1348 + pluralize$1188(keyNum$1348, ' key')));
}
contractKeys$1345.forEach(function (key$1354) {
if (!(objContract$1343[key$1354].type === 'optional' && obj$1353[key$1354] === undefined)) {
var propProjOptions$1355 = function () {
if (objContract$1343[key$1354].type === 'fun') {
return { overrideThisContract: this };
} else {
return {};
}
}.bind(this)();
var c$2$1356 = function () {
if (objContract$1343[key$1354].type === 'cycle') {
return objContract$1343[key$1354].cycleContract;
} else {
return objContract$1343[key$1354];
}
}.bind(this)();
var propProj$1357 = c$2$1356.proj(blame$1352.addLocation('the ' + key$1354 + ' property of'), false, propProjOptions$1355);
var checkedProperty$1358 = propProj$1357(obj$1353[key$1354]);
obj$1353[key$1354] = checkedProperty$1358;
}
}.bind(this));
if (options$1344 && options$1344.proxy) {
return new Proxy(obj$1353, {
set: function (target$1359, key$1360, value$1361) {
if (objContract$1343.hasOwnProperty(key$1360)) {
var c$2$1362 = function () {
if (objContract$1343[key$1360].type === 'cycle') {
return objContract$1343[key$1360].cycleContract;
} else {
return objContract$1343[key$1360];
}
}.bind(this)();
var propProj$1363 = c$2$1362.proj(blame$1352.swap().addLocation('setting the ' + key$1360 + ' property of'));
var checkedProperty$1364 = propProj$1363(value$1361);
target$1359[key$1360] = checkedProperty$1364;
} else {
target$1359[key$1360] = value$1361;
}
}
});
} else {
return obj$1353;
}
}.bind(this);
});
return c$1349;
}
function reMatch$1195(re$1365) {
var contractName$1366 = re$1365.toString();
return check$1186(function (val$1367) {
return re$1365.test(val$1367);
}, contractName$1366);
}
function and$1196(left$1368, right$1369) {
if (!(left$1368 instanceof Contract$1182)) {
if (typeof left$1368 === 'function') {
left$1368 = toContract$1189(left$1368);
} else {
throw new Error(left$1368 + ' is not a contract');
}
}
if (!(right$1369 instanceof Contract$1182)) {
if (typeof right$1369 === 'function') {
right$1369 = toContract$1189(right$1369);
} else {
throw new Error(right$1369 + ' is not a contract');
}
}
var contractName$1370 = left$1368 + ' and ' + right$1369;
return new Contract$1182(contractName$1370, 'and', function (blame$1371) {
return function (val$1372) {
var leftProj$1373 = left$1368.proj(blame$1371.addExpected(contractName$1370, true));
var leftResult$1374 = leftProj$1373(val$1372);
var rightProj$1375 = right$1369.proj(blame$1371.addExpected(contractName$1370, true));
return rightProj$1375(leftResult$1374);
};
});
}
function or$1197(left$1376, right$1377) {
if (!(left$1376 instanceof Contract$1182)) {
if (typeof left$1376 === 'function') {
left$1376 = toContract$1189(left$1376);
} else {
throw new Error(left$1376 + ' is not a contract');
}
}
if (!(right$1377 instanceof Contract$1182)) {
if (typeof right$1377 === 'function') {
right$1377 = toContract$1189(right$1377);
} else {
throw new Error(right$1377 + ' is not a contract');
}
}
var contractName$1378 = left$1376 + ' or ' + right$1377;
return new Contract$1182(contractName$1378, 'or', function (blame$1379) {
return function (val$1380) {
try {
var leftProj$1381 = left$1376.proj(blame$1379.addExpected(contractName$1378, true));
return leftProj$1381(val$1380);
} catch (b$1382) {
var rightProj$1383 = right$1377.proj(blame$1379.addExpected(contractName$1378, true));
return rightProj$1383(val$1380);
}
};
});
}
function cyclic$1198(name$1384) {
return new Contract$1182(name$1384, 'cycle', function () {
throw new Error('Stub, should never be called');
});
}
function guard$1199(contract$1385, value$1386, name$1387) {
var proj$1388 = contract$1385.proj(Blame$1179.create(name$1387, 'function ' + name$1387, '(calling context for ' + name$1387 + ')'));
return proj$1388(value$1386);
}
return {
Num: check$1186(function (val$1389) {
return typeof val$1389 === 'number';
}, 'Num'),
Str: check$1186(function (val$1390) {
return typeof val$1390 === 'string';
}, 'Str'),
Bool: check$1186(function (val$1391) {
return typeof val$1391 === 'boolean';
}, 'Bool'),
Odd: check$1186(function (val$1392) {
return val$1392 % 2 === 1;
}, 'Odd'),
Even: check$1186(function (val$1393) {
return val$1393 % 2 !== 1;
}, 'Even'),
Pos: check$1186(function (val$1394) {
return val$1394 >= 0;
}, 'Pos'),
Nat: check$1186(function (val$1395) {
return val$1395 > 0;
}, 'Nat'),
Neg: check$1186(function (val$1396) {
return val$1396 < 0;
}, 'Neg'),
Any: check$1186(function (val$1397) {
return true;
}, 'Any'),
None: check$1186(function (val$1398) {
return false;
}, 'None'),
Null: check$1186(function (val$1399) {
return null === val$1399;
}, 'Null'),
Undefined: check$1186(function (val$1400) {
return void 0 === val$1400;
}, 'Null'),
Void: check$1186(function (val$1401) {
return null == val$1401;
}, 'Null'),
check: check$1186,
reMatch: reMatch$1195,
fun: fun$1190,
or: or$1197,
and: and$1196,
repeat: repeat$1192,
optional: optional$1191,
object: object$1194,
array: array$1193,
cyclic: cyclic$1198,
Blame: Blame$1179,
makeCoffer: makeCoffer$1185,
guard: guard$1199
};
}();
;
var inner_id$1175 = _c$600.fun([typeof Num !== 'undefined' ? Num : _c$600.Num], typeof Num !== 'undefined' ? Num : _c$600.Num).proj(_c$600.Blame.create('id', 'function id', '(calling context for id)', 4))(function id$1176(x$1402) {
return x$1402;
});
function id$1176(x$1403) {
return inner_id$1175.apply(this, arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment