papa-0.4.0: src/Papa/Semigroupoids/Data/Functor/Bind.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}
module Papa.Semigroupoids.Data.Functor.Bind (
concat,
concatMap,
) where
import Data.Functor.Bind (Bind (join), (-<<))
{-# INLINE concat #-}
-- | Flatten a nested structure.
--
-- >>> concat [[1,2], [3,4], [5,6]]
-- [1,2,3,4,5,6]
-- >>> import Data.Maybe (Maybe(..))
-- >>> concat (Just (Just 5))
-- Just 5
concat ::
(Bind f) =>
f (f a) ->
f a
concat =
join
{-# INLINE concatMap #-}
-- | Map a function over a structure and flatten.
--
-- >>> concatMap (\x -> [x, x]) [1,2,3]
-- [1,1,2,2,3,3]
concatMap ::
(Bind f) =>
(a -> f b) ->
f a ->
f b
concatMap =
(-<<)