Modulebifunctors-5.6.3
Data.Biapplicative
- 2 classes
- 6 values
- Packagebifunctors-5.6.3
- Exports8
- LicenceBSD-3-Clause
- SourceBifunctor.hs
A bifunctor is a type constructor that takes two type arguments and is a functor in both arguments. That is, unlike with Functor, a type constructor such as Either does not need to be partially applied for a Bifunctor instance, and the methods in this class permit mapping functions over the Left value or the Right value, or both at the same time.
Formally, the class Bifunctor represents a bifunctor
from Hask -> Hask.
Intuitively it is a bifunctor where both the first and second arguments are covariant.
The class definition of a Bifunctor p uses the
QuantifiedConstraints
language extension to quantify over the first type
argument a in its context. The context requires that p a
must be a Functor for all a. In other words a partially
applied Bifunctor must be a Functor. This makes Functor a
superclass of Bifunctor such that a function with a
Bifunctor constraint may use fmap in its implementation.
Functor has been a quantified superclass of
Bifunctor since base-4.18.0.0.
You can define a Bifunctor by either defining bimap or by defining both first and second. The second method must agree with fmap:
second ≡ fmapFrom this it follows that:
second id ≡ idIf you supply bimap, you should ensure that:
bimap id id ≡ idIf you supply first and second, ensure:
first id ≡ id
second id ≡ id
If you supply both, you should also ensure:
bimap f g ≡ first f . second gThese ensure by parametricity:
bimap (f . g) (h . i) ≡ bimap f h . bimap g i
first (f . g) ≡ first f . first g
second (f . g) ≡ second f . second g
Methods
Instances21Bifunctor, …
Bifunctor ArgDefined in base-4.23.0.0 · Data.SemigroupBifunctor EitherDefined in base-4.23.0.0 · Data.BifunctorBifunctor Tuple2Defined in base-4.23.0.0 · Data.BifunctorTuple instances have the same laziness as for Functor. Both first id and second id have the same laziness as id (and fmap id):
Example3 expressions first id (errorWithoutStackTrace "error!" :: (Int, Word)) `seq` ()*** Exception: error!second id (errorWithoutStackTrace "error!" :: (Int, Word)) `seq` ()*** Exception: error!id (errorWithoutStackTrace "error!" :: (Int, Word)) `seq` ()*** Exception: error!
Bifunctor ConstDefined in base-4.23.0.0 · Data.BifunctorBifunctor TaggedDefined in tagged-0.8.11 · Data.TaggedBifunctor ConstantDefined in transformers-0.6.3.0 · Data.Functor.ConstantBifunctor (Tuple3 x1)Defined in base-4.23.0.0 · Data.BifunctorBifunctor bi => Bifunctor (Biap bi)Defined in bifunctors-5.6.3 · Data.Bifunctor.BiapBifunctor (K1 i)Defined in base-4.23.0.0 · Data.BifunctorBifunctor (Tuple4 x1 x2)Defined in base-4.23.0.0 · Data.BifunctorBifunctor (Tuple5 x1 x2 x3)Defined in base-4.23.0.0 · Data.BifunctorBifunctor p => Bifunctor (Flip p)Defined in bifunctors-5.6.3 · Data.Bifunctor.FlipBifunctor p => Bifunctor (WrappedBifunctor p)Defined in bifunctors-5.6.3 · Data.Bifunctor.WrappedFunctor f => Bifunctor (Clown f)Defined in bifunctors-5.6.3 · Data.Bifunctor.ClownFunctor g => Bifunctor (Joker g)Defined in bifunctors-5.6.3 · Data.Bifunctor.JokerBifunctor (Tuple6 x1 x2 x3 x4)Defined in base-4.23.0.0 · Data.Bifunctor(Bifunctor f, Bifunctor g) => Bifunctor (Product f g)Defined in bifunctors-5.6.3 · Data.Bifunctor.Product(Bifunctor p, Bifunctor q) => Bifunctor (Sum p q)Defined in bifunctors-5.6.3 · Data.Bifunctor.SumBifunctor (Tuple7 x1 x2 x3 x4 x5)Defined in base-4.23.0.0 · Data.Bifunctor(Functor f, Bifunctor p) => Bifunctor (Tannen f p)Defined in bifunctors-5.6.3 · Data.Bifunctor.Tannen(Bifunctor p, Functor f, Functor g) => Bifunctor (Biff p f g)Defined in bifunctors-5.6.3 · Data.Bifunctor.Biff
Instances17Biapplicative, …
Biapplicative ArgDefined in bifunctors-5.6.3 · Data.BiapplicativeBiapplicative Tuple2Defined in bifunctors-5.6.3 · Data.BiapplicativeBiapplicative ConstDefined in bifunctors-5.6.3 · Data.BiapplicativeBiapplicative TaggedDefined in bifunctors-5.6.3 · Data.BiapplicativeBiapplicative bi => Biapplicative (Biap bi)Defined in bifunctors-5.6.3 · Data.Bifunctor.BiapMonoid x => Biapplicative (Tuple3 x)Defined in bifunctors-5.6.3 · Data.Biapplicative(Monoid x, Monoid y) => Biapplicative (Tuple4 x y)Defined in bifunctors-5.6.3 · Data.BiapplicativeBiapplicative p => Biapplicative (Flip p)Defined in bifunctors-5.6.3 · Data.Bifunctor.FlipBiapplicative p => Biapplicative (WrappedBifunctor p)Defined in bifunctors-5.6.3 · Data.Bifunctor.WrappedApplicative f => Biapplicative (Clown f)Defined in bifunctors-5.6.3 · Data.Bifunctor.ClownApplicative g => Biapplicative (Joker g)Defined in bifunctors-5.6.3 · Data.Bifunctor.Joker(Monoid x, Monoid y, Monoid z) => Biapplicative (Tuple5 x y z)Defined in bifunctors-5.6.3 · Data.Biapplicative(Biapplicative f, Biapplicative g) => Biapplicative (Product f g)Defined in bifunctors-5.6.3 · Data.Bifunctor.Product(Monoid x, Monoid y, Monoid z, Monoid w) => Biapplicative (Tuple6 x y z w)Defined in bifunctors-5.6.3 · Data.Biapplicative(Applicative f, Biapplicative p) => Biapplicative (Tannen f p)Defined in bifunctors-5.6.3 · Data.Bifunctor.Tannen(Monoid x, Monoid y, Monoid z, Monoid w, Monoid v) => Biapplicative (Tuple7 x y z w v)Defined in bifunctors-5.6.3 · Data.Biapplicative(Biapplicative p, Applicative f, Applicative g) => Biapplicative (Biff p f g)Defined in bifunctors-5.6.3 · Data.Bifunctor.Biff