interface PatternMatchers {
    and: ((...subPatts) => Matcher);
    any: (() => Matcher);
    array: ((limits?) => Matcher);
    arrayOf: ((subPatt?, limits?) => Matcher);
    bag: ((limits?) => Matcher);
    bagOf: ((keyPatt?, countPatt?, limits?) => Matcher);
    bigint: ((limits?) => Matcher);
    boolean: (() => Matcher);
    eq: ((key) => Matcher);
    eref: ((subPatt) => any);
    error: (() => Matcher);
    gt: ((rightOperand) => Matcher);
    gte: ((rightOperand) => Matcher);
    key: (() => Matcher);
    kind: ((kind) => Matcher);
    lt: ((rightOperand) => Matcher);
    lte: ((rightOperand) => Matcher);
    map: ((limits?) => Matcher);
    mapOf: ((keyPatt?, valuePatt?, limits?) => Matcher);
    nat: ((limits?) => Matcher);
    neq: ((key) => Matcher);
    not: ((subPatt) => Matcher);
    null: (() => null);
    number: (() => Matcher);
    opt: ((subPatt) => any);
    or: ((...subPatts) => Matcher);
    partial: ((basePatt, rest?) => Matcher);
    pattern: (() => Matcher);
    promise: (() => Matcher);
    record: ((limits?) => Matcher);
    recordOf: ((keyPatt?, valuePatt?, limits?) => Matcher);
    remotable: ((label?) => Matcher);
    scalar: (() => Matcher);
    set: ((limits?) => Matcher);
    setOf: ((keyPatt?, limits?) => Matcher);
    split: ((basePatt, rest?) => Matcher);
    splitArray: ((required, optional?, rest?) => Matcher);
    splitRecord: ((required, optional?, rest?) => Matcher);
    string: ((limits?) => Matcher);
    symbol: ((limits?) => Matcher);
    undefined: (() => Matcher);
}

Properties

and: ((...subPatts) => Matcher)

Type declaration

    • (...subPatts): Matcher
    • Matches against the intersection of all sub-Patterns.

      Parameters

      • Rest ...subPatts: any[]

      Returns Matcher

any: (() => Matcher)

Type declaration

array: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any CopyArray, subject to limits.

      Parameters

      Returns Matcher

arrayOf: ((subPatt?, limits?) => Matcher)

Type declaration

    • (subPatt?, limits?): Matcher
    • Matches any CopyArray whose elements are all matched by subPatt if defined, subject to limits.

      Parameters

      • Optional subPatt: any
      • Optional limits: Partial<AllLimits>

      Returns Matcher

bag: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any CopyBag, subject to limits.

      Parameters

      Returns Matcher

bagOf: ((keyPatt?, countPatt?, limits?) => Matcher)

Type declaration

    • (keyPatt?, countPatt?, limits?): Matcher
    • Matches any CopyBag whose elements are all matched by keyPatt if defined and the cardinality of each is matched by countPatt if defined, subject to limits. countPatt is expected to rarely be useful, but is provided to minimize surprise.

      Parameters

      • Optional keyPatt: any
      • Optional countPatt: any
      • Optional limits: Partial<AllLimits>

      Returns Matcher

bigint: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any bigint, subject to limits.

      Parameters

      Returns Matcher

boolean: (() => Matcher)

Type declaration

eq: ((key) => Matcher)

Type declaration

    • (key): Matcher
    • Matches any value that is equal to key.

      Parameters

      • key: any

      Returns Matcher

eref: ((subPatt) => any)

Type declaration

    • (subPatt): any
    • Matches any Passable that is either matched by subPatt or is a promise object. Note that validation is immediate, so (unlike the TypeScript ERef type) M.eref matches a promise object whose fulfillment value is not matched by subPatt. For describing a top-level parameter, M.callWhen(..., M.await(p), ...) is preferred over M.call(..., M.eref(p), ...) because the former always checks against the sub-Pattern (awaiting fulfillment if necessary) while the latter bypasses such checks when the relevant argument is a promise.

      Parameters

      • subPatt: any

      Returns any

