{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Safe #-}
module Data.Bifoldable1 where
import Control.Applicative (Const (..))
import Data.Bifoldable (Bifoldable (..))
import Data.Semigroup (Arg (..), Semigroup (..))
import Prelude (Either (..), id)
class Bifoldable t => Bifoldable1 t where
bifold1 :: Semigroup m => t m m -> m
bifold1 = (m -> m) -> (m -> m) -> t m m -> m
forall m a b. Semigroup m => (a -> m) -> (b -> m) -> t a b -> m
forall (t :: * -> * -> *) m a b.
(Bifoldable1 t, Semigroup m) =>
(a -> m) -> (b -> m) -> t a b -> m
bifoldMap1 m -> m
forall a. a -> a
id m -> m
forall a. a -> a
id
{-# INLINE bifold1 #-}
bifoldMap1 :: Semigroup m => (a -> m) -> (b -> m) -> t a b -> m
instance Bifoldable1 Arg where
bifoldMap1 :: forall m a b. Semigroup m => (a -> m) -> (b -> m) -> Arg a b -> m
bifoldMap1 a -> m
f b -> m
g (Arg a
a b
b) = a -> m
f a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> b -> m
g b
b
instance Bifoldable1 Either where
bifoldMap1 :: forall m a b.
Semigroup m =>
(a -> m) -> (b -> m) -> Either a b -> m
bifoldMap1 a -> m
f b -> m
_ (Left a
a) = a -> m
f a
a
bifoldMap1 a -> m
_ b -> m
g (Right b
b) = b -> m
g b
b
{-# INLINE bifoldMap1 #-}
instance Bifoldable1 (,) where
bifoldMap1 :: forall m a b. Semigroup m => (a -> m) -> (b -> m) -> (a, b) -> m
bifoldMap1 a -> m
f b -> m
g (a
a, b
b) = a -> m
f a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> b -> m
g b
b
{-# INLINE bifoldMap1 #-}
instance Bifoldable1 ((,,) x) where
bifoldMap1 :: forall m a b. Semigroup m => (a -> m) -> (b -> m) -> (x, a, b) -> m
bifoldMap1 a -> m
f b -> m
g (x
_,a
a,b
b) = a -> m
f a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> b -> m
g b
b
{-# INLINE bifoldMap1 #-}
instance Bifoldable1 ((,,,) x y) where
bifoldMap1 :: forall m a b.
Semigroup m =>
(a -> m) -> (b -> m) -> (x, y, a, b) -> m
bifoldMap1 a -> m
f b -> m
g (x
_,y
_,a
a,b
b) = a -> m
f a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> b -> m
g b
b
{-# INLINE bifoldMap1 #-}
instance Bifoldable1 ((,,,,) x y z) where
bifoldMap1 :: forall m a b.
Semigroup m =>
(a -> m) -> (b -> m) -> (x, y, z, a, b) -> m
bifoldMap1 a -> m
f b -> m
g (x
_,y
_,z
_,a
a,b
b) = a -> m
f a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> b -> m
g b
b
{-# INLINE bifoldMap1 #-}
instance Bifoldable1 Const where
bifoldMap1 :: forall m a b. Semigroup m => (a -> m) -> (b -> m) -> Const a b -> m
bifoldMap1 a -> m
f b -> m
_ (Const a
a) = a -> m
f a
a
{-# INLINE bifoldMap1 #-}