^TpZ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYGADTs, MPTCs, fundeps provisionalEdward Kmett <ekmett@gmail.com> Trustworthy>The contravariant Yoneda lemma applied to a covariant functor 'Z[\]^_`abcdefghijklmnopqrstuvwxyz{&Z[\]^_`abcdefghijklmnopqrstuvwxyz{MPTCs, fundeps provisionalEdward Kmett <ekmett@gmail.com> Trustworthy, |}~   * |}~ rank N types experimentalEdward Kmett <ekmett@gmail.com> Trustworthy  f => g . Lift g f 8 (forall z. f => g . z) -> Lift g f => z -- couniversal UHere we use the universal property directly as how we extract from our definition of .  g .  g f => fLThis could alternately be defined directly from the (co)universal propertly  in which case, we'd get  =  UniversalRift, but then the usage would  suffer.    data  UniversalRift g f a = forall z.  z =>   UniversalRift" (forall x. g (z x) -> f x) (z a) EWe can witness the isomorphism between Rift and UniversalRift using:   < riftIso1 :: Functor g => UniversalRift g f a -> Rift g f a ' riftIso1 (UniversalRift h z) = Rift $ g -> h $ fmap (k -> k  $ z) g   / riftIso2 :: Rift g f a -> UniversalRift g f a ( riftIso2 (Rift e) = UniversalRift e id    riftIso1 (riftIso2 (Rift h)) = ; riftIso1 (UniversalRift h id) = -- by definition  Rift $ g -> h $ fmap (k -> k  $ id) g -- by definition  Rift $ g# -> h $ fmap id g --  $ = (.) and (.id)  Rift $ g2 -> h g -- by functor law ; Rift h -- eta reduction ;The other direction is left as an exercise for the reader. /There are several monads that we can form from Rift. When g@ is corepresentable (e.g. is a right adjoint) then there exists x such that  g ~ (->) x, then it follows that    Rift g g a ~ % forall r. (x -> a -> r) -> x -> r ~ % forall r. (a -> x -> r) -> x -> r ~  forall r. (a -> g r) -> g r ~  Codensity g r When f is a left adjoint, so that f -| g then    Rift f f a ~  forall r. f (a -> r) -> f r ~ ! forall r. (a -> r) -> g (f r) ~ ' forall r. (a -> r) -> Adjoint f g r ~  Yoneda (Adjoint f g r) 9An alternative way to view that is to note that whenever f is a left adjoint then f -|  f  , and since  f f is isomorphic to  f  (f a), this is the  formed by the adjunction.  w f ~  w f can be a  for any Comonad w.   m can be a  for any  m, as it is isomorphic to Yoneda m. 4Indexed applicative composition of right Kan lifts. The universal property of  When f -| u, then f -| Rift f Identity and    .  "a    .  "a  Rift f Identity a' is isomorphic to the right adjoint to f if one exists.    .  "a    .  "a  Rift f Identity a' is isomorphic to the right adjoint to f if one exists.     .  "a    .  "a  |  Rift f h a? is isomorphic to the post-composition of the right adjoint of f onto h! if such a right adjoint exists.    .  "a    .  "a   Rift f h a? is isomorphic to the post-composition of the right adjoint of f onto h! if such a right adjoint exists.  f => g ( g f a)The universal property of  When the adjunction exists     .  "a    .   "a  !   ! . " =   " . ! =  #Lift u Identity a& is isomorphic to the left adjoint to u if one exists.   # . $ "a   $ . # "a  $Lift u Identity a& is isomorphic to the left adjoint to u if one exists. % Lift u h a> is isomorphic to the post-composition of the left adjoint of u onto h if such a left adjoint exists.   % . & "a   & . % "a  & Lift u h a> is isomorphic to the post-composition of the left adjoint of u onto h if such a left adjoint exists.  !"#$%& !"#$%& !"#$%& !"#$%& rank 2 types experimentalEdward Kmett <ekmett@gmail.com> Trustworthy,, and -* witness a higher kinded adjunction. from ( `'Compose'` g) to ) g 88 and 9) witness the natural isomorphism between Lan f h and  Compose h g given f -| g :: and ;& witness the natural isomorphism from Lan f (Lan g h) and Lan (f o g) h '()*+,-./0123456789:;'()*+,-./0123456789:;)*+,-./0123'(456789:;'()*+,-./0123456789:;"non-portable (rank-2 polymorphism) provisionalEdward Kmett <ekmett@gmail.com> TrustworthyBGRight associate all binds in a computation that generates a free monad L This can improve the asymptotic efficiency of the result, while preserving  semantics. <=>?@AB<=>?@AB<=>?@AB<=>?@AB"non-portable (rank-2 polymorphism) provisionalEdward Kmett <ekmett@gmail.com> TrustworthyC   C w m a ~   w m a  F w a ~   w  a CDEFGHIJKLMNOPQRSTCDEFGHIJKLMNOPQRSTFGHCDEIJKLMNOPQRSTCDEFGHIJKLMNOPQRSTnon-portable (GADTs, MPTCs) experimentalEdward Kmett <ekmett@gmail.com> TrustworthyWWThe natural isomorphism between a comonad w and the comonad generated by w (forwards). UVWXYUVWXYUVWXY UVWXY            !"#$%&'())**+,-./0123456789:;<<=>?@ABCDEFGHIJKLMNOPQRRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwdefxljkmnqopWXYZVgih[\^]_`bacrstuvwyz{|}~yzyzkan-extensions-3.4!Data.Functor.Yoneda.ContravariantData.Functor.YonedaData.Functor.KanLiftData.Functor.KanExtensionControl.Monad.CodensityControl.Monad.CoControl.Comonad.DensityCoTRiftYoneda liftYoneda lowerYonedalowerM runYonedamaxFminFmaxMminMLiftrunLiftrunRiftrapgrifttoRiftfromRift adjointToRift riftToAdjoint composeRift decomposeRiftriftToComposedAdjointcomposedAdjointToRiftglifttoLiftfromLift composeLift decomposeLift adjointToLift liftToAdjointliftToComposedAdjointcomposedAdjointToLiftLanRanrunRantoRanfromRan composeRan decomposeRan adjointToRan ranToAdjointranToComposedAdjointcomposedAdjointToRantoLanfromLan adjointToLan lanToAdjointlanToComposedAdjointcomposedAdjointToLan composeLan decomposeLan Codensity runCodensitylowerCodensitycodensityToAdjunctionadjunctionToCodensityimproverunCoTCocorunColiftCoT0 lowerCoT0lowerCo0liftCoT1 lowerCoT1lowerCo1posWpeekWpeeksWaskWasksWtraceWDensity liftDensitydensityToAdjunctionadjunctionToDensity$fAdjunctionYonedaYoneda $fOrdYoneda $fEqYoneda $fReadYoneda $fShowYoneda$fDistributiveYoneda$fTraversableWithKey1Yoneda$fTraversableWithKeyYoneda$fTraversable1Yoneda$fTraversableYoneda$fFoldableWithKey1Yoneda$fFoldable1Yoneda$fFoldableWithKeyYoneda$fFoldableYoneda$fComonadTransYoneda$fComonadYoneda$fExtendYoneda$fRepresentableYoneda$fIndexableYoneda$fLookupYoneda$fMonadPlusYoneda$fMonadFixYoneda$fMonadTransYoneda $fMonadYoneda $fBindYoneda $fPlusYoneda $fAltYoneda$fAlternativeYoneda$fZipWithKeyYoneda $fZipYoneda$fApplicativeYoneda $fApplyYoneda $fKeyedYoneda$fFunctorYoneda$fMonadFreefYonedabaseGHC.BaseFunctortransformers-0.3.0.0Data.Functor.IdentityIdentityMonadid$fCopointedLift $fFunctorLift$fApplicativeRift $fPointedRift $fFunctorRift$fApplicativeLan $fApplyLan $fFunctorLan $fFunctorRan$fMonadStaterCodensity$fMonadFreefCodensity$fMonadPlusCodensity$fAlternativeCodensity$fPlusCodensity$fAltCodensity$fMonadTransCodensity$fMonadIOCodensity$fMonadCodensity$fApplicativeCodensity$fApplyCodensity$fFunctorCodensity$fMonadSpecCodensity$fMonadErroreCoT$fMonadWritereCoT$fMonadStatesCoT$fMonadReadereCoT $fMonadIOCoT$fMonadTransCoT $fMonadCoT$fApplicativeCoT $fBindCoT $fApplyCoT $fFunctorCoT$fMonadSpecCoT$fApplicativeDensity$fApplyDensity$fComonadTransDensity$fComonadDensity$fExtendDensity$fFunctorDensity