UNPKG

@harmoniclabs/plu-ts-onchain

Version:

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

20 lines (19 loc) 827 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pmatch = void 0; var types_1 = require("../../type_system/types.js"); var utils_1 = require("../../type_system/utils.js"); var type_system_1 = require("../../type_system/index.js"); var pmatchStruct_1 = require("./pmatchStruct.js"); var pmatchSop_1 = require("./pmatchSop.js"); function pmatch(term) { var t = term.type; t = (0, type_system_1.isTaggedAsAlias)(t) ? (0, type_system_1.unwrapAlias)(t) : t; if (t[0] === types_1.PrimType.Struct) return (0, pmatchStruct_1.pmatchStruct)(term); else if (t[0] === types_1.PrimType.Sop) return (0, pmatchSop_1.pmatchSop)(term); throw new Error("invalid term to match; term type is: " + (0, utils_1.termTypeToString)(term.type)); } exports.pmatch = pmatch;