@@ -164,6 +164,7 @@ module Streamly.Internal.Data.Stream.IsStream.Transform
164164 -- Move these to Streamly.Data.Either.Stream?
165165 , lefts
166166 , rights
167+ , both
167168
168169 -- * Concurrent Evaluation
169170 -- ** Concurrent Pipelines
@@ -1509,6 +1510,15 @@ lefts = fmap (fromLeft undefined) . filter isLeft
15091510rights :: (IsStream t, Monad m, Functor (t m)) => t m (Either a b) -> t m b
15101511rights = fmap (fromRight undefined) . filter isRight
15111512
1513+-- | Remove the either wrapper and flatten both lefts and as well as rights in
1514+-- the output stream.
1515+--
1516+-- /Pre-release/
1517+--
1518+{-# INLINE both #-}
1519+both :: Functor (t m) => t m (Either a a) -> t m a
1520+both = fmap (either id id)
1521+
15121522------------------------------------------------------------------------------
15131523-- Concurrent Application
15141524------------------------------------------------------------------------------