on master help sign in
Add a "both" utility function for either streams.
2f5925bHarendra Kumar
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+10
@@ -164,6 +164,7 @@ module Streamly.Internal.Data.Stream.IsStream.Transform
164 -- Move these to Streamly.Data.Either.Stream?
164 -- Move these to Streamly.Data.Either.Stream?
165 , lefts
165 , lefts
166 , rights
166 , rights
167+ , both
167
168
168 -- * Concurrent Evaluation
169 -- * Concurrent Evaluation
169 -- ** Concurrent Pipelines
170 -- ** Concurrent Pipelines
@@ -1509,6 +1510,15 @@ lefts = fmap (fromLeft undefined) . filter isLeft
1509rights :: (IsStream t, Monad m, Functor (t m)) => t m (Either a b) -> t m b
1510rights :: (IsStream t, Monad m, Functor (t m)) => t m (Either a b) -> t m b
1510rights = fmap (fromRight undefined) . filter isRight
1511rights = fmap (fromRight undefined) . filter isRight
1511
1512
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+
1512------------------------------------------------------------------------------
1522------------------------------------------------------------------------------
1513-- Concurrent Application
1523-- Concurrent Application
1514------------------------------------------------------------------------------
1524------------------------------------------------------------------------------