effect-ts-laws
    Preparing search index...

    Interface UnfoldedGiven<Typeclass, F1, A, B, C, R, O, E>

    Unfolded requirements for testing parameterized typeclass laws. These are set as the union of all arguments required by the law predicates for parameterized typeclass laws.

    For example, the field aob is required by the filterableLaws composition typeclass law, and bab by * the the reduce law of foldableLaws.

    The nomenclature is based on the types of expressions, and is designed to make it easy, or at least easy as possible, for the author of law tests to find the correct arguments required by the predicates they are checking:

    1. A, B, and C are the underlying types. There are no predicates in any parameterized typeclass law that require more than three type parameters.
    2. Arbitraries
      1. Lower case a, b, and c are the names of arbitraries for the three underlying types.
      2. The arbitraries for the data type under test are called fa, fb, and fc, standing for arbitraries of F<A>, F<B>, and F<C> respectively.
      3. For simple unary arbitrary functions between two different underlying types, for example A ⇒ B, we use the lower case type names of argument followed by return value. For example an arbitrary for a function of type C ⇒ B we use the field name cb.
      4. Binary functions use the same pattern, so an arbitrary for a function of type (b: B, a: A) => B will be called bab.
      5. Unary function from a type to itself are named endo[TYPE], for example endoA is the name of an arbitrary a function A ⇒ A.
      6. Arbitraries for functions that lift an underlying type into the data type under test, also use the same naming pattern, except the return type is prefixed with a lowercase f. For example, afb is an arbitrary for a function of the type A ⇒ F<B>, where F is the higher-kinded datatype under test.
      7. Arbitraries that lift an underlying type into the Option data type are also named in this way, except the f is replaced by an o. aob, for example, is the field where you will find an arbitrary function of type A ⇒ Option<B>.
      8. Applicative laws, for example, require a function of the type: (of: <T>(a: T) => F<T>>) => Arbitrary<F<(a: A) => B>>>. I.e.: a function tht takes a lifting function, and returns an arbitrary for the unary function (a: A) => B. These are called just like the lifted function argument would have been called (afb), but with an Of suffix, and the f is moved to the head position. The function above, for example, would be found in a field called fabOf.
    3. Equivalences
      1. The equivalences for the underlying types are called equalsA, equalsB, and equalsC.
      2. The equivalences for the data type under test are called equalsFa, equalsFb, and equalsFc.
    4. For laws that require predicates, we have fields predicateA, predicateB, and predicateC, for functions that take a value of the underlying type and returns a boolean.

    Having all given arguments for all predicates in a central place is less open-closed. We still do it though, as it massively simplifies the code unfolding law predicate arguments.

    The type lambda of the datatype under test. For example when testing an instance of Covariant<Array<string>>, F would be the type lambda of the higher-kinded type Array.

    interface UnfoldedGiven<
        Typeclass extends TypeLambda,
        F1 extends TypeLambda,
        A,
        B = A,
        C = A,
        R = never,
        O = unknown,
        E = unknown,
    > {
        a: Arbitrary<A>;
        ab: Arbitrary<(a: A) => B>;
        afb: Arbitrary<(a: A) => Kind<F1, R, O, E, B>>;
        aob: Arbitrary<(a: A) => Option<B>>;
        b: Arbitrary<B>;
        ba: Arbitrary<(a: B) => A>;
        bab: Arbitrary<(b: B, a: A) => B>;
        bc: Arbitrary<(a: B) => C>;
        bfc: Arbitrary<(b: B) => Kind<F1, R, O, E, C>>;
        boc: Arbitrary<(a: B) => Option<C>>;
        c: Arbitrary<C>;
        cb: Arbitrary<(a: C) => B>;
        endoA: Arbitrary<(a: A) => A>;
        equalsA: Equivalence<A>;
        equalsB: Equivalence<B>;
        equalsC: Equivalence<C>;
        equalsFa: Equivalence<Kind<F1, R, O, E, A>>;
        equalsFb: Equivalence<Kind<F1, R, O, E, B>>;
        equalsFc: Equivalence<Kind<F1, R, O, E, C>>;
        F: Kind<Typeclass, R, O, E, F1>;
        fa: Arbitrary<Kind<F1, R, O, E, A>>;
        fabOf: (
            of: <T>(a: T) => Kind<F1, R, O, E, T>,
        ) => Arbitrary<Kind<F1, R, O, E, (a: A) => B>>;
        fb: Arbitrary<Kind<F1, R, O, E, B>>;
        fbcOf: (
            of: <T>(a: T) => Kind<F1, R, O, E, T>,
        ) => Arbitrary<Kind<F1, R, O, E, (a: B) => C>>;
        fc: Arbitrary<Kind<F1, R, O, E, C>>;
        getArbitrary: LiftArbitrary<F1, R, O, E>;
        getEquivalence: LiftEquivalence<F1, R, O, E>;
        Monoid: Monoid<A>;
        predicateA: Arbitrary<Predicate<A>>;
        predicateB: Arbitrary<Predicate<B>>;
        predicateC: Arbitrary<Predicate<C>>;
    }

    Type Parameters

    • Typeclass extends TypeLambda

      The type lambda of the typeclass under tests. For example when testing an instance of Covariant<Array<string>>, Typeclass would be the type lambda of the higher-kinded type Covariant.

    • F1 extends TypeLambda
    • A

      First underlying type for the typeclass tests.

    • B = A

      second underlying type for the typeclass tests.

    • C = A

      Third underlying type for the typeclass tests. Three is the maximum number of type parameters required by any predicate of the parameterized typeclass laws.

    • R = never
    • O = unknown
    • E = unknown

    Hierarchy (View Summary)

    Index

    Properties

    a: Arbitrary<A>

    An arbitrary for the underlying type A.

    ab: Arbitrary<(a: A) => B>
    afb: Arbitrary<(a: A) => Kind<F1, R, O, E, B>>
    aob: Arbitrary<(a: A) => Option<B>>
    b: Arbitrary<B>

    An arbitrary for the underlying type B.

    ba: Arbitrary<(a: B) => A>
    bab: Arbitrary<(b: B, a: A) => B>
    bc: Arbitrary<(a: B) => C>
    bfc: Arbitrary<(b: B) => Kind<F1, R, O, E, C>>
    boc: Arbitrary<(a: B) => Option<C>>
    c: Arbitrary<C>

    An arbitrary for the underlying type C.

    cb: Arbitrary<(a: C) => B>
    endoA: Arbitrary<(a: A) => A>
    equalsA: Equivalence<A>

    An equivalence for the underlying type A.

    equalsB: Equivalence<B>

    An equivalence for the underlying type B.

    equalsC: Equivalence<C>

    An equivalence for the underlying type C.

    equalsFa: Equivalence<Kind<F1, R, O, E, A>>
    equalsFb: Equivalence<Kind<F1, R, O, E, B>>
    equalsFc: Equivalence<Kind<F1, R, O, E, C>>
    F: Kind<Typeclass, R, O, E, F1>

    The higher-kinded type Typeclass<F> is the typeclass instance under test. For example when testing the Monad laws on an Either<number, string>, this would be Monad<Either>.

    fa: Arbitrary<Kind<F1, R, O, E, A>>
    fabOf: (
        of: <T>(a: T) => Kind<F1, R, O, E, T>,
    ) => Arbitrary<Kind<F1, R, O, E, (a: A) => B>>
    fb: Arbitrary<Kind<F1, R, O, E, B>>
    fbcOf: (
        of: <T>(a: T) => Kind<F1, R, O, E, T>,
    ) => Arbitrary<Kind<F1, R, O, E, (a: B) => C>>
    fc: Arbitrary<Kind<F1, R, O, E, C>>
    getArbitrary: LiftArbitrary<F1, R, O, E>

    A function that will get an arbitrary for the type under test from an arbitrary for the underlying type.

    getEquivalence: LiftEquivalence<F1, R, O, E>

    A function that will get an equivalence for the type under test from an equivalence for the underlying type.

    Monoid: Monoid<A>

    Required Monoid for the underlying type A, useful for typeclasses like Applicative that can build their own Monoid instance from it.

    predicateA: Arbitrary<Predicate<A>>

    Predicate for values of type A.

    predicateB: Arbitrary<Predicate<B>>

    Predicate for values of type B.

    predicateC: Arbitrary<Predicate<C>>

    Predicate for values of type C.