@harmoniclabs/plu-ts-onchain
Version:
An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript
48 lines (47 loc) • 3.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.pisEmpty = exports.ptail = exports.phead = exports.pchooseList = exports.pstrictChooseList = void 0;
var obj_utils_1 = require("@harmoniclabs/obj-utils");
var IRNative_1 = require("../../../../IR/IRNodes/IRNative/index.js");
var Term_1 = require("../../../Term/index.js");
var type_system_1 = require("../../../type_system/index.js");
var papp_1 = require("../../papp.js");
var pdelay_1 = require("../../pdelay.js");
var pforce_1 = require("../../pforce/index.js");
var addApplications_1 = require("../addApplications.js");
function pstrictChooseList(listElemType, returnType) {
var listElemT = listElemType !== null && listElemType !== void 0 ? listElemType : (0, type_system_1.tyVar)("pstrictChooseList_listElemType");
var returnT = returnType !== null && returnType !== void 0 ? returnType : (0, type_system_1.tyVar)("pstrictChooseList_returnType");
return (0, addApplications_1.addApplications)(new Term_1.Term((0, type_system_1.fn)([(0, type_system_1.list)(listElemT), returnT, returnT], returnT), function (_dbn) { return IRNative_1.IRNative.strictChooseList; }));
}
exports.pstrictChooseList = pstrictChooseList;
function pchooseList(listElemType, returnType) {
if (listElemType === void 0) { listElemType = undefined; }
if (returnType === void 0) { returnType = undefined; }
var listElemT = listElemType !== null && listElemType !== void 0 ? listElemType : (0, type_system_1.tyVar)("pchooseList_listElemType");
var returnT = returnType !== null && returnType !== void 0 ? returnType : (0, type_system_1.tyVar)("pchooseList_returnType");
// new term identical to the strict one in order to define new (different) "$" properties
var _chooseList = new Term_1.Term((0, type_system_1.fn)([(0, type_system_1.list)(listElemT), (0, type_system_1.delayed)(returnT), (0, type_system_1.delayed)(returnT)], returnT), function (_dbn) { return IRNative_1.IRNative.strictChooseList; });
return (0, obj_utils_1.defineReadOnlyProperty)(_chooseList, "$", function (list) {
var _chooseListNil = (0, papp_1.papp)(_chooseList, list);
var _chooseListNilApp = (0, obj_utils_1.defineReadOnlyProperty)(_chooseListNil, "$", function (nilCase) {
var _chooseListNilCons = (0, papp_1.papp)(_chooseListNil, (0, pdelay_1.pdelay)(nilCase));
var _chooseListNilConsApp = (0, obj_utils_1.defineReadOnlyProperty)(_chooseListNilCons, "$", function (consCase) {
return (0, pforce_1.pforce)((0, papp_1.papp)(_chooseListNilCons, (0, pdelay_1.pdelay)(consCase)));
});
return (0, obj_utils_1.defineReadOnlyProperty)(_chooseListNilConsApp, "caseCons", _chooseListNilConsApp.$);
});
return (0, obj_utils_1.defineReadOnlyProperty)(_chooseListNilApp, "caseNil", _chooseListNilApp.$);
});
}
exports.pchooseList = pchooseList;
function phead(listElemType) {
var listElemT = listElemType;
return (0, addApplications_1.addApplications)(new Term_1.Term((0, type_system_1.lam)((0, type_system_1.list)(listElemT), listElemT), function (_dbn) { return IRNative_1.IRNative.headList; }));
}
exports.phead = phead;
function ptail(listElemT) {
return (0, addApplications_1.addApplications)(new Term_1.Term((0, type_system_1.lam)((0, type_system_1.list)(listElemT), (0, type_system_1.list)(listElemT)), function (_dbn) { return IRNative_1.IRNative.tailList; }));
}
exports.ptail = ptail;
exports.pisEmpty = (0, addApplications_1.addApplications)(new Term_1.Term((0, type_system_1.lam)((0, type_system_1.list)((0, type_system_1.tyVar)()), type_system_1.bool), function (_dbn) { return IRNative_1.IRNative.nullList; }));