úÎ4Ô1X)
!"#$%&'(portableprovisionalEdward Kmett <ekmett@gmail.com>Safe Dual function arrows.
Define an equivalence relation
*Defines a total ordering on a type as per )
6Any instance should be subject to the following laws:
contramap id = id
/ contramap f . contramap g = contramap (g . f)
GNote, that the second law follows from the free theorem of the type of
; and the first law, so you need only check that the former
condition holds.
Compare using )
Check for equivalence with *
+Equivalence relations are , because you can
B apply the contramapped function to each input to the equivalence
relation.
,A is a -
, because
can
@ apply its function argument to each input to each input to the
comparison function.
.A is a -
, because
can
< apply its function argument to the input of the predicate.
/0+,.1234567
/0+,.1234567portableexperimentalekmett@gmail.com
Safe-Inferred4Composition of contravariant and covariant functors
4Composition of covariant and contravariant functors
*Composition of two contravariant functors
89:;< 89:;<portableprovisionalEdward Kmett <ekmett@gmail.com>Trustworthy
3The Day convolution of two contravariant functors.
Construct the Day convolution
$ (
f g) = f
% (
f g) = g
?Break apart the Day convolution of two contravariant functors.
?Day convolution provides a monoidal product. The associativity
of this monoid is witnessed by and .
. = =
. = =
f > = >
f
?Day convolution provides a monoidal product. The associativity
of this monoid is witnessed by and .
. = =
. = =
f > = >
f
!The monoid for Day convolution
in Haskell is symmetric.
f > ! = ! >
f
"-Proxy serves as the unit of Day convolution.
$ > " = =
f > " = " >
f
#-Proxy serves as the unit of Day convolution.
% > # = =
f > # = # >
f
$PIn Haskell we can do general purpose elimination, but in a more general setting
, it is only possible to eliminate the unit.
$ > " = =
$ = ? >
f > $ = $ >
f
%PIn Haskell we can do general purpose elimination, but in a more general setting
, it is only possible to eliminate the unit.
% > # = =
% = @ >
f > % = % >
f
&!Diagonalize the Day convolution:
$ > & = =
% > & = =
'runDay > & = a
-> (a,a)
f . & = & .
f
'KApply a natural transformation to the left-hand side of a Day convolution.
IThis respects the naturality of the natural transformation you supplied:
f > ' fg = ' fg >
f
(LApply a natural transformation to the right-hand side of a Day convolution.
IThis respects the naturality of the natural transformation you supplied:
f > ( fg = ( fg >
f
A !"#$%&'(BC !"#$%&'( !"#$%&'(A !"#$%&'(BCD
!"#$%&'%&()*+,-./0123456789:;<+,=+,>+?@+?ABCDEcontravariant-0.4.4Data.Functor.Contravariant"Data.Functor.Contravariant.ComposeData.Functor.Contravariant.DayOpgetOpEquivalencegetEquivalence
Comparison
getComparison PredicategetPredicate
Contravariant contramap>$<>$$<defaultComparisondefaultEquivalence ComposeCFgetComposeCF ComposeFCgetComposeFCCompose
getComposeDaydayrunDayassocdisassocswappedintro1intro2day1day2diagtrans1trans2ghc-primGHC.Classescompare==$fContravariantEquivalence$fContravariantComparisonbaseGHC.BaseFunctor$fContravariantPredicate$fContravariantOp$fCategoryOp$fContravariantProxy$fContravariantReverse$fContravariantBackwards$fContravariantCompose$fContravariantConst$fContravariantConstant$fContravariantProduct$fFunctorComposeCF$fContravariantComposeCF$fFunctorComposeFC$fContravariantComposeFC$fFunctorComposeid.
Data.TuplefstsnddayTyCon$fContravariantDay$fTypeable1Day