vlT      !"#$%&'()*+,-./0123456789:;<=>?@ABCDE F G H I J K L M N O P Q R S SafeWe often need to distinguish between various forms of Functor-like composition in Haskell in order to please the type system. This lets us work with these representations uniformly. T   T(C) 2008-2011 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableSafeB(C) 2008-2015 Edward Kmett, (C) 2004 Dave Menendez BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableSafe*+1 The   U s of a given  ComonadApply is to Comonad like  Applicative is to Monad.TMathematically, it is a strong lax symmetric semi-monoidal comonad on the category Hask' of Haskell types. That it to say that wF is a strong lax symmetric semi-monoidal functor on Hask, where both  and 1 are symmetric monoidal natural transformations.Laws: (V)  u  v  w = u  (v  w)  (p  q) =  p ( q)  (p  q) = ()   p   q If our type is both a  and W we further require (X) = () "Finally, if you choose to define () and (D), the results of your definitions should match the following laws: a  b = Y Z  a  b a  b = Y  a  b 'There are two ways to define a comonad:I. Provide definitions for  and  satisfying these laws:   = Z  .  f = f  f .  g =  (f .  g) !In this case, you may simply set  = .These laws are directly analogous to the laws for monads and perhaps can be made clearer by viewing them as laws stating that Cokleisli composition must be associative, and has extract for a unit: f   = f   f = f (f  g)  h = f  (g  h) ;II. Alternately, you may choose to provide definitions for , , and  satisfying these laws:  .  = Z   .  = Z  .  =   .  7In this case you may not rely on the ability to define  in terms of .)You may of course, choose to define both  and 0. In that case you must also satisfy these laws:  f =  f .   =  id  f =  (f . ) %These are the default definitions of  and  and the definition of  respectively.  .  f = f .    =  Z  ( f) .  =  .  f   f =  f .  "A suitable default definition for  for a $. Promotes a function to a comonad."You can only safely use to define  if your  defined  , not just , since defining  in terms of duplicate uses !  f =  f =  (f . ) )Comonadic fixed point la David Menendez*Comonadic fixed point la Dominic Orchard)Comonadic fixed point la Kenneth Foner: This is the evaluate function from his  +https://www.youtube.com/watch?v=F7F-BzOB670!"Getting a Quick Fix on Comonads" talk.% with the arguments swapped. Dual to [ for a \. in operator formRight-to-left   compositionLeft-to-right   composition A variant of  with the arguments reversed.Lift a binary function into a  with zipping Lift a ternary function into a  with zipping. ] ^_`abcdefghijklmnopqrst   &  ] ^_`abcdefghijklmnopqrst(C) 2008-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableSafe!"u!"!"!"u(C) 2008-2013 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableSafeIN$$Given any comonad-homomorphism from w to v* this yields a comonad homomorphism from t w to t v.#$v#$#$#$v(C) 2008-2013 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableSafe*+4(.Create an Env using an environment and a value+/Gets rid of the environment. This differs from Q in that it will not continue extracting the value from the contained comonad.,Retrieves the environment.-Like ,3, but modifies the resulting value with a function. asks = f . ask.6Modifies the environment using the specified function.%&'wx()*+,-.yz{|}~ %&'()*+,-. '()%&*+,-.%&'wx()*+,-.yz{|}~(C) 2008-2013 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableSafe*+2<Create a Store using an accessor function and a stored value5Read the stored valuepos $ store fst (1,5)(1,5)6Set the stored value"pos . seek (3,7) $ store fst (1,5)(3,7)Seek satisfies the law seek s = peek s . duplicate7Modify the stored value"pos . seeks swap $ store fst (1,5)(5,1)Seeks satisfies the law seeks f = peeks f . duplicate8DPeek at what the current focus would be for a different stored valuePeek satisfies the law !peek x . extend (peek y) = peek y9\Peek at what the current focus would be if the stored value was modified by some function:uApplies a functor-valued function to the stored value, and then uses the new accessor to read the resulting focus./let f x = if x > 0 then Just (x^2) else Nothingexperiment f $ store (+1) 2Just 5experiment f $ store (+1) (-2)Nothing/0123456789: /0123456789: 123/0456789:/0123456789:(C) 2008-2014 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportableSafe*+;<=>?@ABCD ;<=>?@ABCD >?@;<=ABCD;<=>?@ABCD (C) 2008-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalnon-portable (fundeps, MPTCs)Safe3579 EFGEFGEFG EFG (C) 2008-2014 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalnon-portable (fundeps, MPTCs)Safe'  !"%&'()*.EFG EFG.'()%&* (C) 2008-2014 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalnon-portable (fundeps, MPTCs)Safe!  (C) 2008-2012 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalnon-portable (fundeps, MPTCs)Safe3579HIJKLMNOP HIJKLMNOP HIJKLMNOPHIJKLMNOP(C) 2008-2014 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalnon-portable (fundeps, MPTCs)Safe*  !"/01234HIJKLMN HIJKLMN123/04 (C) 2008-2012 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalnon-portable (fundeps, MPTCs)Safe3579 QRSQRSQRSQRS(C) 2008-2014 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimentalnon-portable (fundeps, MPTCs)SafeF  !";<=>?@QRS QRS>?@;<= !"#$%&'()*+,-./01234567889:;<=>?@AABCDEFGHIJKLLMNOPQRST U > ? V F I J G H K W X Y Q Z[\]^_`ab^cdefghijklmnopqrstuvwxyz{|}~  comon_1PIxYseaeOfJZ5jLKWaHfVControl.ComonadControl.Comonad.Trans.IdentityData.Functor.CompositionControl.Comonad.Trans.ClassControl.Comonad.Hoist.ClassControl.Comonad.Trans.EnvControl.Comonad.Trans.StoreControl.Comonad.Trans.TracedControl.Comonad.Env.ClassControl.Comonad.Store.ClassControl.Comonad.Traced.ClassControl.Comonad.EnvControl.Comonad.IdentityControl.Comonad.StoreControl.Comonad.TracedbaseGHC.BasefmapFunctor Data.Functor$><$><$trans_GZTjP9K5WFq01xC9BAGQpFControl.Monad.Trans.Identity runIdentityT IdentityT Composition decomposecompose Cokleisli runCokleisli ComonadApply<@>@><@Comonadextract duplicateextendliftWwfixcfixkfix=>><<==<==>=<@@>liftW2liftW3 ComonadTranslower ComonadHoistcohoistEnvTEnvenvrunEnvrunEnvT lowerEnvTaskaskslocalStoreTStorestorerunStore runStoreTposseekseekspeekpeeks experimentTracedT runTracedTTracedtraced runTracedtracelistenlistenscensor ComonadEnv ComonadStorelowerPos lowerPeek ComonadTracedtraces$fCompositionCompose Control.ArrowArrowControl.Category. Applicative<*>constid>>=Monad coproduct$fMonadCokleisli$fApplicativeCokleisli$fFunctorCokleisli$fArrowLoopCokleisli$fArrowChoiceCokleisli$fArrowApplyCokleisli$fArrowCokleisli$fCategory*Cokleisli$fComonadApplyTree$fComonadApplyIdentityT$fComonadApplyIdentity$fComonadApply(->)$fComonadApplyNonEmpty$fComonadApply(,) $fComonadSum$fComonadNonEmpty $fComonadTree$fComonadIdentityT$fComonadTagged$fComonadIdentity $fComonad(->) $fComonadArg $fComonad(,)$fComonadTransIdentityT$fComonadHoistIdentityT envTConstr envTDataType$fTraversableEnvT$fFoldableEnvT$fComonadApplyEnvT$fComonadHoistEnvT$fApplicativeEnvT$fComonadTransEnvT $fComonadEnvT $fFunctorEnvT $fDataEnvT$fComonadHoistStoreT$fComonadTransStoreT$fComonadStoreT$fApplicativeStoreT$fComonadApplyStoreT$fFunctorStoreT$fDistributiveTracedT$fComonadHoistTracedT$fComonadTransTracedT$fComonadTracedT$fApplicativeTracedT$fComonadApplyTracedT$fFunctorTracedTlowerAsk$fComonadEnveTracedT$fComonadEnveIdentityT$fComonadEnveStoreT$fComonadEnveArg$fComonadEnve(,)$fComonadEnveEnvTData.Functor.Identity runIdentityIdentitylowerExperiment$fComonadStoresTracedT$fComonadStoresEnvT$fComonadStoresIdentityT$fComonadStoresStoreT lowerTrace$fComonadTracedmStoreT$fComonadTracedmEnvT$fComonadTracedmIdentityT$fComonadTracedm(->)$fComonadTracedmTracedT Data.Monoid<>getDualDualappEndoEndogetAllAllgetAnyAnygetSumSum getProductProductgetFirstFirstgetLastLastgetAltAltmconcatmappendmemptyMonoid