dU      !"#$%&'()*+,-./0123456789:;<=>?@A B C D E F G H I J K L M N OPQRST(C) 2011 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredMinimal definition either  or _ identifies foldable structures with two different varieties of elements. Common examples are U and '(,)': instance Bifoldable Either where bifoldMap f _ (Left a) = f a bifoldMap _ g (Right b) = g b instance Bifoldable (,) where bifoldr f g z (a, b) = f a (g b z)nWhen defining more than the minimal set of definitions, one should ensure that the following identities hold:  "a  V V  f g "a  (W . f) (W . g) X  f g z t "a Y ( (Endo . f) (Endo . g) t) z 4Combines the elements of a structure using a monoid.  "a  V VUCombines the elements of a structure, given ways of mapping them to a common monoid.  f g "a  (W . f) (W . g) XcCombines the elements of a structure in a right associative manner. Given a hypothetical function %toEitherList :: p a b -> [Either a b]T yielding a list of all elements of a structure in order, the following would hold:  f g z "a Z ([ f g) z . toEitherListaCombines the elments of a structure in a left associative manner. Given a hypothetical function %toEitherList :: p a b -> [Either a b]T yielding a list of all elements of a structure in order, the following would hold:  f g z "a \ (acc -> [# (f acc) (g acc)) z . toEitherListAs D, but strict in the result of the reduction functions at each step.2Right associative monadic bifold over a structure.As D, but strict in the result of the reductionf unctions at each step.1Left associative monadic bifold over a structure. As M, but ignores the results of the functions, merely performing the "actions". As  1, but with the structure as the primary argument. As N, but ignores the results of the functions, merely performing the "actions". As  1, but with the structure as the primary argument. As ), but ignores the results of the actions.As ), but ignores the results of the actions.6Collects the list of elements of a structure in order.AReduces a structure of lists to the concatenation of those lists.vGiven a means of mapping the elements of a structure to lists, computes the concatenation of all such lists in order.UDetermines whether any element of the structure satisfies the appropriate predicate.TDetermines whether all elements of the structure satisfy the appropriate predicate. ]^_`abc   ]^_`abc(C) 2011 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredFUsable default for foldMap, but only if you define bifoldMap1 yourselfdefghijklmnopdefghijklmnop(C) 2008-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredMinimal definition either  or  and Formally, the class  represents a bifunctor from Hask -> Hask.VIntuitively it is a bifunctor where both the first and second arguments are covariant.You can define a  by either defining  or by defining both  and .If you supply , you should ensure that:  V V "a VIf you supply  and  , ensure:  V "a V  V "a V +If you supply both, you should also ensure:  f g "a  f q  gThese ensure by parametricity:  (f q g) (h q i) "a  f h q  g i  (f q g) "a  f q  g  (f q g) "a  f q  g )Map over both arguments at the same time.  f g "a  f q  g(Map covariantly over the first argument.  f "a  f V)Map covariantly over the second argument.  "a  V rstuvwxrstuvwx(C) 2011 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred! a .> b "a y V z a <.> b " a <. b "a y z a <.> b %Lift binary functions&Lift ternary functions !"#$%&{|}~  !"#$%& !"#$%&  !"#$%&{|}~ !"#$(C) 2011 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred right-to-left state transformerleft-to-right state transformer'#Minimal complete definition either ( or ).'_ identifies bifunctorial data structures whose elements can be traversed in order, performing  or Q actions at each element, and collecting a result structure with the same shape.A definition of traverse! must satisfy the following laws:  naturality( (t . f) (t . g) "a t . ( f g) for every applicative transformation tidentity( Identity Identity "a Identity compositionCompose .  (( g1 g2) . ( f1 f2 "a traverse (Compose .  g1 . f1) (Compose .  g2 . f2)A definition of )! must satisfy the following laws:  naturality) .  t t "a t . )) for every applicative transformation tidentity) .  Identity Identity "a Identity composition) .  Compose Compose "a Compose .  ) . ) where an applicative transformation is a function t :: ( f,  g) => f a -> g apreserving the  operations: t ( x) =  x t (f  x) = t f  t x and the identity functor Identity and composition functors Compose are defined as newtype Identity a = Identity { runIdentity :: a } instance Functor Identity where fmap f (Identity x) = Identity (f x) instance Applicative Identity where pure = Identity Identity f <*> Identity x = Identity (f x) newtype Compose f g a = Compose (f (g a)) instance (Functor f, Functor g) => Functor (Compose f g) where fmap f (Compose x) = Compose (fmap (fmap f) x) instance (Applicative f, Applicative g) => Applicative (Compose f g) where pure = Compose . pure . pure Compose f <*> Compose x = Compose ((<*>) <$> f <*> x)Some simple examples are U and '(,)': instance Bitraversable Either where bitraverse f _ (Left x) = Left <$> f x bitraverse _ g (Right y) = Right <$> g y instance Bitraversable (,) where bitraverse f g (x, y) = (,) <$> f x <*> g y'3 relates to its superclasses in the following ways:  f g "a  runIdentity . ( (Identity . f) (Identity . g)  f g =  . ( ( . f) ( . g) These are available as 0 and 1 respectively.(Evaluates the relevant functions at each element in the structure, running the action, and builds a new structure with the same shape, using the elements produced from sequencing the actions. ( f g "a ) .  f g)ySequences all the actions in a structure, building a new structure with the same shape using the results of the actions. ) "a ( V V*As (, but uses evidence that m is a  rather than an . * f g "a + .  f g * f g "a  . ( ( . f) ( . g) +As ), but uses evidence that m is a  rather than an . + "a * V V + "a  . ) .    ,, is (* with the structure as the first argument.-- is ** with the structure as the first argument..DTraverses a structure from left to right, threading a state of type aH and using the given actions to compute new elements for the structure./DTraverses a structure from right to left, threading a state of type aH and using the given actions to compute new elements for the structure.0A default definition of  in terms of the ' operations.1A default definition of  in terms of the ' operations.!'()*+,-./01 '()*+,-./01 '()*+,-./01'()*+,-./01(C) 2011 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred 234523452345 2345(C) 2011-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred9 a  b "a y V z a  b : a  b "a y z a <.> b <Lift binary functions=Lift ternary functions6789:;<= #6789:;<= 6789:#;<= 6789:;<=89:;(C) 2008-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred> Compose two s on the inside of a . >?@>?@>?@ >?@ (C) 2008-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredAMake a  over the first argument of a . ABCABCABC ABC (C) 2008-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredDMake a  over the first argument of a . DEFDEFDEF DEF (C) 2008-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Safe-Inferred*3GMake a  over both arguments of a . GHIGHIGHIGHI (C) 2008-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredJMake a  over the second argument of a .JKLJKLJKL JKL (C) 2008-2013 Jesse Selover, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredM"Form the product of two bifunctorsMNMNMNMN(C) 2008-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredO Compose a  on the outside of a . OPQOPQOPQ OPQ(C) 2008-2013 Edward Kmett, BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-InferredRMake a  over the second argument of a . RSTRSTRST RST !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNNO P P Q R R S T T U V V W X YZZ[\]^_`a_bc_de_df_dg_bh_`i_jklmnopqrsstuvwxyz{|}~_b_b___b_b_________b bifunctors-4.2Data.BifoldableData.Semigroup.BifoldableData.BifunctorData.Bifunctor.ApplyData.BitraversableData.Semigroup.BitraversableData.BiapplicativeData.Bifunctor.BiffData.Bifunctor.ClownData.Bifunctor.FlipData.Bifunctor.JoinData.Bifunctor.JokerData.Bifunctor.ProductData.Bifunctor.TannenData.Bifunctor.Wrapped bitraversebimapM bisequenceA bisequence Bifoldablebifold bifoldMapbifoldrbifoldlbifoldr'bifoldrMbifoldl'bifoldlM bitraverse_bifor_bimapM_biforM_ bisequenceA_ bisequence_biListbiconcat biconcatMapbianybiall Bifoldable1bifold1 bifoldMap1 bitraverse1_bifor1_ bisequenceA1_bifoldMapDefault1 BifunctorbimapfirstsecondBiapply<<.>>.>><<.<<$>><<..>>bilift2bilift3 BitraversablebiforbiforM bimapAccumL bimapAccumR bimapDefaultbifoldMapDefaultBitraversable1 bitraverse1 bisequence1bifoldMap1Default Biapplicativebipure<<*>>*>><<*<<**>>biliftA2biliftA3BiffrunBiffClownrunClownFliprunFlipJoinrunJoinJokerrunJokerProductPairTannen runTannenWrappedBifunctor WrapBifunctorunwrapBifunctorbase Data.EitherEitherGHC.Baseid Data.MonoidmappendmemptyappEndofoldreitherGHC.Listfoldl$fBifoldableEither$fBifoldableTagged$fBifoldable(,,,,)$fBifoldable(,,,)$fBifoldable(,,)$fBifoldableConst$fBifoldable(,)ActgetActignore $fFunctorAct$fSemigroupAct$fBifoldable1Tagged$fBifoldable1Const$fBifoldable1(,,,,)$fBifoldable1(,,,)$fBifoldable1(,,)$fBifoldable1(,)$fBifoldable1Either.$fBifunctorTagged$fBifunctorConst$fBifunctorEither$fBifunctor(,,,,)$fBifunctor(,,,)$fBifunctor(,,)$fBifunctor(,)const Data.Functor<$>$fBiapplyTagged$fBiapplyConst$fBiapply(,,,,)$fBiapply(,,,) $fBiapply(,,) $fBiapply(,)StateRStateLControl.Applicative ApplicativeMonadfmappure<*>getConstConst unwrapMonad WrapMonadIdgetId runStateR runStateL$fApplicativeId $fFunctorId$fApplicativeStateR$fFunctorStateR$fApplicativeStateL$fFunctorStateL$fBitraversableTagged$fBitraversableConst$fBitraversableEither$fBitraversable(,,,,)$fBitraversable(,,,)$fBitraversable(,,)$fBitraversable(,)$fBitraversable1Tagged$fBitraversable1Const$fBitraversable1(,,,,)$fBitraversable1(,,,)$fBitraversable1(,,)$fBitraversable1(,)$fBitraversable1Either*><*$fBiapplicativeConst$fBiapplicativeTagged$fBiapplicative(,,,,)$fBiapplicative(,,,)$fBiapplicative(,,)$fBiapplicative(,)Functor$fBitraversable1Biff$fBifoldable1Biff$fBitraversableBiff$fTraversableBiff$fBifoldableBiff$fFoldableBiff$fBiapplicativeBiff $fBiapplyBiff $fFunctorBiff$fBifunctorBiff$fBitraversable1Clown$fBifoldable1Clown$fTraversableClown$fBitraversableClown$fFoldableClown$fBifoldableClown$fBiapplyClown$fBiapplicativeClown$fFunctorClown$fBifunctorClown$fBitraversable1Flip$fBifoldable1Flip$fTraversableFlip$fBitraversableFlip$fFoldableFlip$fBifoldableFlip $fBiapplyFlip$fBiapplicativeFlip $fFunctorFlip$fBifunctorFlip$fTraversable1Join$fFoldable1Join$fTraversableJoin$fFoldableJoin $fApplyJoin$fApplicativeJoin $fFunctorJoin$fTraversable1Joker$fBitraversable1Joker$fFoldable1Joker$fBifoldable1Joker$fTraversableJoker$fBitraversableJoker$fFoldableJoker$fBifoldableJoker$fBiapplyJoker$fBiapplicativeJoker$fFunctorJoker$fBifunctorJoker$fBitraversable1Product$fBifoldable1Product$fBitraversableProduct$fBifoldableProduct$fBiapplicativeProduct$fBifunctorProduct$fBitraversable1Tannen$fBifoldable1Tannen$fBitraversableTannen$fTraversableTannen$fBifoldableTannen$fFoldableTannen$fBiapplicativeTannen$fBiapplyTannen$fFunctorTannen$fBifunctorTannen $fBitraversable1WrappedBifunctor$fBifoldable1WrappedBifunctor$fBitraversableWrappedBifunctor$fTraversableWrappedBifunctor$fBifoldableWrappedBifunctor$fFoldableWrappedBifunctor$fBiapplicativeWrappedBifunctor$fBiapplyWrappedBifunctor$fFunctorWrappedBifunctor$fBifunctorWrappedBifunctor