úÎŕÓʇ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  €  ‚ ƒ „ … † (C) 2014-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableNone +;>ILN .The Day convolution of two covariant functors.Day f g a -> h a is isomorphic to f a -> Rift g h aConstruct the Day convolution_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 > convolution on the cartesian monoidal structure is symmetric. ˆ f ‰  =  ‰ ˆ f Š is the unit of  convolution  ‰  = ‡  ‰  = ‡ Š is the unit of  convolution  ‰   = ‡   ‰  = ‡ Š is the unit of  convolution  ‰  = ‡  ‰  = ‡ Š is the unit of  convolution  ‰   = ‡   ‰  = ‡  Collapse via a monoidal functor.   ( f g) = f ‹ g JApply a natural transformation to the left-hand side of a Day convolution.HThis respects the naturality of the natural transformation you supplied: ˆ f ‰   fg =   fg ‰ ˆ f KApply a natural transformation to the right-hand side of a Day convolution.HThis respects the naturality of the natural transformation you supplied: ˆ f ‰   fg =   fg ‰ ˆ f  ŒŽ     ŒŽ#2013-2016 Edward Kmett and Dan DoelBSDEdward Kmett <ekmett@gmail.com> experimental rank N typesNone!"IN  The natural isomorphism between f and  Curried f f.   ‰  "a ‡  ‰  "a ‡  ( x) -- definition  (  (‹ x)) -- definition (‹ x) ( ‡) -- beta reduction  ‡ ‹. x -- Applicative identity law x Lower   by applying  ‡ to the continuation.See .3Indexed applicative composition of right Kan lifts.This is the counit of the Day f -| Curried f adjunctionThis is the unit of the Day f -| Curried f adjunctionThe universal property of    .  "a ‡  .  "a ‡ Curried f Identity a' is isomorphic to the right adjoint to f if one exists.  .  "a ‡  .  "a ‡ Curried f Identity a' is isomorphic to the right adjoint to f if one exists. Curried 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 ‡  Curried f h a? is isomorphic to the post-composition of the right adjoint of f onto h if such a right adjoint exists. ‘’   ‘’(C) 2013-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalGADTs, TFs, MPTCs Trustworthy !"7>LA “6 functor (aka presheaf) suitable for Yoneda reduction. -http://ncatlab.org/nlab/show/Yoneda+reduction"Coyoneda "expansion" of a presheaf  .  "a ‡  .  "a ‡  Coyoneda reduction on a presheaf”•–”•–(C) 2013-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalGADTs, TFs, MPTCs Trustworthy !"7>ILNYoneda embedding for a presheaf" " . # "a ‡ # . " "a ‡  !"#—˜™ !"# !"# !"#—˜™=(C) 2013-2016 Edward Kmett, Gershom Bazerman and Derek Elkins BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableNone +;>ILN $2The 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 -{In Haskell we can do general purpose elimination, but in a more general setting it is only possible to eliminate the unit. - ‰ + = ‡ - = › ‰ ' š f ‰ - = - ‰ š f .}In 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: - ‰ / = ‡ . ‰ / = ‡ ' ‰ / = a -> (a,a) š f . / = / . š f 0JApply a natural transformation to the left-hand side of a Day convolution.HThis respects the naturality of the natural transformation you supplied: š f ‰ 0 fg = 0 fg ‰ š f 1KApply a natural transformation to the right-hand side of a Day convolution.HThis respects the naturality of the natural transformation you supplied: š f ‰ 1 fg = 1 fg ‰ š f $%&'()*+,-./01ž$%&'()*+,-./01$%&'()*+,-./01$%&'()*+,-./01ž2008-2016 Edward KmettBSDEdward Kmett <ekmett@gmail.com> experimental rank 2 types Trustworthy!"IN2The right Kan extension of a Ÿ h along a Ÿ g.ěWe can define a right Kan extension in several ways. The definition here is obtained by reading off the definition in of a right Kan extension in terms of an End, but we can derive an equivalent definition from the universal property.Given a Ÿ  h : C -> D and a Ÿ  g : C -> C', we want to extend h back along g to give Ran g h : C' -> C', such that the natural transformation = :: Ran g h (g a) -> h a exists.;In some sense this is trying to approximate the inverse of g^ by using one of its adjoints, because if the adjoint and the inverse both exist, they match! EHask -h-> Hask | + g / | Ran g h v / Hask -'_The Right Kan extension is unique (up to isomorphism) by taking this as its universal property.That is to say given any  K : C' -> C1 such that we have a natural transformation from k.g to h (forall x. k (g x) -> h x)6 there exists a canonical natural transformation from k to Ran g h. (forall x. k x -> Ran g h x).BWe could literally read this off as a valid Rank-3 definition for 2: data Ran' g h a = forall z. Ÿ, z => Ran' (forall x. z (g x) -> h x) (z a) \This definition is isomorphic the simpler Rank-2 definition we use below as witnessed by the ?ranIso1 :: Ran g f x -> Ran' g f x ranIso1 (Ran e) = Ran' e id  PranIso2 :: Ran' g f x -> Ran g f x ranIso2 (Ran' h z) = Ran $ \k -> h (k <$> z)  äranIso2 (ranIso1 (Ran e)) "a -- by definition ranIso2 (Ran' e id) "a -- by definition Ran $ \k -> e (k <$> id) -- by definition Ran $ \k -> e (k . id) -- f . id = f Ran $ \k -> e k -- eta reduction Ran e :The other direction is left as an exercise for the reader.50The universal property of a right Kan extension.65 and 6* witness a higher kinded adjunction. from (`Compose' g) to 2 g 5 . 6 "a ‡ 6 . 5 "a ‡ 7 7 . 8 "a ‡ 8 . 7 "a ‡ 9 9 . : "a ‡ : . 9 "a ‡ ; < . ; "a ‡ ; . < "a ‡ =FThis is the natural transformation that defines a Right Kan extension.23456789:;<=>?@A 23456789:;<=>?@A23456=789:<;>?A@23456789:;<=>?@A (C) 2011-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalMPTCs, fundeps Trustworthy 3457>ILNB Yoneda f a- can be viewed as the partial application of ˆ to its second argument.E The natural isomorphism between f and B f, given by the Yoneda lemma is witnessed by E and F E . F "a ‡ F . E "a ‡  ÖlowerYoneda (liftYoneda fa) = -- definition lowerYoneda (Yoneda (f -> fmap f a)) -- definition (f -> fmap f fa) id -- beta reduction fmap id fa -- functor law fa Ą = E GYoneda f- can be viewed as the right Kan extension of f along the Š functor. G . H "a ‡ H . G "a ‡ %BCDEFGHIJKL˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ľśˇ¸šşť BCDEFGHIJKL BCDEFIJKLGH#BCDEFGHIJKL˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ľśˇ¸šşť(C) 2008-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional"non-portable (rank-2 polymorphism) Trustworthy+357INMM fB is the Monad generated by taking the right Kan extension of any Ÿ f along itself (Ran f f).5This can often be more "efficient" to construct than f( itself using repeated applications of (>>=).ySee "Asymptotic Improvement of Computations over Free Monads" by Janis Voigtländer for more information about this type. (http://www.iai.uni-bonn.de/~jv/mpc08.pdfP2This serves as the *left*-inverse (retraction) of Ą. P . Ą "a ‡ HIn general this is not a full 2-sided inverse, merely a retraction, as M m% is often considerably "larger" than m.e.g. M0 ((->) s)) a ~ forall r. (a -> s -> r) -> s -> r% could support a full complement of ź s actions, while (->) s is limited to ˝ s actions.QThe MH monad of a right adjoint is isomorphic to the monad obtained from the ž. Q . R "a ‡ R . Q "a ‡ SThe M monad of a representable Ÿ/ is isomorphic to the monad obtained from the ž for which that Ÿ is the right adjoint. S . T "a ‡ T . S "a ‡ codensityToComposedRep = @ . U T T = V . A UThe M ż of a Ÿ g is the right Kan extension (2) of g along itself. U . V "a ‡ V . U "a ‡ WFRight associate all binds in a computation that generates a free monadVThis can improve the asymptotic efficiency of the result, while preserving semantics.€See "Asymptotic Improvement of Computations over Free Monads" by Janis Voightländer for more information about this combinator. (http://www.iai.uni-bonn.de/~jv/mpc08.pdfMNOPQRSTUVWŔÁÂĂÄĹĆÇČÉĘËĚ MNOPQRSTUVW MNOPQRUVSTWMNOPQRSTUVWŔÁÂĂÄĹĆÇČÉĘËĚ 2008-2016 Edward KmettBSDEdward Kmett <ekmett@gmail.com> experimental rank 2 typesSafe!"INXThe left Kan extension of a Ÿ h along a Ÿ g.Z/The universal property of a left Kan extension.[[ and Z. witness a (higher kinded) adjunction between X g and (Compose g) Z . [ "a ‡ [ . Z "a ‡ \ \ . ] "a ‡ ] . \ "a ‡ ^^ and _) witness the natural isomorphism between Lan f h and  Compose h g given f -| g _ . ^ "a ‡ ^ . _ "a ‡ `` and a& witness the natural isomorphism from Lan f (Lan g h) and Lan (f o g) h ` . a "a ‡ a . ` "a ‡ bEThis is the natural transformation that defines a Left Kan extension.XYZ[\]^_`abÍÎĎ XYZ[\]^_`ab XYZ[b`a\]_^ XYZ[\]^_`abÍÎĎ (C) 2011-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalGADTs, MPTCs, fundeps Trustworthy !"47>Lc A covariant Ÿ suitable for Yoneda reductione Coyoneda f is the left Kan extension of f along the Š functor. Coyoneda f is always a functor, even if f) is not. In this case, it is called the free functor over f1. Note the following categorical fine print: If f is not a functor,  Coyoneda f, is actually not the left Kan extension of f along the ŠL functor, but along the inclusion functor from the discrete subcategory of HaskK which contains only identity functions as morphisms to the full category Hask. (This is because f, not being a proper functor, can only be interpreted as a categorical functor by restricting the source category to only contain identities.) e . f "a ‡ f . e "a ‡ gYoneda "expansion" g . h "a ‡ h . g "a ‡  šlowerCoyoneda (liftCoyoneda fa) = -- by definition lowerCoyoneda (Coyoneda id fa) = -- by definition fmap id fa = -- functor law fa Ą = g h>Yoneda reduction lets us walk under the existential and apply ˆ.NMnemonically, "Yoneda reduction" sounds like and works a bit like ˛-reduction. -http://ncatlab.org/nlab/show/Yoneda+reduction You can view c as just the arguments to ˆ tupled up. Đ = i = h iYoneda reduction given a ż. lets us walk under the existential and apply Ń. You can view c as just the arguments to Ń tupled up. Đ = i = h cdefghiŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęcdefghicdghiefcdefghiŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéę (C) 2008-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalnon-portable (GADTs, MPTCs)Safe!"7l"The natural transformation from a ë w to the ë generated by w (forwards).,This is merely a right-inverse (section) of Đ, rather than a full inverse. Đ . l "a ‡ m The Density ë( of a left adjoint is isomorphic to the ë formed by that ž.!This isomorphism is witnessed by m and n. m . n "a ‡ n . m "a ‡ oThe j ë of a Ÿ f0 is obtained by taking the left Kan extension (X) of f0 along itself. This isomorphism is witnessed by o and p o . p "a ‡ p . o "a ‡ jklmnopěíîďđńjklmnopjklmnpo jklmnopěíîďđń (C) 2011-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional"non-portable (rank-2 polymorphism)Safe3457INq t w a ~   w Š a !qrstuvwxyz{|}~€‚ƒ„…†ňóôőö÷řůúűüqrstuvwxyz{|}~€‚ƒ„…†tuvqrswƒxyz„{|…†}~€‚qrstuvwxyz{|}~€‚ƒ„…†ňóôőö÷řůúűüý !"#$%&'(()*++,-./01233456789:;<=>?@A++,-.BCDEFGHHIJKLMNOPQ R R S T U V W X Y Z [ ( ( \ ] ) * ^ _ _ ` a b c d e e f g h i j k l m n o p q r s t u v w x yz{|z{}z{~z€z{‚ƒ„…z{†‡ˆ‰Š‹ŒŽ‘‰Š’z“”z“•‚–z{—˜™š›œžŸ Ą˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ľś´ˇ¸šşťz{ź˝žżŔÁÂĂÄĹĆÇČÉ Ę Ë ĚÍÎĎz{Đ Œ Ń Ň Ó Ô Ő Ö × Ř Ů Ú Ű Ü  Ý Ţ ß ŕ á â ă ä ĺ ć çÍčé ę ë ě í î ď đ ń ň ó ô ő ö ÷ ř ů úűkanex_F6Mj0a2Sr6vFNX95PMzl8TData.Functor.DayData.Functor.Day.Curried#Data.Functor.Contravariant.Coyoneda!Data.Functor.Contravariant.YonedaData.Functor.Contravariant.DayData.Functor.Kan.RanData.Functor.YonedaControl.Monad.CodensityData.Functor.Kan.LanData.Functor.CoyonedaControl.Comonad.DensityControl.Monad.CoData.Functor.Kan.RiftRiftDaydayassocdisassocswappedintro1intro2elim1elim2daptrans1trans2Curried runCurried liftCurried lowerCurriedrapapplied unapplied toCurried fromCurriedadjointToCurriedcurriedToAdjointcurriedToComposedAdjointcomposedAdjointToCurriedCoyoneda liftCoyoneda lowerCoyonedaYoneda runYoneda liftYoneda lowerYonedarunDayday1day2diagRanrunRantoRanfromRan composeRan decomposeRan adjointToRan ranToAdjointranToComposedAdjointcomposedAdjointToRangranrepToRanranToRepranToComposedRepcomposedRepToRan yonedaToRan ranToYonedamaxFminFmaxMminM Codensity runCodensitylowerCodensitycodensityToAdjunctionadjunctionToCodensitycodensityToComposedRepcomposedRepToCodensitycodensityToRanranToCodensityimproveLantoLanfromLan adjointToLan lanToAdjointlanToComposedAdjointcomposedAdjointToLan composeLan decomposeLanglan coyonedaToLan lanToCoyonedalowerMDensity liftDensitydensityToAdjunctionadjunctionToDensity lanToDensity densityToLanCoTrunCoTCocorunColiftCoT0 lowerCoT0lowerCo0liftCoT1 lowerCoT1lowerCo1posWpeekWpeeksWaskWasksWtraceW liftCoT0M liftCoT1MditerdctrlMbaseGHC.Baseidfmap.Data.Functor.IdentityIdentity<*>$fRepresentableDay$fDistributiveDay$fApplicativeDay $fFunctorDaypure$fApplicativeCurried$fFunctorCurriedcontr_LxARs66IWzOGQC8CMWQkcDData.Functor.Contravariant Contravariant$fAdjunctionCoyonedaCoyoneda$fRepresentableCoyoneda$fContravariantCoyoneda$fAdjunctionYonedaYoneda$fRepresentableYoneda$fContravariantYoneda contramap Data.Tuplefstsnd$fContravariantDayFunctor $fFunctorRantrans_3eG64VdP2vzGjP6wJiCp5XControl.Monad.Trans.Classlift$fComonadTransYoneda$fComonadYoneda$fExtendYoneda$fMonadFreefYoneda$fMonadTransYoneda$fMonadPlusYoneda$fMonadFixYoneda $fMonadYoneda $fBindYoneda$fAlternativeYoneda $fPlusYoneda $fAltYoneda $fOrdYoneda $fEqYoneda $fReadYoneda $fShowYoneda$fDistributiveYoneda$fTraversable1Yoneda$fTraversableYoneda$fFoldable1Yoneda$fFoldableYoneda$fApplicativeYoneda $fApplyYoneda$fFunctorYonedamtl_KMpng31YRYc5JfMWFZ3FCUControl.Monad.State.Class MonadStateControl.Monad.Reader.Class MonadReaderadjun_1pDKNTZKR9U5PBML8JZdi1Data.Functor.Adjunction AdjunctionMonad$fMonadReaderrCodensity$fMonadStaterCodensity$fMonadFreefCodensity$fMonadPlusCodensity$fAlternativeCodensity$fPlusCodensity$fAltCodensity$fMonadTransCodensity$fMonadIOCodensity$fMonadCodensity$fApplicativeCodensity$fApplyCodensity$fFunctorCodensity$fApplicativeLan $fApplyLan $fFunctorLancomon_1qolsfbfk8T9qU0rqRneeIControl.Comonad.Trans.ClasslowerliftM $fOrdCoyoneda $fEqCoyoneda$fReadCoyoneda$fShowCoyoneda$fDistributiveCoyoneda$fTraversable1Coyoneda$fTraversableCoyoneda$fFoldable1Coyoneda$fFoldableCoyoneda$fComonadTransCoyoneda$fComonadCoyoneda$fExtendCoyoneda$fMonadPlusCoyoneda$fMonadFixCoyoneda$fMonadTransCoyoneda$fMonadCoyoneda$fBindCoyoneda$fPlusCoyoneda $fAltCoyoneda$fAlternativeCoyoneda$fApplicativeCoyoneda$fApplyCoyoneda$fFunctorCoyonedaControl.ComonadComonad$fApplicativeDensity$fApplyDensity$fComonadTransDensity$fComonadDensity$fExtendDensity$fFunctorDensity$fMonadErroreCoT$fMonadWritereCoT$fMonadStatesCoT$fMonadReadereCoT $fMonadIOCoT$fMonadTransCoT $fMonadCoT$fApplicativeCoT $fBindCoT $fApplyCoT $fFunctorCoT