śĪiļ_„Y      !"#$%&'()*+,-./0123456789:;<=>?@ABCD E F G H I J K L M N O P Q R S T U V W X  Safe-Inferred~We often need to distinguish between various forms of Functor-like composition in Haskell in order to please the type system. 9 This lets us work with these representations uniformly. YYportable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred  portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy The   Z s of a given   ComonadApply is to Comonad like  Applicative is to Monad. JMathematically, it is a strong lax symmetric semi-monoidal comonad on the  category Hask' of Haskell types. That it to say that w is a strong lax O symmetric semi-monoidal functor on Hask, where both extract and duplicate are - symmetric monoidal natural transformations. Laws:  ) (.) <$> u <@> v <@> w = u <@> (v <@> w) + extract (p <@> q) = extract p (extract q) = duplicate (p <@> q) = (<@>) <$> duplicate p <@> duplicate q FIf our type is both a ComonadApply and Applicative we further require   (<*>) = (<@>) "Finally, if you choose to define () and (), the results of your . definitions should match the following laws:  a @> b = const id <$> a <@> b  a <@ b = const <$> a <@> b (There are two ways to define a comonad: I. Provide definitions for  and  satisfying these laws:   extend extract = id  extract . extend f = f - extend f . extend g = extend (f . extend g) !In this case, you may simply set  = . 9These laws are directly analogous to the laws for monads @and perhaps can be made clearer by viewing them as laws stating Dthat Cokleisli composition must be associative, and has extract for a unit:   f =>= extract = f  extract =>= f = f # (f =>= g) =>= h = f =>= (g =>= h) ;II. Alternately, you may choose to provide definitions for , , and  satisfying these laws:   extract . duplicate = id  fmap extract . duplicate = id 7 duplicate . duplicate = fmap duplicate . duplicate 7In this case you may not rely on the ability to define  in  terms of . )You may of course, choose to define both  and . /In that case you must also satisfy these laws:   extend f = fmap f . duplicate  duplicate = extend id " fmap f = extend (f . extract) %These are the default definitions of  and  and the definition of  respectively.   extract . fmap f = f . extract   duplicate = extend id 0 fmap (fmap f) . duplicate = duplicate . fmap f   extend f = fmap f . duplicate "A suitable default definition for  for a . # Promotes a function to a comonad. ) fmap f = liftW f = extend (f . extract) $Comonadic fixed point ą la Menendez #Comonadic fixed point ą la Orchard % with the arguments swapped. Dual to [ for a \.  in operator form $Right-to-left Cokleisli composition $Left-to-right Cokleisli composition  A variant of  with the arguments reversed. 3Lift a binary function into a comonad with zipping 4Lift a ternary function into a comonad with zipping CReplace the contents of a functor uniformly with a constant value. - ]^_`abcdefghijklmnopqrs   %  ]^_`abcdefghijklmnopqrsportable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy !t ! ! !tportable provisionalEdward Kmett <ekmett@gmail.com> Safe-Inferred#$Given any comonad-homomorphism from w to v this yields a comonad  homomorphism from t w to t v. "#u"#"#"#uportable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy'/Create an Env using an environment and a value */Gets rid of the environment. This differs from  in that it will A not continue extracting the value from the contained comonad. +Retrieves the environment. ,Like +4, but modifies the resulting value with a function.  asks = f . ask -7Modifies the environment using the specified function. $%&vwx'()*+,-yz{|}~€‚ $%&'()*+,- &'($%)*+,-$%&vwx'()*+,-yz{|}~€‚ Trustworthy1=Create a Store using an accessor function and a stored value 4Read the stored value pos $ store fst (1,5)(1,5)5Set the stored value  $ pos . seek (3,7) $ store fst (1,5)  (3,7) Seek satisfies the law  seek s = peek s . duplicate 7EPeek at what the current focus would be for a different stored value Peek satisfies the law # peek x . extend (peek y) = peek y 8@Peek at what the current focus would be if the stored value was  modified by some function 9IApplies 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./0ƒ123456789„…†‡ˆ‰Š‹ ./0123456789 012./3456789./0ƒ123456789„…†‡ˆ‰Š‹portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy:;<=>?@ABCŒŽ‘’“” :;<=>?@ABC =>?:;<@ABC:;<=>?@ABCŒŽ‘’“” non-portable (fundeps, MPTCs) experimentalEdward Kmett <ekmett@gmail.com> Trustworthy DEF•–—˜™šDEFDEFDEF•–—˜™š non-portable (fundeps, MPTCs) experimentalEdward Kmett <ekmett@gmail.com> Trustworthy&  !$%&'()-DEF DEF-&'($%)non-portable (fundeps, MPTCs) experimentalEdward Kmett <ekmett@gmail.com> Trustworthy  ›œ  non-portable (fundeps, MPTCs) experimentalEdward Kmett <ekmett@gmail.com> TrustworthyGHIJKLMNOžŸ ”¢ GHIJKLMNO GHIJKLMNOGHIJKLMNOžŸ ”¢non-portable (fundeps, MPTCs) experimentalEdward Kmett <ekmett@gmail.com> Trustworthy)  !./0123GHIJKLM GHIJKLM012./3 non-portable (fundeps, MPTCs) experimentalEdward Kmett <ekmett@gmail.com> TrustworthyPQR£¤„¦§PQRPQRPQR£¤„¦§non-portable (fundeps, MPTCs) experimentalEdward Kmett <ekmett@gmail.com> TrustworthyBØ©Ŗ«¬­®Æ°±²³“µ¶·ø¹ŗ»¼½¾æĄĮĀĆÄ  !:;<=>?PQR PQR=>?:;< portable provisionalEdward Kmett <ekmett@gmail.com> Trustworthy STUVWXÅĘĒČÉSTUVWXSTUVWX STUVWXÅĘĒČÉŹ !"#$%&'()*+,-./01234567889:;<=>?@AABCDEFGHIJKLLMNOPQRST U > ? V F I J G H K W X Y Q Z [ [ \ ] ^ _`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œ  ž Ÿ   ” ¢£¤£„£„ ¦ § Ø © Ŗ « ¬ ­ ® Æ°±°²°³°“°µ°¶°·°·°ø°¹°¹°ŗ°»°»°¼°½°½°¾°æ°æ°Ą°Į°Į°Ā°Ć°Ć°Ä°Å°Å Ę Ē Č É ŹĖ comonad-4.0Control.ComonadData.Functor.CompositionControl.Comonad.Trans.IdentityControl.Comonad.Trans.ClassControl.Comonad.Hoist.ClassControl.Comonad.Trans.EnvControl.Comonad.Trans.StoreControl.Comonad.Trans.TracedControl.Comonad.Env.ClassControl.Comonad.Store.ClassControl.Comonad.Traced.ClassData.Functor.CoproductControl.Comonad.EnvControl.Comonad.IdentityControl.Comonad.StoreControl.Comonad.TracedbaseGHC.BasefmapFunctor Data.Functor<$><$ Composition decomposecomposetransformers-0.3.0.0Control.Monad.Trans.Identity runIdentityT IdentityT Cokleisli runCokleisli ComonadApply<@>@><@Comonadextract duplicateextendliftWwfixcfix=>><<==<==>=<@@>liftW2liftW3$> ComonadTranslower ComonadHoistcohoistEnvTEnvenvrunEnvrunEnvT lowerEnvTaskaskslocalStoreTStorestorerunStore runStoreTposseekseekspeekpeeks experimentTracedT runTracedTTracedtraced runTracedtracelistenlistenscensor ComonadEnv ComonadStorelowerPos lowerPeek ComonadTracedtraces Coproduct getCoproductleftright coproduct$fCompositionCompose Control.ArrowArrow>>=MonadcokleisliTyCon$fMonadCokleisli$fApplicativeCokleisli$fFunctorCokleisli$fArrowLoopCokleisli$fArrowChoiceCokleisli$fArrowApplyCokleisli$fArrowCokleisli$fCategoryCokleisli$fTypeable2Cokleisli$fComonadApplyTree$fComonadApplyIdentityT$fComonadApplyIdentity$fComonadApply(->)$fComonadApplyNonEmpty$fComonadApply(,)$fComonadNonEmpty $fComonadTree$fComonadIdentityT$fComonadTagged$fComonadIdentity $fComonad(->) $fComonad(,)$fComonadTransIdentityT$fComonadHoistIdentityT envTTyCon envTConstr envTDataType$fTraversableEnvT$fFoldableEnvT$fComonadApplyEnvT$fComonadHoistEnvT$fComonadTransEnvT $fComonadEnvT $fFunctorEnvT $fDataEnvT$fTypeableEnvT$fTypeable1EnvT storeTTyCon$fComonadHoistStoreT$fComonadTransStoreT$fComonadStoreT$fApplicativeStoreT$fComonadApplyStoreT$fFunctorStoreT$fTypeableStoreT$fTypeable1StoreT tracedTTyCon$fTypeable1TracedT$fDistributiveTracedT$fComonadHoistTracedT$fComonadTransTracedT$fComonadTracedT$fApplicativeTracedT$fComonadApplyTracedT$fFunctorTracedTlowerAsk$fComonadEnveTracedT$fComonadEnveIdentityT$fComonadEnveStoreT$fComonadEnve(,)$fComonadEnveEnvTData.Functor.Identity runIdentityIdentitylowerExperiment$fComonadStoresTracedT$fComonadStoresEnvT$fComonadStoresIdentityT$fComonadStoresStoreT lowerTrace$fComonadTracedmStoreT$fComonadTracedmEnvT$fComonadTracedmIdentityT$fComonadTracedmTracedT Data.Monoid<>mconcatmappendmemptyMonoidgetDualDualappEndoEndogetAllAllgetAnyAnygetSumSum getProductProductgetFirstFirstgetLastLast$fContravariantCoproduct$fComonadCoproduct$fTraversableCoproduct$fFoldableCoproduct$fFunctorCoproduct