bifunctors
bifunctors copied to clipboard
Functor (Foldable..) instances to Bifunctors (Bifoldable..) like Product
For the change of adding a superclass to Bifunctor
, and later to Bifoldable
and Bitraversable
- https://github.com/haskell/core-libraries-committee/issues/91
- https://github.com/haskell/core-libraries-committee/issues/93
we need Functor
instances of Data.Bifunctor.Product
and others. I tried it out and it seems enough to do deriving stock Functor
.
Functor (WrappedBifunctor p a)
can probably be reduced to a forall a. Functor (p a)
constraint as well since second = fmap
.
instance Bifunctor p => Functor (WrappedBifunctor p a) where
fmap f = WrapBifunctor . second f . unwrapBifunctor
For the change of adding a superclass to
Bifunctor
, and later toBifoldable
andBitraversable
we needFunctor
instances ofData.Bifunctor.Product
and others. I tried it out and it seems enough to doderiving stock Functor
.
That change was already done on the main branch, which contains the unreleased major version 6 of bifunctors https://github.com/ekmett/bifunctors/blob/4f1535a2c94788c9e6d9accfca8c58ef497628c5/src/Data/Bifunctor/Product.hs#L43
The Functor
instance of WrappedBifunctor
currently looks like this:
https://github.com/ekmett/bifunctors/blob/4f1535a2c94788c9e6d9accfca8c58ef497628c5/src/Data/Bifunctor/Wrapped.hs#L107