laws
API reference for @effx/compiler/laws
laws.ts overview
Exports Grouped by Category
utils
Law (interface)
One derived law of a definition (spec 0020 §2.3). Nothing runs when a Law is built: check is a
suspended Effect that generates values, checks the property, and fails with LawViolation on a
falsification. It needs no services and starts no fibers; each generated value is checked inside an
Effect, so interrupting check stops it at the next value and leaves nothing to release.
Signature
export interface Law {
readonly name: string
readonly check: (options?: LawOptions) => Effect.Effect<void, LawViolation>
}LawDefinition (type alias)
A definition whose application is callable with its own Live arguments (an operation-target one).
Signature
type LawDefinition = DefinitionData & ((...live: never[]) => Applied<string, "operation">)LawOptions (type alias)
How many values a law checks, and the seed that replays a run.
Signature
type LawOptions = IRArbitrary.PropertyOptionsLawViolation (class)
A law of a definition did not hold; message is the formatted falsification (shrunk input, replay token).
Signature
declare class LawViolationlaws
The laws a definition satisfies, derived from its args plan (spec 0020 §2.3):
- round trip, always: for
xgenerated from the decode Schema,decode(encode(x)) = x. - syntax equivalence, only for plans without
Schema,SymbolorCapabilityleaves: for generated live arguments, the decorator spelling andOperationBuilder.with(definition(...live))record equal annotations (Reflect.annotationsOfagainst the builder'sannotations). A reference-bearing plan needs a universe of fixture references (exported schemas, services) to generate live values from; v1 provides none, so that law is absent from the result rather than weakened.
Values are generated through the @effx/ir Arbitrary adapter. A definition whose plan holds a rejected
A.fromSchema node (EFFX1301) has no derivable Schema: its check fails with LawViolation.
Pure: building the laws derives nothing.
Signature
declare const laws: (definition: LawDefinition) => ReadonlyArray<Law>