diff --git a/packages/patterns/index.js b/packages/patterns/index.js index 9bd5dbb5f5..1a3cc1773f 100644 --- a/packages/patterns/index.js +++ b/packages/patterns/index.js @@ -68,6 +68,7 @@ export { getInterfaceMethodKeys, assertInterfaceGuard, getInterfaceGuardPayload, + kindOf, } from './src/patterns/patternMatchers.js'; // ////////////////// Temporary, until these find their proper home //////////// diff --git a/packages/patterns/src/patterns/internal-types.js b/packages/patterns/src/patterns/internal-types.js index ceb3ec4085..1d15dc41ba 100644 --- a/packages/patterns/src/patterns/internal-types.js +++ b/packages/patterns/src/patterns/internal-types.js @@ -44,6 +44,18 @@ /** @typedef {import('../types').AllLimits} AllLimits */ /** @typedef {import('../types').GetRankCover} GetRankCover */ +/** + * @typedef {Exclude | + * 'copySet' | 'copyBag' | 'copyMap' | + * `match:${any}` | `guard:${any}` + * } Kind + * It is either a PassStyle other than 'tagged', or, if the underlying + * PassStyle is 'tagged', then the `getTag` value for tags that are + * recognized at the @endo/patterns level of abstraction. For each of those + * tags, a tagged record only has that kind if it satisfies the invariants + * that the @endo/patterns level associates with that kind. + */ + /** * @typedef {object} MatchHelper * This factors out only the parts specific to each kind of Matcher. It is @@ -85,4 +97,5 @@ * @property {(patt: Passable) => boolean} isPattern * @property {GetRankCover} getRankCover * @property {MatcherNamespace} M + * @property {(specimen: Passable, check?: Checker) => Kind | undefined} kindOf */ diff --git a/packages/patterns/src/patterns/patternMatchers.js b/packages/patterns/src/patterns/patternMatchers.js index 49e266a49b..71a5beb8a3 100644 --- a/packages/patterns/src/patterns/patternMatchers.js +++ b/packages/patterns/src/patterns/patternMatchers.js @@ -174,17 +174,6 @@ const makePatternKit = () => { // eslint-disable-next-line no-use-before-define GuardPayloadShapes[tag]; - /** - * @typedef {Exclude | - * 'copySet' | 'copyBag' | 'copyMap' | keyof HelpersByMatchTag - * } Kind - * It is either a PassStyle other than 'tagged', or, if the underlying - * PassStyle is 'tagged', then the `getTag` value for tags that are - * recognized at the store level of abstraction. For each of those - * tags, a tagged record only has that kind if it satisfies the invariants - * that the store level associates with that kind. - */ - /** @type {Map} */ const singletonKinds = new Map([ ['null', null], @@ -1719,6 +1708,7 @@ const makePatternKit = () => { isPattern, getRankCover, M, + kindOf, }); }; @@ -1736,6 +1726,7 @@ export const { isPattern, getRankCover, M, + kindOf, } = makePatternKit(); MM = M;