error: (() => Matcher)

Type declaration

    • (): Matcher
    • Matches any error object. Error objects are Passable, but are neither Keys nor Patterns. They do not have a useful identity.

      Returns Matcher

gt: ((rightOperand) => Matcher)

Type declaration

    • (rightOperand): Matcher
    • Matches any value that compareKeys reports as greater than rightOperand.

      Parameters

      • rightOperand: any

      Returns Matcher

gte: ((rightOperand) => Matcher)

Type declaration

    • (rightOperand): Matcher
    • Matches any value that compareKeys reports as greater than or equal to rightOperand.

      Parameters

      • rightOperand: any

      Returns Matcher

key: (() => Matcher)

Type declaration

    • (): Matcher
    • Matches any value that can be a key in a CopyMap or an element in a CopySet or CopyBag. All matched values are also valid Patterns that match only themselves.

      Returns Matcher

kind: ((kind) => Matcher)

Type declaration

    • (kind): Matcher
    • When kind specifies a PassStyle other than "tagged", matches any value having that PassStyle. Otherwise, when kind specifies a known tagged record tag (such as 'copySet', 'copyBag', 'copyMap', or 'match:scalar'), matches any CopyTagged with that tag and a valid tag-specific payload. Otherwise, does not match any value. TODO: Reject attempts to create a kind matcher with unknown kind?

      Parameters

      • kind: string

      Returns Matcher

lt: ((rightOperand) => Matcher)

Type declaration

    • (rightOperand): Matcher
    • Matches any value that compareKeys reports as less than rightOperand.

      Parameters

      • rightOperand: any

      Returns Matcher

lte: ((rightOperand) => Matcher)

Type declaration

    • (rightOperand): Matcher
    • Matches any value that compareKeys reports as less than or equal to rightOperand.

      Parameters

      • rightOperand: any

      Returns Matcher

map: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any CopyMap, subject to limits.

      Parameters

      Returns Matcher

mapOf: ((keyPatt?, valuePatt?, limits?) => Matcher)

Type declaration

    • (keyPatt?, valuePatt?, limits?): Matcher
    • Matches any CopyMap whose keys are all matched by keyPatt if defined and values are all matched by valuePatt if defined, subject to limits.

      Parameters

      • Optional keyPatt: any
      • Optional valuePatt: any
      • Optional limits: Partial<AllLimits>

      Returns Matcher

nat: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any non-negative bigint, subject to limits.

      Parameters

      Returns Matcher

neq: ((key) => Matcher)

Type declaration

    • (key): Matcher
    • Matches any value that is not equal to key.

      Parameters

      • key: any

      Returns Matcher

not: ((subPatt) => Matcher)

Type declaration

    • (subPatt): Matcher
    • Matches against the negation of the sub-Pattern.

      Parameters

      • subPatt: any

      Returns Matcher

null: (() => null)

Type declaration

    • (): null
    • Returns null, which matches only itself.

      Returns null

number: (() => Matcher)

Type declaration

    • (): Matcher
    • Matches any floating point number, including NaN and either signed Infinity.

      Returns Matcher

opt: ((subPatt) => any)

Type declaration

    • (subPatt): any
    • Matches any Passable that is matched by subPatt or is the exact value undefined.

      Parameters

      • subPatt: any

      Returns any

or: ((...subPatts) => Matcher)

Type declaration

    • (...subPatts): Matcher
    • Matches against the union of all sub-Patterns (requiring a successful match against at least one).

      Parameters

      • Rest ...subPatts: any[]

      Returns Matcher

partial: ((basePatt, rest?) => Matcher)

Type declaration

    • (basePatt, rest?): Matcher
    • Deprecated. Use M.splitArray or M.splitRecord instead. An array or record is split into the first part that is matched by basePatt, and the remainder, which is matched against rest if present. M.partial differs from M.split in the handling of data that is described in basePatt but absent in a provided specimen:

      • For a CopyRecord, M.partial ignores properties of basePatt that are not present on the specimen.
      • For a CopyArray, M.partial ignores elements of basePatt at indices beyond the maximum index of the specimen.

      Parameters

      Returns Matcher

