C      !"#$%&'()*+,-./012345678 9 : ; < = > ? @ A B (C) 2011-2015 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 C 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  D D  f g "a  (E . f) (E . g) F  f g z t "a G ( (Endo . f) (Endo . g) t) z 4Combines the elements of a structure using a monoid.  "a  D DUCombines the elements of a structure, given ways of mapping them to a common monoid.  f g "a  (E . f) (E . g) FcCombines 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 H (I 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 J (acc -> I# (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. KLMNOPQRST   KLMNOPQRST(C) 2008-2015 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:  D D "a DIf you supply  and  , ensure:  D "a D  D "a D +If you supply both, you should also ensure:  f g "a  f U  gThese ensure by parametricity:  (f U g) (h U i) "a  f h U  g i  (f U g) "a  f U  g  (f U g) "a  f U  g )Map over both arguments at the same time.  f g "a  f U  g(Map covariantly over the first argument.  f "a  f D)Map covariantly over the second argument.  "a  DVWXYZ[\]^_ VWXYZ[\]^_(C) 2011 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred `right-to-left state transformeraleft-to-right state transformer#Minimal complete definition either  or ._ identifies bifunctorial data structures whose elements can be traversed in order, performing b or cQ 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 . d ( g1 g2) .  f1 f2 "a traverse (Compose . d g1 . f1) (Compose . d 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 . d  .  where an applicative transformation is a function t :: (b f, b g) => f a -> g apreserving the b operations: t (e x) = e x t (f f x) = t f 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 C 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 y3 relates to its superclasses in the following ways:  f g "a  runIdentity .  (Identity . f) (Identity . g)  f g = g .  (h . f) (h . g) These are available as ! and " 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 gySequences all the actions in a structure, building a new structure with the same shape using the results of the actions.  "a  D DAs , but uses evidence that m is a c rather than an b.  f g "a  .  f g  f g "a i .  (j . f) (j . g) As , but uses evidence that m is a c rather than an b.  "a  D D  "a i .  .  j j  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.!A default definition of  in terms of the  operations."A default definition of  in terms of the  operations.$klm`noapq !"rstuvwxyz{|}~  !"  !"klm`noapq !"rstuvwxyz{|}~(C) 2011-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred& a  b "a  D  a f b ' a  b "a   a <.> b *Lift binary functions+Lift ternary functions#$%&'()*+ #$%&'()*+ #$%&'()*+#$%&'()*+%&'()(C) 2008-2015 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-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred/Make a  over the first argument of a . /01/01/01/01(C) 2008-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred2Make a  flipping the arguments of a . 234234234234(C) 2008-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisional non-portable Safe-Inferred*35Make a  over both arguments of a .567567567567 (C) 2008-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred8Make a  over the second argument of a . 89:89:89:89: )(C) 2008-2015 Jesse Selover, Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred;"Form the product of two bifunctors;<;<;<;< (C) 2008-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred= Compose a  on the outside of a . =>?=>?=>?=>? (C) 2008-2015 Edward Kmett BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> provisionalportable Safe-Inferred@Make a  over the second argument of a . @AB@AB@AB@AB !"#$%&'() *+,-./01234567899:;;<==>??@ A A B C D E E F G H IJKLJMNJOPJOQJORJMSJKTJUVWXYZ[\]^_`JMabcdefghijklmJnoJMpJMqJnrJnsJntJnuJnvJnwxxylzm{|}~JnJMJJnJM bifunctors-5Data.BifoldableData.BifunctorData.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 Bifunctorbimapfirstsecond BitraversablebiforbiforM bimapAccumL bimapAccumR bimapDefaultbifoldMapDefault Biapplicativebipure<<*>>*>><<*<<$>><<**>>biliftA2biliftA3BiffrunBiffClownrunClownFliprunFlipJoinrunJoinJokerrunJokerProductPairTannen runTannenWrappedBifunctor WrapBifunctorunwrapBifunctorbase Data.EitherEitherGHC.Baseid Data.MonoidmappendmemptyappEndofoldreitherGHC.Listfoldl$fBifoldableEither$fBifoldableTagged$fBifoldable(,,,,,,)$fBifoldable(,,,,,)$fBifoldable(,,,,)$fBifoldable(,,,)$fBifoldable(,,)$fBifoldableConst$fBifoldable(,)$fBifoldableArg.$fBifunctorTagged$fBifunctorConst$fBifunctorEither$fBifunctor(,,,,,,)$fBifunctor(,,,,,)$fBifunctor(,,,,)$fBifunctor(,,,)$fBifunctor(,,)$fBifunctorArg$fBifunctor(,)StateRStateLControl.Applicative ApplicativeMonadfmappure<*>getConstConst unwrapMonad WrapMonadIdgetId runStateR runStateL$fApplicativeId $fFunctorId$fApplicativeStateR$fFunctorStateR$fApplicativeStateL$fFunctorStateL$fBitraversableTagged$fBitraversableConst$fBitraversableEither$fBitraversable(,,,,,,)$fBitraversable(,,,,,)$fBitraversable(,,,,)$fBitraversable(,,,)$fBitraversable(,,)$fBitraversable(,)$fBitraversableArg*>const Data.Functor<$><*$fBiapplicativeConst$fBiapplicativeTagged$fBiapplicative(,,,,,,)$fBiapplicative(,,,,,)$fBiapplicative(,,,,)$fBiapplicative(,,,)$fBiapplicative(,,)$fBiapplicativeArg$fBiapplicative(,)Functor$fBitraversableBiff$fTraversableBiff$fBifoldableBiff$fFoldableBiff$fBiapplicativeBiff $fFunctorBiff$fBifunctorBiff$fTraversableClown$fBitraversableClown$fFoldableClown$fBifoldableClown$fBiapplicativeClown$fFunctorClown$fBifunctorClown$fTraversableFlip$fBitraversableFlip$fFoldableFlip$fBifoldableFlip$fBiapplicativeFlip $fFunctorFlip$fBifunctorFlip$fTraversableJoin$fFoldableJoin$fApplicativeJoin $fFunctorJoin$fTraversableJoker$fBitraversableJoker$fFoldableJoker$fBifoldableJoker$fBiapplicativeJoker$fFunctorJoker$fBifunctorJoker$fBitraversableProduct$fBifoldableProduct$fBiapplicativeProduct$fBifunctorProduct$fBitraversableTannen$fTraversableTannen$fBifoldableTannen$fFoldableTannen$fBiapplicativeTannen$fFunctorTannen$fBifunctorTannen$fBitraversableWrappedBifunctor$fTraversableWrappedBifunctor$fBifoldableWrappedBifunctor$fFoldableWrappedBifunctor$fBiapplicativeWrappedBifunctor$fFunctorWrappedBifunctor$fBifunctorWrappedBifunctor