Law.associative
const · packages/entity/src/law.ts:80
associative: {
readonly _tag: 'Associative'
readonly domain: Option.Option<Schema.Top>
}Entity / foldkit-entity
namespace · packages/entity/src/law.ts:79
const Law = {
associative,
commutative,
idempotent,
preservesCollation,
identity,
absorbing,
inverse,
distributes,
monotonic,
within,
$match,
witnessesNamed,
describe,
}type Law = Data.TaggedEnum<{
Associative: {
readonly domain: Option.Option<Schema.Top>
}
Commutative: {
readonly domain: Option.Option<Schema.Top>
}
Idempotent: {
readonly domain: Option.Option<Schema.Top>
}
Identity: {
readonly domain: Option.Option<Schema.Top>
readonly value: unknown
readonly side: Side
}
Absorbing: {
readonly domain: Option.Option<Schema.Top>
readonly value: unknown
readonly side: Side
}
Inverse: {
readonly domain: Option.Option<Schema.Top>
readonly other: AnyOperator
readonly identity: unknown
}
Distributes: {
readonly domain: Option.Option<Schema.Top>
readonly over: AnyOperator
}
Monotonic: {
readonly domain: Option.Option<Schema.Top>
readonly direction: 'increasing' | 'decreasing'
readonly position: number
}
PreservesCollation: {
readonly domain: Option.Option<Schema.Top>
}
}>A law, over its domain: by default every non-null value of the operator's
input schemas; narrowed by Law.within.
Law.associativeconst · packages/entity/src/law.ts:80
associative: {
readonly _tag: 'Associative'
readonly domain: Option.Option<Schema.Top>
}Law.commutativeconst · packages/entity/src/law.ts:81
commutative: {
readonly _tag: 'Commutative'
readonly domain: Option.Option<Schema.Top>
}Law.idempotentconst · packages/entity/src/law.ts:82
idempotent: {
readonly _tag: 'Idempotent'
readonly domain: Option.Option<Schema.Top>
}Law.preservesCollationconst · packages/entity/src/law.ts:83
preservesCollation: {
readonly _tag: 'PreservesCollation'
readonly domain: Option.Option<Schema.Top>
}Law.identityfunction · packages/entity/src/law.ts:85
identity(value: unknown, side?: Side): Lawvalue leaves the other argument as it is, from side (both by default).
Law.absorbingfunction · packages/entity/src/law.ts:88
absorbing(value: unknown, side?: Side): Lawvalue is the answer whatever the other argument, from side (both by default).
Law.inversefunction · packages/entity/src/law.ts:91
inverse<In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(
other: Operator<In, Out>,
identity: unknown,
): Lawother undoes the operator: op(a, other(a)) is identity.
Law.distributesfunction · packages/entity/src/law.ts:96
distributes<In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(
over: Operator<In, Out>,
): LawThe operator distributes over over, from the left.
Law.monotonicfunction · packages/entity/src/law.ts:100
monotonic(direction: 'increasing' | 'decreasing', position: number): LawMoving the argument at position up moves the result up (or down, decreasing).
Law.withinfunction · packages/entity/src/law.ts:107
within(law: Law, domain: Schema.Top): LawThe law over the values domain accepts only: a law that holds of the
integers and not of every number, say, narrowed so it is tested where it
is claimed.
Law.$matchconst · packages/entity/src/law.ts:110
$match: { <Cases extends { readonly Associative: (args: { readonly _tag: "Associative"; readonly domain: Option.Option<Schema.Top>; }) => any; readonly Commutative: (args: { readonly _tag: "Commutative"; readonly domain: Option.Option<Schema.Top>; }) => any; readonly Idempotent: (args: { readonly _tag: "Idempotent"; readonly domain: Option.Option<Schema.Top>; }) => any; readonly Identity: (args: { readonly _tag: "Identity"; readonly domain: Option.Option<Schema.Top>; readonly value: unknown; readonly side: Side; }) => any; readonly Absorbing: (args: { readonly _tag: "Absorbing"; readonly domain: Option.Option<Schema.Top>; readonly value: unknown; readonly side: Side; }) => any; readonly Inverse: (args: { readonly _tag: "Inverse"; readonly domain: Option.Option<Schema.Top>; readonly other: AnyOperator; readonly identity: unknown; }) => any; readonly Distributes: (args: { readonly _tag: "Distributes"; readonly domain: Option.Option<Schema.Top>; readonly over: AnyOperator; }) => any; readonly Monotonic: (args: { readonly _tag: "Monotonic"; readonly domain: Option.Option<Schema.Top>; readonly direction: "increasing" | "decreasing"; readonly position: number; }) => any; readonly PreservesCollation: (args: { readonly _tag: "PreservesCollation"; readonly domain: Option.Option<Schema.Top>; }) => any; }>(cases: Cases): (value: { readonly _tag: "Associative"; readonly domain: Option.Option<Schema.Top>; } | { readonly _tag: "Commutative"; readonly domain: Option.Option<Schema.Top>; } | { readon …;Law.witnessesNamedfunction · packages/entity/src/law.ts:117
witnessesNamed(law: LawDescription): ReadonlyArray<string>The operators a law, as JSON, calls besides its own (inverse's and
distributes' witnesses), by name: evidence of it is of their
implementations too, and goes when one of them is replaced.
Law.describefunction · packages/entity/src/law.ts:123
describe(law: Law): LawDescriptionThe law as JSON: its kind, its witnesses (operators by name) and its domain's JSON Schema.