{-# LANGUAGE Safe #-}
module Relude.Extra.Bifunctor
( bimapBoth
, bimapF
, firstF
, secondF
) where
import Relude
bimapBoth :: Bifunctor f => (a -> b) -> f a a -> f b b
bimapBoth :: forall (f :: * -> * -> *) a b.
Bifunctor f =>
(a -> b) -> f a a -> f b b
bimapBoth a -> b
f = forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap a -> b
f a -> b
f
{-# INLINE bimapBoth #-}
bimapF :: (Functor f, Bifunctor p) => (a -> c) -> (b -> d) -> f (p a b) -> f (p c d)
bimapF :: forall (f :: * -> *) (p :: * -> * -> *) a c b d.
(Functor f, Bifunctor p) =>
(a -> c) -> (b -> d) -> f (p a b) -> f (p c d)
bimapF a -> c
f b -> d
g = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap a -> c
f b -> d
g)
{-# INLINE bimapF #-}
firstF :: (Functor f, Bifunctor p) => (a -> c) -> f (p a b) -> f (p c b)
firstF :: forall (f :: * -> *) (p :: * -> * -> *) a c b.
(Functor f, Bifunctor p) =>
(a -> c) -> f (p a b) -> f (p c b)
firstF = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first
{-# INLINE firstF #-}
secondF :: (Functor f, Bifunctor p) => (b -> d) -> f (p a b) -> f (p a d)
secondF :: forall (f :: * -> *) (p :: * -> * -> *) b d a.
(Functor f, Bifunctor p) =>
(b -> d) -> f (p a b) -> f (p a d)
secondF = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second
{-# INLINE secondF #-}