File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ module Streaming.Prelude (
7070 , repeat
7171 , repeatM
7272 , replicate
73+ , untilLeft
7374 , untilRight
7475 , cycle
7576 , replicateM
@@ -2140,6 +2141,18 @@ unfoldr step = loop where
21402141 Right (a,s) -> return (Step (a :> loop s)))
21412142{-# INLINABLE unfoldr #-}
21422143
2144+ -- ---------------------------------------
2145+ -- untilLeft
2146+ -- ---------------------------------------
2147+ untilLeft :: Monad m => m (Either r a ) -> Stream (Of a ) m r
2148+ untilLeft act = Effect loop where
2149+ loop = do
2150+ e <- act
2151+ case e of
2152+ Right a -> return (Step (a :> Effect loop))
2153+ Left r -> return (Return r)
2154+ {-# INLINABLE untilLeft #-}
2155+
21432156-- ---------------------------------------
21442157-- untilRight
21452158-- ---------------------------------------
You can’t perform that action at this time.
0 commit comments