Function testTypeclassLaws

Test typeclass laws for the given instances of some datatype. This is just like testTypeclassLawsFor, but with all functions monomorphic on an underlying type of readonly number[]. At the contravariant key of this function, you will find the version of this function for contravariant datatypes.

// Test “Traversable” typeclass laws on “Identity” datatype.
import {
IdentityTypeLambda,
Traversable
} from '@effect/typeclass/data/Identity'
import {identity as id} from 'effect'
import {testTypeclassLaws, predicate} from 'effect-ts-laws'
testTypeclassLaws<IdentityTypeLambda>({
getEquivalence: identity,
getArbitrary: identity,
})({ Traversable })
  • Type Parameters

    • F extends TypeLambda

    Parameters

    • given: MonomorphicGiven<F, never, unknown, string>

      Test options for the datatype under test.

    Returns (<Ins>(instances: Ins, parameters?: ParameterOverrides) => void)

      • <Ins>(instances, parameters?): void
      • Type Parameters

        Parameters

        • instances: Ins

          Instances to test. Key is typeclass name and value is the instance under test. For example, { Monad: Option.Monad } will run the monad typeclass laws on Option.

        • Optionalparameters: ParameterOverrides

          Optional runtime fast-check parameters.

        Returns void

vitest

contravariant: (<F>(given: ContravariantGiven<F>) => (<Ins>(instances: Ins, parameters?: ParameterOverrides) => void))

Type declaration

    • <F>(given): (<Ins>(instances: Ins, parameters?: ParameterOverrides) => void)
    • Test typeclass laws for the given instances of some contravariant datatype: a higher-kinded datatype where the constructor type parameter appears in the contravariant position, for example Predicate. The underlying types used will all be readonly number[]. This is a version of testTypeclassLaws for contravariant datatypes.

      Type Parameters

      • F extends TypeLambda

      Parameters

      Returns (<Ins>(instances: Ins, parameters?: ParameterOverrides) => void)

        • <Ins>(instances, parameters?): void
        • Type Parameters

          Parameters

          • instances: Ins

            Instances to test. Key is typeclass name and value is the instance under test. For example, { Invariant: Predicate.Invariant } will run the Invariant typeclass laws on the datatype Predicate.

          • Optionalparameters: ParameterOverrides

            Optional runtime fast-check parameters.

          Returns void