h*[hTݑ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                     5.2.6 (C) 2013-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett  provisionalGADTs, TFs, MPTCs Trustworthy )*]kan-extensionsA 6 functor (aka presheaf) suitable for Yoneda reduction. -http://ncatlab.org/nlab/show/Yoneda+reductionkan-extensions"Coyoneda "expansion" of a presheaf  .  D   .  D  kan-extensions Coyoneda reduction on a presheafkan-extensions#Lift a natural transformation from f to g# to a natural transformation from  Coyoneda f to  Coyoneda g.=(C) 2013-2016 Edward Kmett, Gershom Bazerman and Derek Elkins BSD-style (see the file LICENSE)Edward Kmett  provisionalportable Safe-Inferred 7 kan-extensions2The Day convolution of two contravariant functors. kan-extensionsConstruct the Day convolution  (  f g) = f  (  f g) = g kan-extensions>Break apart the Day convolution of two contravariant functors. kan-extensionsDay convolution provides a monoidal product. The associativity of this monoid is witnessed by   and  .   .   =    .   =   f    =     f kan-extensionsDay convolution provides a monoidal product. The associativity of this monoid is witnessed by   and  .   .   =    .   =   f    =     f kan-extensionsThe monoid for Day convolution  in Haskell is symmetric.  f   =    f kan-extensions,Proxy serves as the unit of Day convolution.    =   f   =    f kan-extensions,Proxy serves as the unit of Day convolution.    =   f   =    f kan-extensionsIn Haskell we can do general purpose elimination, but in a more general setting it is only possible to eliminate the unit.    =   =      f   =    f kan-extensionsIn Haskell we can do general purpose elimination, but in a more general setting it is only possible to eliminate the unit.     =   =      f   =    f kan-extensions Diagonalize the Day convolution:    =     =      = a -> (a,a)  f .  =  .  f kan-extensionsApply a natural transformation to the left-hand side of a Day convolution.This respects the naturality of the natural transformation you supplied:  f   fg =  fg   f kan-extensionsApply a natural transformation to the right-hand side of a Day convolution.This respects the naturality of the natural transformation you supplied:  f   fg =  fg   f   (C) 2013-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett  provisionalGADTs, TFs, MPTCs Trustworthy )**kan-extensionsYoneda embedding for a presheafkan-extensions  .  D   .  D  (C) 2014-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett  provisionalportable Safe-Inferred 7} "kan-extensions.The Day convolution of two covariant functors.$kan-extensionsConstruct the Day convolution%kan-extensionsDay convolution provides a monoidal product. The associativity of this monoid is witnessed by % and &. % . & =  & . % =   f  % = %   f &kan-extensionsDay convolution provides a monoidal product. The associativity of this monoid is witnessed by % and &. % . & =  & . % =   f  & = &   f 'kan-extensionsThe monoid for "> convolution on the cartesian monoidal structure is symmetric.  f  ' = '   f (kan-extensions is the unit of " convolution (  * =  *  ( =  )kan-extensions is the unit of " convolution )  + =  +  ) =  *kan-extensions is the unit of " convolution (  * =  *  ( =  +kan-extensions is the unit of " convolution )  + =  +  ) =  ,kan-extensions Collapse via a monoidal functor. , ($ f g) = f  g -kan-extensionsApply a natural transformation to the left-hand side of a Day convolution.This respects the naturality of the natural transformation you supplied:  f  - fg = - fg   f .kan-extensionsApply a natural transformation to the right-hand side of a Day convolution.This respects the naturality of the natural transformation you supplied:  f  . fg = . fg   f 0kan-extensions&Proposition 4.1 from Pastro and Street"#$,%&'()*+-./0"#$,%&'()*+-./0#2013-2016 Edward Kmett and Dan DoelBSDEdward Kmett  experimental rank N types Safe-Inferred)*" <kan-extensions The natural isomorphism between f and  Curried f f.  =  < D  <  = D  = (< x) -- definition = (9 ( x)) -- definition ( x) ( ) -- beta reduction   . x -- Applicative identity law x =kan-extensionsLower 9 by applying   to the continuation.See <.>kan-extensions3Indexed applicative composition of right Kan lifts.?kan-extensionsThis is the counit of the Day f -| Curried f adjunction@kan-extensionsThis is the unit of the Day f -| Curried f adjunctionAkan-extensionsThe universal property of 9Bkan-extensions A . B D  B . A D  Ckan-extensionsCurried f Identity a' is isomorphic to the right adjoint to f if one exists. C . D D  D . C D  Dkan-extensionsCurried f Identity a' is isomorphic to the right adjoint to f if one exists.Ekan-extensions Curried f h a? is isomorphic to the post-composition of the right adjoint of f onto h if such a right adjoint exists. E . F D  F . E D  Fkan-extensions Curried f h a? is isomorphic to the post-composition of the right adjoint of f onto h if such a right adjoint exists.9:;AB?@CDFE<=>9:;AB?@CDFE<=>(C) 2018 Brian Mckenna BSD-style (see the file LICENSE)Edward Kmett  provisionalportable Safe-Inferred*h Jkan-extensions.The Day convolution of two invariant functors.Lkan-extensionsConstruct the Day convolutionMkan-extensionsDay convolution provides a monoidal product. The associativity of this monoid is witnessed by M and N. M . N =  N . M =   f g  M = M   f g Nkan-extensionsDay convolution provides a monoidal product. The associativity of this monoid is witnessed by M and N. M . N =  N . M =   f g  N = N   f g Okan-extensionsThe monoid for J> convolution on the cartesian monoidal structure is symmetric.  f g  O = O   f g Pkan-extensions is the unit of J convolution P  R =  R  P =  Qkan-extensions is the unit of J convolution Q  S =  S  Q =  Rkan-extensions is the unit of J convolution P  R =  R  P =  Skan-extensions is the unit of J convolution Q  S =  S  Q =  Tkan-extensionsApply a natural transformation to the left-hand side of a Day convolution.This respects the naturality of the natural transformation you supplied:  f g  T fg = T fg   f g Ukan-extensionsApply a natural transformation to the right-hand side of a Day convolution.This respects the naturality of the natural transformation you supplied:  f g  U fg = U fg   f g Vkan-extensions/Drop the covariant part of the Day convolution.Wkan-extensions3Drop the contravariant part of the Day convolution.JKLMNOPQRSTUVWJKLMNOPQRSTUVW2008-2016 Edward KmettBSDEdward Kmett  experimental rank 2 types Safe-Inferred)*0.Ykan-extensionsThe left Kan extension of a  h along a  g.[kan-extensions/The universal property of a left Kan extension.\kan-extensions\ and [. witness a (higher kinded) adjunction between Y g and (Compose g) [ . \ D  \ . [ D  ]kan-extensions ] . ^ D  ^ . ] D  _kan-extensions_ and `) witness the natural isomorphism between Lan f h and  Compose h g given f -| g ` . _ D  _ . ` D  akan-extensionsa and b& witness the natural isomorphism from Lan f (Lan g h) and Lan (f o g) h a . b D  b . a D  ckan-extensionsThis is the natural transformation that defines a Left Kan extension. YZ[\cab]^`_ YZ[\cab]^`_(C) 2011-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett  provisionalGADTs, MPTCs, fundeps Trustworthy )*6|gkan-extensions A covariant  suitable for Yoneda reductionikan-extensions 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  functor, but along the inclusion functor from the discrete subcategory of Hask 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.) i . j D  j . i D  kkan-extensionsYoneda "expansion" k . l D  l . k D   lowerCoyoneda (liftCoyoneda fa) = -- by definition lowerCoyoneda (Coyoneda id fa) = -- by definition fmap id fa = -- functor law fa  = k lkan-extensions>Yoneda reduction lets us walk under the existential and apply .Mnemonically, "Yoneda reduction" sounds like and works a bit like -reduction. -http://ncatlab.org/nlab/show/Yoneda+reduction You can view g as just the arguments to  tupled up.  = m = l mkan-extensionsYoneda reduction given a . lets us walk under the existential and apply . You can view g as just the arguments to  tupled up.  = m = l nkan-extensions#Lift a natural transformation from f to g# to a natural transformation from  Coyoneda f to  Coyoneda g.ghklmnijghklmnij (C) 2008-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett  experimentalnon-portable (GADTs, MPTCs) Safe-Inferred)*0:(kan-extensions"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.  .  D  kan-extensions The Density ( of a left adjoint is isomorphic to the  formed by that .!This isomorphism is witnessed by  and .  .  D   .  D  kan-extensionsThe   of a  f0 is obtained by taking the left Kan extension (Y) of f0 along itself. This isomorphism is witnessed by  and   .  D   .  D   (C) 2011-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett  provisional"non-portable (rank-2 polymorphism) Safe-Inferred 0;@kan-extensions  w a ~  w  a  2008-2016 Edward KmettBSDEdward Kmett  experimental rank 2 types Trustworthy)*0Ekan-extensionsThe 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' -> D', 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! Hask -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' -> D1 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).We could literally read this off as a valid Rank-3 definition for : 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  ranIso2 :: Ran' g f x -> Ran g f x ranIso2 (Ran' h z) = Ran $ \k -> h (k <$> z)  ranIso2 (ranIso1 (Ran e)) D -- by definition ranIso2 (Ran' e id) D -- 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.kan-extensions0The universal property of a right Kan extension.kan-extensions and * witness a higher kinded adjunction. from (`Compose' g) to  g  .  D   .  D  kan-extensions  .  D   .  D  kan-extensions  .  D   .  D  kan-extensions  .  D   .  D  kan-extensionsThis is the natural transformation that defines a Right Kan extension. (C) 2008-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett  provisional"non-portable (rank-2 polymorphism) Trustworthy0P kan-extensions f 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 (>>=).See "Asymptotic Improvement of Computations over Free Monads" by Janis Voigtlnder for more information about this type. https://www.janis-voigtlaender.eu/papers/AsymptoticImprovementOfComputationsOverFreeMonads.pdfkan-extensions2This serves as the *left*-inverse (retraction) of .  .  D  In general this is not a full 2-sided inverse, merely a retraction, as  m% is often considerably "larger" than m.e.g. 0 ((->) s)) a ~ forall r. (a -> s -> r) -> s -> r% could support a full complement of  s actions, while (->) s is limited to  s actions.kan-extensionsThe  monad of a right adjoint is isomorphic to the monad obtained from the .  .  D   .  D  kan-extensionsThe  monad of a representable / is isomorphic to the monad obtained from the  for which that  is the right adjoint.  .  D   .  D  codensityToComposedRep =  .  kan-extensions  =  .  kan-extensionsThe   of a  g is the right Kan extension () of g along itself.  .  D   .  D  kan-extensionsRight associate all binds in a computation that generates a free monadThis can improve the asymptotic efficiency of the result, while preserving semantics.See "Asymptotic Improvement of Computations over Free Monads" by Janis Voightlnder for more information about this combinator. (http://www.iai.uni-bonn.de/~jv/mpc08.pdfkan-extensionsWrap the remainder of the " action using the given function.This function can be used to register cleanup actions that will be executed at the end. Example: *wrapCodensity (`finally` putStrLn "Done.")kan-extensions m" delimits the continuation of any  inside m.  ( m) =  mkan-extensions f8 captures the continuation up to the nearest enclosing  and passes it to f:  ( f >>= k) =  (f ( . k)) (C) 2011-2016 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett  provisionalMPTCs, fundeps Trustworthy Tkan-extensions Yoneda f a- can be viewed as the partial application of  to its second argument.kan-extensions The natural isomorphism between f and  f, given by the Yoneda lemma is witnessed by  and   .  D   .  D   lowerYoneda (liftYoneda fa) = -- definition lowerYoneda (Yoneda (f -> fmap f a)) -- definition (f -> fmap f fa) id -- beta reduction fmap id fa -- functor law fa  =  kan-extensionsYoneda f- can be viewed as the right Kan extension of f along the  functor.  .  D   .  D   0 !"#$%&'())*+,-./012#$34567%&89:;;<=>?@ABCDEFGHIJ01#$KLMNNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwx y y z { | } ~                                                                                      ) ) * + ,                           - .         +kan-extensions-5.2.6-550A3QDRW7424gxHPpNn82#Data.Functor.Contravariant.CoyonedaData.Functor.Contravariant.Day!Data.Functor.Contravariant.YonedaData.Functor.DayData.Functor.Day.CurriedData.Functor.Invariant.DayData.Functor.Kan.LanData.Functor.CoyonedaControl.Comonad.DensityControl.Monad.CoData.Functor.Kan.RanControl.Monad.CodensityData.Functor.Yonedakan-extensionsData.Functor.Kan.RiftRiftCoyoneda liftCoyoneda lowerCoyoneda hoistCoyoneda$fAdjunctionCoyonedaCoyoneda$fRepresentableCoyoneda$fContravariantCoyonedaDaydayrunDayassocdisassocswappedintro1intro2day1day2diagtrans1trans2$fAdjunctionDayDay$fRepresentableDay$fDivisibleDay$fContravariantDayYoneda runYoneda liftYoneda lowerYoneda$fAdjunctionYonedaYoneda$fRepresentableYoneda$fContravariantYonedaelim1elim2dapcayleydayley$fComonadTransDay$fComonadApplyDay $fComonadDay$fDistributiveDay$fApplicativeDay $fFunctorDayCurried runCurried liftCurried lowerCurriedrapapplied unapplied toCurried fromCurriedadjointToCurriedcurriedToAdjointcurriedToComposedAdjointcomposedAdjointToCurried$fApplicativeCurried$fApplyCurried$fFunctorCurriedtoContravariant toCovariant$fInvariantDayLantoLanfromLan adjointToLan lanToAdjointlanToComposedAdjointcomposedAdjointToLan composeLan decomposeLanglan$fApplicativeLan $fApplyLan $fFunctorLan coyonedaToLan lanToCoyonedalowerM $fOrdCoyoneda $fEqCoyoneda$fOrd1Coyoneda $fEq1Coyoneda$fReadCoyoneda$fShowCoyoneda$fRead1Coyoneda$fShow1Coyoneda$fDistributiveCoyoneda$fTraversable1Coyoneda$fTraversableCoyoneda$fFoldable1Coyoneda$fFoldableCoyoneda$fComonadTransCoyoneda$fComonadCoyoneda$fExtendCoyoneda$fMonadPlusCoyoneda$fMonadFixCoyoneda$fMonadTransCoyoneda$fMonadCoyoneda$fBindCoyoneda$fPlusCoyoneda $fAltCoyoneda$fAlternativeCoyoneda$fApplicativeCoyoneda$fApplyCoyoneda$fFunctorCoyonedaDensity liftDensitydensityToAdjunctionadjunctionToDensity lanToDensity densityToLan$fApplicativeDensity$fApplyDensity$fComonadTransDensity$fComonadDensity$fExtendDensity$fFunctorDensityCoTrunCoTCocorunColiftCoT0 lowerCoT0lowerCo0liftCoT1 lowerCoT1lowerCo1posWpeekWpeeksWaskWasksWtraceW liftCoT0M liftCoT1MditerdctrlM$fMonadErroreCoT$fMonadWritereCoT$fMonadStatesCoT$fMonadReadereCoT $fMonadIOCoT$fMonadTransCoT$fMonadFailCoT $fMonadCoT$fApplicativeCoT $fBindCoT $fApplyCoT $fFunctorCoTRanrunRantoRanfromRan composeRan decomposeRan adjointToRan ranToAdjointranToComposedAdjointcomposedAdjointToRangranrepToRanranToRepranToComposedRepcomposedRepToRan $fFunctorRan Codensity runCodensitylowerCodensitycodensityToAdjunctionadjunctionToCodensitycodensityToComposedRepcomposedRepToCodensitycodensityToRanranToCodensityimprove wrapCodensityresetshift$fMonadReaderrCodensity$fMonadStaterCodensity$fMonadFreefCodensity$fMonadPlusCodensity$fAlternativeCodensity$fPlusCodensity$fAltCodensity$fMonadTransCodensity$fMonadIOCodensity$fMonadFailCodensity$fMonadCodensity$fApplicativeCodensity$fApplyCodensity$fFunctorCodensity yonedaToRan ranToYonedamaxFminFmaxMminM$fComonadTransYoneda$fComonadYoneda$fExtendYoneda$fMonadFreefYoneda$fMonadTransYoneda$fMonadPlusYoneda$fMonadFixYoneda $fMonadYoneda $fBindYoneda$fAlternativeYoneda $fPlusYoneda $fAltYoneda $fOrdYoneda $fEqYoneda $fOrd1Yoneda $fEq1Yoneda $fReadYoneda $fShowYoneda $fRead1Yoneda $fShow1Yoneda$fDistributiveYoneda$fTraversable1Yoneda$fTraversableYoneda$fFoldable1Yoneda$fFoldableYoneda$fApplicativeYoneda $fApplyYoneda$fFunctorYonedabaseData.Functor.Contravariant ContravariantGHC.Baseid contramap. Data.TuplefstsndControl.CategoryfmapData.Functor.IdentityIdentity<*>pure&invariant-0.6.3-Cv37Bzgy6B5LrjPHhlbJZ7Data.Functor.InvariantinvmapFunctortransformers-0.6.1.0Control.Monad.Trans.Classlift$comonad-5.0.8-AVOTm0Ep2s7CyKccKptU9wControl.Comonad.Trans.ClasslowerMonadliftMControl.ComonadComonad(adjunctions-4.4.2-C5JH3h9Ya6W86pEjNFpyZBData.Functor.Adjunction Adjunction mtl-2.3.1Control.Monad.State.Class MonadStateControl.Monad.Reader.Class MonadReaderreturnon1