Convert the LawSet options of a typeclass test into the options
of a composed typeclass test.
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.
Example
constgiven: ParameterizedGiven< // Original options. CovariantTypeLambda, MyTupleLambda, number > = … constcomposedGiven = liftGiven< CovariantTypeLambda, MyTupleLambda, // Wrapped data type. OptionTypeLambda// Wrapper data type. >()( 'Covariant', // Name of composed typeclass. 'Option<F>'// Will be used as test label suffix. options, // The original options. )( optionCovariant, // covariant instance for wrapper. OP.getEquivalence, // LiftEquivalence for wrapper. option, // LiftArbitrary for wrapper. ) // Only the datatype type lambda is different between the // input and output given: // composedGiven: ParameterizedGiven< // CovariantTypeLambda, // Still testing same laws. // ComposeTypeLambda<OptionTypeLambda, MyTupleLambda>, // number, // Underlying type does not change. // >
Convert the
LawSet
options of a typeclass test into the options of a composed typeclass test.For example if we are testing
Covariant
laws onMyTuple
, and the underlying types are allnumber
, then the correctgiven
type required for these tests, isParameterizedGiven<CovariantTypeLambda, MyTupleLambda, number>
.If we wanted to run the same law test but on a composed instance of
MyTuple
inside anOption
, 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.Example