mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Add a "both" utility function for either streams.
This commit is contained in:
parent
064ac664c5
commit
2f5925b421
@ -164,6 +164,7 @@ module Streamly.Internal.Data.Stream.IsStream.Transform
|
||||
-- Move these to Streamly.Data.Either.Stream?
|
||||
, lefts
|
||||
, rights
|
||||
, both
|
||||
|
||||
-- * Concurrent Evaluation
|
||||
-- ** Concurrent Pipelines
|
||||
@ -1509,6 +1510,15 @@ lefts = fmap (fromLeft undefined) . filter isLeft
|
||||
rights :: (IsStream t, Monad m, Functor (t m)) => t m (Either a b) -> t m b
|
||||
rights = fmap (fromRight undefined) . filter isRight
|
||||
|
||||
-- | Remove the either wrapper and flatten both lefts and as well as rights in
|
||||
-- the output stream.
|
||||
--
|
||||
-- /Pre-release/
|
||||
--
|
||||
{-# INLINE both #-}
|
||||
both :: Functor (t m) => t m (Either a a) -> t m a
|
||||
both = fmap (either id id)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Concurrent Application
|
||||
------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user