<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]>
<S extends Constraint>(
schema: S,
options: { readonly report: true }
): Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>Derives a fast-check Arbitrary from a schema for property-based
testing. The derived arbitrary generates values that satisfy the schema.
Details
Constraints refine base generators; candidates add weighted sources while
filters still validate every value. { report: true } returns warnings such
as OpaqueFilter, while derivation errors remain fail-fast. Recursive
schemas use terminal branches and fail when no finite terminal path exists.
Example (Generating arbitrary values)
import { Schema } from "effect"
import * as FastCheck from "fast-check"
const PersonArb = Schema.toArbitrary(
Schema.Struct({ name: Schema.String, age: Schema.Number })
)
// Sample a random value
const sample = FastCheck.sample(PersonArb, 1)[0]
console.log(typeof sample.name) // "string"export function function toArbitrary<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]> (+1 overload)Derives a fast-check Arbitrary from a schema for property-based
testing. The derived arbitrary generates values that satisfy the schema.
Details
Constraints refine base generators; candidates add weighted sources while
filters still validate every value. { report: true } returns warnings such
as OpaqueFilter, while derivation errors remain fail-fast. Recursive
schemas use terminal branches and fail when no finite terminal path exists.
Example (Generating arbitrary values)
import { Schema } from "effect"
import * as FastCheck from "fast-check"
const PersonArb = Schema.toArbitrary(
Schema.Struct({ name: Schema.String, age: Schema.Number })
)
// Sample a random value
const sample = FastCheck.sample(PersonArb, 1)[0]
console.log(typeof sample.name) // "string"
toArbitrary<function (type parameter) S in toArbitrary<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]>S extends Constraint>(schema: S extends Constraintschema: function (type parameter) S in toArbitrary<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]>S): import FastCheckFastCheck.type FastCheck.Arbitrary = /*unresolved*/ anyArbitrary<function (type parameter) S in toArbitrary<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]>S["Type"]>
export function function toArbitrary<S extends Constraint>(schema: S, options: {
readonly report: true;
}): Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>> (+1 overload)
Derives a fast-check Arbitrary from a schema for property-based
testing. The derived arbitrary generates values that satisfy the schema.
Details
Constraints refine base generators; candidates add weighted sources while
filters still validate every value. { report: true } returns warnings such
as OpaqueFilter, while derivation errors remain fail-fast. Recursive
schemas use terminal branches and fail when no finite terminal path exists.
Example (Generating arbitrary values)
import { Schema } from "effect"
import * as FastCheck from "fast-check"
const PersonArb = Schema.toArbitrary(
Schema.Struct({ name: Schema.String, age: Schema.Number })
)
// Sample a random value
const sample = FastCheck.sample(PersonArb, 1)[0]
console.log(typeof sample.name) // "string"
toArbitrary<function (type parameter) S in toArbitrary<S extends Constraint>(schema: S, options: {
readonly report: true;
}): Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
S extends Constraint>(
schema: S extends Constraintschema: function (type parameter) S in toArbitrary<S extends Constraint>(schema: S, options: {
readonly report: true;
}): Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
S,
options: {
readonly report: true
}
options: { readonly report: truereport: true }
): Annotations.namespace Annotations.ToArbitraryTypes used by arbitrary-derivation annotations to configure toArbitrary
hooks, filter hints, candidate sources, diagnostics, and merged generation
constraints.
ToArbitrary.interface Annotations.ToArbitrary.WithReport<A>Wraps a derived value together with arbitrary-derivation diagnostics.
WithReport<import FastCheckFastCheck.type FastCheck.Arbitrary = /*unresolved*/ anyArbitrary<function (type parameter) S in toArbitrary<S extends Constraint>(schema: S, options: {
readonly report: true;
}): Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
S["Type"]>>
export function function toArbitrary<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]> (+1 overload)Derives a fast-check Arbitrary from a schema for property-based
testing. The derived arbitrary generates values that satisfy the schema.
Details
Constraints refine base generators; candidates add weighted sources while
filters still validate every value. { report: true } returns warnings such
as OpaqueFilter, while derivation errors remain fail-fast. Recursive
schemas use terminal branches and fail when no finite terminal path exists.
Example (Generating arbitrary values)
import { Schema } from "effect"
import * as FastCheck from "fast-check"
const PersonArb = Schema.toArbitrary(
Schema.Struct({ name: Schema.String, age: Schema.Number })
)
// Sample a random value
const sample = FastCheck.sample(PersonArb, 1)[0]
console.log(typeof sample.name) // "string"
toArbitrary<function (type parameter) S in toArbitrary<S extends Constraint>(schema: S, options?: {
readonly report?: boolean;
}): FastCheck.Arbitrary<S["Type"]> | Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
S extends Constraint>(
schema: S extends Constraintschema: function (type parameter) S in toArbitrary<S extends Constraint>(schema: S, options?: {
readonly report?: boolean;
}): FastCheck.Arbitrary<S["Type"]> | Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
S,
options: | {
readonly report?: boolean
}
| undefined
options?: { readonly report?: boolean | undefinedreport?: boolean }
): import FastCheckFastCheck.type FastCheck.Arbitrary = /*unresolved*/ anyArbitrary<function (type parameter) S in toArbitrary<S extends Constraint>(schema: S, options?: {
readonly report?: boolean;
}): FastCheck.Arbitrary<S["Type"]> | Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
S["Type"]> | Annotations.namespace Annotations.ToArbitraryTypes used by arbitrary-derivation annotations to configure toArbitrary
hooks, filter hints, candidate sources, diagnostics, and merged generation
constraints.
ToArbitrary.interface Annotations.ToArbitrary.WithReport<A>Wraps a derived value together with arbitrary-derivation diagnostics.
WithReport<import FastCheckFastCheck.type FastCheck.Arbitrary = /*unresolved*/ anyArbitrary<function (type parameter) S in toArbitrary<S extends Constraint>(schema: S, options?: {
readonly report?: boolean;
}): FastCheck.Arbitrary<S["Type"]> | Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
S["Type"]>> {
if (options: | {
readonly report?: boolean
}
| undefined
options?.report?: boolean | undefinedreport === true) {
const const lawc: anylawc = import InternalArbitraryInternalArbitrary.const memoized: anymemoized(schema: S extends Constraintschema.Constraint["ast"]: SchemaAST.ASTast)
const const report: InternalArbitrary.MutableReportconst report: {
warnings: Array<Schema.Annotations.ToArbitrary.Warning>;
}
report = import InternalArbitraryInternalArbitrary.function makeReport(): InternalArbitrary.MutableReportmakeReport()
import InternalArbitraryInternalArbitrary.function collectReport(
ast: SchemaAST.AST,
report: InternalArbitrary.MutableReport
): void
collectReport(schema: S extends Constraintschema.Constraint["ast"]: SchemaAST.ASTast, const report: InternalArbitrary.MutableReportconst report: {
warnings: Array<Schema.Annotations.ToArbitrary.Warning>;
}
report)
return {
value: anyvalue: const lawc: anylawc(import FastCheckFastCheck, {}),
report: Annotations.ToArbitrary.Report(property) report: {
warnings: ReadonlyArray<Warning>;
}
report: import InternalArbitraryInternalArbitrary.function toReport(
report: InternalArbitrary.MutableReport
): Annotations.ToArbitrary.Report
toReport(const report: InternalArbitrary.MutableReportconst report: {
warnings: Array<Schema.Annotations.ToArbitrary.Warning>;
}
report)
}
}
return function toArbitraryLazy<
S extends Constraint
>(schema: S): LazyArbitrary<S["Type"]>
Derives a
LazyArbitrary
from a schema. The result is memoized so
repeated calls with the same schema are cheap.
Details
Prefer
toArbitrary
when you need the arbitrary directly, or when you
want derivation diagnostics via { report: true }. Unsupported schema
nodes, impossible constraints, invalid candidates, and recursive schemas
without a finite terminal path fail immediately.
toArbitraryLazy(schema: S extends Constraintschema)(import FastCheckFastCheck)
}