papa-0.4.0: src/Papa/Bifunctors/Data/Bifoldable.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}
module Papa.Bifunctors.Data.Bifoldable (
biconcat,
biconcatMap,
) where
import Data.Bifoldable (Bifoldable (bifold, bifoldMap))
import Data.Monoid (Monoid)
{-# INLINE biconcat #-}
-- | Fold a bifunctor containing monoids.
--
-- >>> biconcat ([1,2], [3,4])
-- [1,2,3,4]
-- >>> biconcat ("hello", " world")
-- "hello world"
biconcat ::
(Bifoldable p, Monoid m) =>
p m m ->
m
biconcat =
bifold
{-# INLINE biconcatMap #-}
-- | Map each side of a bifunctor to a monoid and combine.
--
-- >>> biconcatMap (\x -> [x]) (\x -> [x]) (1, 2)
-- [1,2]
biconcatMap ::
(Bifoldable p, Monoid m) =>
(a -> m) ->
(b -> m) ->
p a b ->
m
biconcatMap =
bifoldMap