úÎx”sHf      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e portable experimentaldan.doel@gmail.comOA type constructor which takes three arguments and an associated map function.  Informally,  Trifunctor f implies Bifunctor (f a) with bimap = trimap id. MA type constructor which takes two arguments and an associated map function.  Informally,  Bifunctor f implies  Functor (f a) with fmap = bimap id. +Constant functors. Essentially the same as   , except that they also carry a value. The unit functor. (Note: this is not the same as () . In fact,    is the  fixpoint of ().) Functor composition. )(Note: Some compilers will let you write f `O` g rather than O f g; we'&ll be doing so here for readability.) 'Functor composition is associative, so f `O` (g `O` h) and (f `O` g) `O` h are equivalent. The functions  and  convert between the two. '(Operationally, they are equivalent to id". Their only purpose is to affect the type system.)    ;non-portable (rank-2 polymorphism, infix type constructors) experimentaldan.doel@gmail.com portable experimentaldan.doel@gmail.comf  defined in terms of    % with the arguments swapped. Dual to g  for monads. "Injects a value into the comonad. 1Calls a comonadic function in a modified context >Converts a list of comonadic functions into a single function  returning a list of values (There are two ways to define a comonad: I. Provide definitions for f , , and  satisfying these laws:   extract . duplicate == id  fmap extract . duplicate == id 8 duplicate . duplicate == fmap duplicate . duplicate II. Provide definitions for  and   satisfying these laws:   extend extract == id  extract . extend f == f . extend f . extend g == extend (f . extend g) (f 2 cannot be defaulted, but a comonad which defines   may simply set f  equal to .) $A comonad providing definitions for   and , must also satisfy these laws:  ! extend f == fmap f . duplicate  duplicate == extend id % fmap f == extend (f . duplicate) $(The first two are the defaults for   and , #and the third is the definition of .)   portable experimentaldan.doel@gmail.com!Returns the context ";Returns the result of the preceeding operations running in  a modified context #>Returns a list of results created by running prior operations @ in modified contexts created by the list of context-modifiers. $=Lifts an operation into the context comonad. Syntactic sugar for fmap# when chaining comonad operations.  & liftCtx == extract . fmap f  w =>> liftCtx f == fmap f w !"#$%&%&!"#$non-portable (fundeps) experimentaldan.doel@gmail.com'Minimal definitions: 1.  leftAdjunct and  rightAdjunct 2. unit and counit Given functors f and g, Adjunction f g implies  Monad (g `'O'` f) and  (f `'O'` g). '()*+'()*+07An H-branching stream. The specific functor chosen for H determines its behavior:  Strf Id is an infinite stream   Strf Maybe is a non-empty stream  Strf [] is a rose tree ,-./0101,-./+non-portable (rank-2 polymorphism, fundeps) experimentaldan.doel@gmail.com2Deconstructor for > 3A generalized map, known formally as a  hylomorphism and written [| f, g |].   refold f g == 4 f . 5 g 4A generalized foldr, known formally as a  catmorphism and written (| f |).   fold f == 3 f E  fold f == : (Id . fmap unId ) (f . fmap unId) 5A generalized unfoldr, known formally as an  anamorphism and written [( f )].   unfold f == 3 D f  unfold f == = (fmap Id . unId) (fmap Id . f) 6 A variant of 4 where the function f! also receives the result of the +inner recursive calls. Formally known as a  paramorphism and written <| f |>. Dual to ;.    para == 8 D  para f == 3 f (fmap (id &&& id) . E)  para f == f . fmap (id &&& para f) . E #Example: Computing the factorials.   fact :: Integer -> Integer  fact = para g  where  g Nothing = 1 " g (Just (n,f)) = f * (n + 1)  For the base case 0!, g is passed Nothing . (Note that D Nothing == 0.)  For subsequent cases (n+1)!, g is passed n and n!.  (Note that D (Just n) == n + 1.) Point-free version: 0fact = para $ maybe 1 (uncurry (*) . first (+1)).  Example:  dropWhile  ( dropWhile :: (a -> Bool) -> [a] -> [a]  dropWhile p = para f  where  f Nil = [] 8 f (Pair x xs) = if p x then snd xs else x : fst xs Point-free version: L dropWhile p = para $ cons [] (\x xs -> if p x then snd xs else x : fst xs) 7AImplements course-of-value recursion. At each step, the function  receives an F-branching stream (0) containing the previous values. Formally known as a  histomorphism and written {| f |}.    histo == 9 id &Example: Computing Fibonacci numbers.   fibo :: Integer -> Integer  fibo = histo next  where 3 next :: Maybe (Strf Maybe Integer) -> Integer 2 next Nothing = 0 2 next (Just (Consf _ Nothing)) = 1 6 next (Just (Consf m (Just (Consf n _)))) = m + n  For the base case F(0), next is passed Nothing and returns 0.  (Note that D Nothing == 0)  For F(1), next0 is passed a one-element stream, and returns 1.  For subsequent cases F(n), next is passed a the stream [F(n-1), F(n-2), ..., F(0)] and returns F(n-1)+F(n-2). 8A generalization of 6 implementing " semi-mutual" recursion. Known formally as a  zygomorphism and written <| f |> ^g, where g is an auxiliary function. Dual to <.   zygo g == : (g . fmap fst &&& fmap snd) 9 Generalizes 7. to cases where the recursion functor and the (stream functor are distinct. Known as a g-histomorphism.   g_histo g == : (. (fmap , ) (g . fmap -)) : Generalizes 4, 8, and 9. Formally known as a g-catamorphism !and written (| f |)^(w,k), where w is a  and k is a distributive law between n and the functor f. The behavior of foldWith is determined by the comonad w.  Id recovers 4  ((,) a) recovers 8 (and 6)  0 recovers 9 (and 7) ; apomorphisms , dual to 6    apo == < E  apo f == D . fmap (id ||| apo f) . f *Example: Appending a list to another list  append :: [a] -> [a] -> [a]  append = curry (apo f)  where 9 f :: ([a],[a]) -> ConsPair a (Either [a] ([a],[a]))  f ([], []) = Nil % f ([], y:ys) = Pair y (Left ys) + f (x:xs, ys) = Pair x (Right (xs,ys)) <"generalized apomorphisms, dual to 8   g_apo g == = (fmap Left . g ||| fmap Right) =;generalized anamorphisms parameterized by a monad, dual to :  Id recovers 5   (Either a) recovers < (and ;) >Fixpoint of lists A%Creates a fixpoint for any functor. D formally, in[f] : f -> mu f E formally, in^-1[f] : mu f -> f 23456789:;<=>?@ABCDE46879:5;<=3CDEAB>?@2 FGHIJKLMNO OFGHIJKLMN PQRSTUVWX WXPQRSTUV YZ[\]^_`abcde eYZ[\]^_`abdch  !"#$%%&'()*+,-.//0123456789:;<=>?@ABCDEFGHIJKLMNOPQ;RSTUVW P Q ; R X Y T Z [ \ ] ^ _ ` a b c d e f g h i jkcategory-extras-0.1Control.FunctorControl.Functor.TransformControl.ComonadControl.Comonad.ContextControl.Functor.AdjunctionData.BranchingStreamControl.Recursion Data.StreamData.InfiniteSeqData.InfiniteTreebaseGHC.BaselComprComp Trifunctortrimap BifunctorbimapConstunConstUnitOCompdeComp transFunc funcTrans.>:>liftW=>>.>>localmapW parallelWunfoldW sequenceW CoKleisli unCoKleisliComonadextract duplicateextendgetmodify experimentliftCtxContext Adjunction leftAdjunct rightAdjunctunitcounithdftlfgenStrf strfToListStrfConsfconsrefoldfoldunfoldparahistozygog_histofoldWithapog_apo unfoldWithConsPairPairNilFixInFixpointinFoutFmkStreamheadtailelemAttoSeqtoList mapStreamStfibsStreamdroptoStreamSeqNatmkTreerootleftrightbranchFsurrealsshowTree showTreeWide showTree'showWiderotateLrotateRTreefmap>>=