pattern: (() => Matcher)

Type declaration

    • (): Matcher
    • Matches any Pattern that can be used to characterize Passables. A Pattern cannot contain promises or errors, as these are not stable enough to usefully match.

      Returns Matcher

promise: (() => Matcher)

Type declaration

    • (): Matcher
    • Matches any promise object. Promises are Passable, but are neither Keys nor Patterns. They do not have a useful identity.

      Returns Matcher

record: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any CopyRecord, subject to limits.

      Parameters

      Returns Matcher

recordOf: ((keyPatt?, valuePatt?, limits?) => Matcher)

Type declaration

    • (keyPatt?, valuePatt?, limits?): Matcher
    • Matches any CopyRecord whose keys are all matched by keyPatt if defined and values are all matched by valuePatt if defined, subject to limits.

      Parameters

      • Optional keyPatt: any
      • Optional valuePatt: any
      • Optional limits: Partial<AllLimits>

      Returns Matcher

remotable: ((label?) => Matcher)

Type declaration

    • (label?): Matcher
    • Matches a far object or its remote presence. The optional label is purely for diagnostic purposes and does not add any constraints.

      Parameters

      • Optional label: string

      Returns Matcher

scalar: (() => Matcher)

Type declaration

    • (): Matcher
    • Matches any Passable primitive value or Remotable. All matched values are Keys.

      Returns Matcher

set: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any CopySet, subject to limits.

      Parameters

      Returns Matcher

setOf: ((keyPatt?, limits?) => Matcher)

Type declaration

    • (keyPatt?, limits?): Matcher
    • Matches any CopySet whose elements are all matched by keyPatt if defined, subject to limits.

      Parameters

      • Optional keyPatt: any
      • Optional limits: Partial<AllLimits>

      Returns Matcher

split: ((basePatt, rest?) => Matcher)

Type declaration

    • (basePatt, rest?): Matcher
    • Deprecated. Use M.splitArray or M.splitRecord instead. An array or record is split into the first part that is matched by basePatt, and the remainder, which is matched against rest if present.

      Parameters

      Returns Matcher

splitArray: ((required, optional?, rest?) => Matcher)

Type declaration

    • (required, optional?, rest?): Matcher
    • Matches any array --- typically an arguments list --- consisting of

      • an initial portion matched by required, and
      • a middle portion of length up to the length of optional that is matched by the equal-length prefix of optional if optional is defined, and
      • a remainder that is matched by rest if rest is defined. The array must be at least as long as required but its remainder can be arbitrarily short. Any array elements beyond the summed length of required and optional are collected and matched against rest.

      Parameters

      • required: any[]
      • Optional optional: any[]
      • Optional rest: any

      Returns Matcher

splitRecord: ((required, optional?, rest?) => Matcher)

Type declaration

    • (required, optional?, rest?): Matcher
    • Matches any CopyRecord that can be split into component CopyRecords as follows:

      • all properties corresponding with a property of required
      • all properties corresponding with a property of optional but not corresponding with a property of required
      • all other properties where the first component is matched by required, the second component is matched by the subset of optional corresponding with its properties if optional is defined, and the third component is matched by rest if defined. The CopyRecord must have all properties that appear on required, but may omit properties that appear on optional.

      Parameters

      Returns Matcher

string: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any string, subject to limits.

      Parameters

      Returns Matcher

symbol: ((limits?) => Matcher)

Type declaration

    • (limits?): Matcher
    • Matches any registered or well-known symbol, subject to limits.

      Parameters

      Returns Matcher

undefined: (() => Matcher)

Type declaration

    • (): Matcher
    • Matches the exact value undefined. All keys including undefined are already valid Patterns and so can validly represent themselves. But optional Pattern arguments (patt = undefined) => ... treat explicit undefined as omission of the argument. Thus, when a passed Pattern does not also need to be a Key, we recommend passing M.undefined() rather than undefined.

      Returns Matcher

Generated using TypeDoc