effect-ts-laws
Version:
effect-ts law testing using fast-check.
73 lines • 3.11 kB
TypeScript
import type { LiftArbitrary } from '#arbitrary';
import type { LiftEquivalence } from '#law';
import { Monoid } from '@effect/typeclass';
import { Order as OD, Predicate as PR, Record as RC } from 'effect';
import { type Equivalence } from 'effect/Equivalence';
import type { Kind, TypeLambda } from 'effect/HKT';
import { type Option } from 'effect/Option';
import fc from 'fast-check';
import type { GivenConcerns, ParameterizedGiven } from '../parameterized/given.js';
/**
* The underlying type used for monomorphic typeclass law tests.
* This means that, for example, if we are testing the `Array`
* datatype, the actual type used in the tests will be
* `Array<Mono> ≡ Option<Option<number>>`.
* @category monomorphic
*/
export type Mono = Option<number>;
/**
* An arbitrary for the underlying type of the
* {@link vitest.testTypeclassLaws} unit under test.
* @category monomorphic
*/
export declare const monoArbitrary: fc.Arbitrary<Mono>;
/**
* Arbitrary for a record with string keys and `Mono` values.
* @category monomorphic
*/
export declare const monoRecordArbitrary: fc.Arbitrary<RC.ReadonlyRecord<string, Mono>>;
/** @category monomorphic */
export declare const monoPredicateArbitrary: fc.Arbitrary<PR.Predicate<Mono>>;
/**
* The equivalence used for {@link vitest.testTypeclassLaws}.
* @category monomorphic
*/
export declare const monoEquivalence: Equivalence<Mono>;
/**
* Equivalence for a record with string keys and `Mono` values.
* @category monomorphic
*/
export declare const monoRecordEquivalence: Equivalence<RC.ReadonlyRecord<string, Mono>>;
/**
* The order used for {@link vitest.testTypeclassLaws}.
* @category monomorphic
*/
export declare const monoOrder: OD.Order<Mono>;
/**
* Monoid instance for the `Mono` type.
* @category monomorphic
*/
export declare const monoMonoid: Monoid.Monoid<Mono>;
/**
* Build a sampling equivalence between functions of type
* `(numArray: Mono) ⇒ A`.
* @category monomorphic
*/
export declare const getMonoUnaryEquivalence: <A>(equalsA: Equivalence<A>) => Equivalence<(numArray: Mono) => A>;
/**
* Build a sampling equivalence for predicates of the underlying `Mono` type.
* @category monomorphic
*/
export declare const monoPredicateEquivalence: Equivalence<PR.Predicate<Mono>>;
/**
* Unfold the options for monomorphic typeclass law tests on the underlying type
* `Mono` from a function that will lift equivalence in the higher-kinded type
* under test, and one that will lift an arbitrary. This function is used inside
* typeclass law test code to unfold the requirements of their law predicates.
* @category monomorphic
*/
export declare const unfoldMonoGiven: {
<F extends TypeLambda, R = never, O = unknown, E = unknown>(getEquivalence: LiftEquivalence<F, R, O, E>, getArbitrary: LiftArbitrary<F, R, O, E>): GivenConcerns<F, Mono, Mono, Mono, R, O, E>;
contravariant: <Typeclass extends TypeLambda, F extends TypeLambda, R = never, O = unknown, E = unknown>(F: Kind<Typeclass, R, O, E, F>) => ParameterizedGiven<Typeclass, F, Mono, Mono, Mono, R, O, E>;
};
//# sourceMappingURL=mono.d.ts.map