UNPKG

@harmoniclabs/plu-ts-onchain

Version:

An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript

35 lines (34 loc) 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.precursiveList = void 0; var type_system_1 = require("../../../../type_system/index.js"); var papp_1 = require("../../../papp.js"); var pfn_1 = require("../../../pfn.js"); var phoist_1 = require("../../../phoist.js"); var plet_1 = require("../../../plet/index.js"); var precursive_1 = require("../../../precursive/index.js"); var minimal_common_1 = require("../../data/conversion/minimal_common.js"); var pmatchList_1 = require("../pmatchList/index.js"); function precursiveList(returnT, elemsT) { var finalSelfType = (0, type_system_1.lam)((0, type_system_1.list)(elemsT), returnT); var matchNil_t = (0, type_system_1.lam)(finalSelfType, (0, type_system_1.delayed)(returnT)); var matchCons_t = (0, type_system_1.fn)([finalSelfType, elemsT, (0, type_system_1.list)(elemsT)], returnT); var originalSelf_t = (0, type_system_1.fn)([ matchNil_t, matchCons_t, (0, type_system_1.list)(elemsT) ], returnT); return (0, phoist_1.phoist)((0, precursive_1.precursive)((0, pfn_1.pfn)([ originalSelf_t, matchNil_t, matchCons_t, (0, type_system_1.list)(elemsT) ], returnT)(function (self, matchNil, matchCons, lst) { return (0, plet_1.plet)((0, papp_1.papp)((0, papp_1.papp)(self, matchNil), matchCons)).in(function (finalSelf) { return (0, minimal_common_1._papp)((0, pmatchList_1.pmatchList)(returnT, elemsT) .$((0, papp_1.papp)(matchNil, finalSelf)) .$((0, papp_1.papp)(matchCons, finalSelf)), lst); }); }, "precursiveList"))); } exports.precursiveList = precursiveList;