Metakit / @doeixd/metakit/operation

Claims

type · packages/metakit/src/operationDefine.ts:61

type Claims<Args extends ReadonlyArray<Schema.Top>, R extends Schema.Top> = {
  readonly identity?: Binary<Args, R> extends true
    ? {
        readonly value: Schema.Schema.Type<R>
        readonly side: Node.ClaimSide
      }
    : 'identity needs two arguments of one Schema and a result of that Schema'
  readonly absorbing?: Binary<Args, R> extends true
    ? {
        readonly value: Schema.Schema.Type<R>
        readonly result: Schema.Schema.Type<R>
        readonly side: Node.ClaimSide
      }
    : 'absorbing needs two arguments of one Schema and a result of that Schema'
  readonly idempotent?: SameType<Args, R> extends true
    ? true
    : 'idempotent needs one or two arguments of one Schema and a result of that Schema'
  readonly commutative?: Binary<Args, R> extends true
    ? true
    : 'commutative needs two arguments of one Schema and a result of that Schema'
  readonly associative?: Binary<Args, R> extends true
    ? | true
      | {
          readonly unlessRefused: true
        }
    : 'associative needs two arguments of one Schema and a result of that Schema'
  readonly invertible?: Args extends readonly [
    infer A extends Schema.Top,
    infer B extends Schema.Top,
  ]
    ? {
        readonly inverse:
          | (Binary<Args, R> extends true ? 'self' : never)
          | Operation<
              string,
              number,
              readonly [R, B],
              A,
              'strict' | 'own',
              object
            >
      }
    : 'invertible needs two arguments (A, B) => R'
  readonly monotone?: MonotoneTuple<Args>
  readonly total?: true
}

Algebraic claims typed by the operation's signature. A claim that does not fit the signature resolves to a human-readable sentence rather than never.