3 ms·
Not OP but they meant https://hackage.haskell.org/package/base-4.16.1.0/docs/Data-Bifunctor.html#v:bimap https://hackage.haskell.org/package/base-4.16.1.0/docs/
by pwm 4y ago
Not OP but they meant https://hackage.haskell.org/package/base-4.16.1.0/docs/Data-Bifunctor.html#v:bimap https://hackage.haskell.org/package/base-4.16.1.0/docs/Data-...
As you have the normal map function for Functors (using Haskell):
> :t fmap
fmap :: Functor f => (a -> b) -> f a -> f b
you can have bimap for Bifunctors:
> :t bimap
bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d
which specialised to pairs is:
> :t bimap @(,)
bimap @(,) :: (a -> b) -> (c -> d) -> (a, c) -> (b, d)