effect-ts-laws
Version:
effect-ts law testing using fast-check.
48 lines • 2.38 kB
TypeScript
import { Option as OP } from 'effect';
import type { Kind, TypeLambda } from 'effect/HKT';
import type { OptionTypeLambda } from 'effect/Option';
import type { ComposeKey, ComposeTypeLambda } from '../../../compose.js';
import type { ParameterizedGiven } from './given.js';
/**
* Return the given options transformed into options for a composed
* typeclass test, where the outer composed datatype is an `Option`.
*
* For example if we are testing `Covariant` laws on `MyTuple`, and
* the underlying types are all `number`, then the correct `given`
* type required for these tests, is
* `ParameterizedGiven<CovariantTypeLambda, MyTupleLambda, number>`.
*
* If we wanted to run the same law test but on a _composed instance_
* of `MyTuple` inside an `Option`, then we could use this function
* to convert the options to the required type. Then we can run these
* new options to test typeclass laws on the composed instance.
* @returns Typeclass test options for the `F` datatype when it is
* wrapped in an `Option`.
* @category composition
*/
export declare const withOuterOption: <K extends ComposeKey, Class extends TypeLambda, F extends TypeLambda, A, B = A, C = A, R = never, O = unknown, E = unknown>(
/**
* Type of composition requested: `Of`, `Invariant`, `Covariant`,
* `Applicative`, or `Traversable`. The `Option` datatype can do
* all of them.
*/
key: K,
/**
* The original {@link ParameterizedGiven} for the typeclass under test as
* it is _before_ composition.
*
*/
given: ParameterizedGiven<Class, F, A, B, C, R, O, E>,
/**
* The instance of `Option` for the typeclass under test.
*/
optionInstance: Kind<Class, R, O, E, OptionTypeLambda>) => readonly [`${K}Composition.${string}`, ParameterizedGiven<Class, ComposeTypeLambda<OP.OptionTypeLambda, F, R, O, E, R, O, E>, A, B, C, R, O, E>];
/**
* Composed typeclass law test options.
* @category composition
*/
export type ComposeGiven<Class extends TypeLambda, F extends TypeLambda, G extends TypeLambda, Os extends ParameterizedGiven<Class, F, any, any, any, any, any, any>> = Os extends ParameterizedGiven<Class, F, infer A, infer B, infer C, infer R, infer O, infer E> ? {
instance: Kind<Class, R, O, E, ComposeTypeLambda<G, F, R, O, E>>;
given: ParameterizedGiven<Class, ComposeTypeLambda<G, F, R, O, E>, A, B, C, R, O, E>;
} : never;
//# sourceMappingURL=compose.d.ts.map