@@ -27,7 +27,7 @@ import Control.Monad.Trans.Maybe (MaybeT (..))
2727import Control.Monad.Trans.Except (ExceptT , runExceptT , throwE , catchE )
2828import Control.Monad.Trans.Cont (ContT (.. ), callCC )
2929import Streamly.Data.Stream (Stream )
30- import Streamly.Internal.Data.Stream (CrossStream , mkCross , unCross )
30+ import Streamly.Internal.Data.Stream (Nested ( .. ) )
3131
3232import qualified Streamly.Data.Fold as Fold
3333import qualified Streamly.Data.Stream as Stream
@@ -40,10 +40,10 @@ import qualified Streamly.Data.Stream as Stream
4040-- non-determinism.
4141--
4242getSequenceMaybeBelow :: MonadIO m => Stream (MaybeT m ) ()
43- getSequenceMaybeBelow = unCross $ do
43+ getSequenceMaybeBelow = unNested $ do
4444 liftIO $ putStrLn " MaybeT below streamly: Enter one char per line: "
4545
46- i <- mkCross $ Stream. fromList [1 .. 2 :: Int ]
46+ i <- Nested $ Stream. fromList [1 .. 2 :: Int ]
4747 liftIO $ putStrLn $ " iteration = " <> show i
4848
4949 r1 <- liftIO getLine
@@ -69,11 +69,11 @@ mainMaybeBelow = do
6969-- Note that this is redundant configuration as the same behavior can be
7070-- achieved with just streamly, using mzero.
7171--
72- getSequenceMaybeAbove :: MonadIO m => MaybeT (CrossStream m ) ()
72+ getSequenceMaybeAbove :: MonadIO m => MaybeT (Nested m ) ()
7373getSequenceMaybeAbove = do
7474 liftIO $ putStrLn " MaybeT above streamly: Enter one char per line: "
7575
76- i <- lift $ mkCross $ Stream. fromList [1 .. 2 :: Int ]
76+ i <- lift $ Nested $ Stream. fromList [1 .. 2 :: Int ]
7777 liftIO $ putStrLn $ " iteration = " <> show i
7878
7979 r1 <- liftIO getLine
@@ -82,7 +82,7 @@ getSequenceMaybeAbove = do
8282 r2 <- liftIO getLine
8383 when (r2 /= " y" ) mzero
8484
85- mainMaybeAbove :: MonadIO m => MaybeT (CrossStream m ) ()
85+ mainMaybeAbove :: MonadIO m => MaybeT (Nested m ) ()
8686mainMaybeAbove = do
8787 getSequenceMaybeAbove
8888 liftIO $ putStrLn " Bingo"
@@ -96,10 +96,10 @@ mainMaybeAbove = do
9696-- Note that throwE would terminate all iterations of non-determinism
9797-- altogether.
9898getSequenceEitherBelow :: MonadIO m => Stream (ExceptT String m ) ()
99- getSequenceEitherBelow = unCross $ do
99+ getSequenceEitherBelow = unNested $ do
100100 liftIO $ putStrLn " ExceptT below streamly: Enter one char per line: "
101101
102- i <- mkCross $ Stream. fromList [1 .. 2 :: Int ]
102+ i <- Nested $ Stream. fromList [1 .. 2 :: Int ]
103103 liftIO $ putStrLn $ " iteration = " <> show i
104104
105105 r1 <- liftIO getLine
@@ -124,10 +124,10 @@ mainEitherBelow = do
124124--
125125
126126getSequenceEitherAsyncBelow :: MonadIO m => Stream (ExceptT String m ) ()
127- getSequenceEitherAsyncBelow = unCross $ do
127+ getSequenceEitherAsyncBelow = unNested $ do
128128 liftIO $ putStrLn " ExceptT below concurrent streamly: "
129129
130- i <- mkCross
130+ i <- Nested
131131 $ Stream. consM
132132 (liftIO (threadDelay 1000 )
133133 >> throwE " First task"
@@ -158,11 +158,11 @@ mainEitherAsyncBelow = do
158158--
159159-- Here we can use catchE directly but will have to use monad-control to lift
160160-- stream operations with stream arguments.
161- getSequenceEitherAbove :: MonadIO m => ExceptT String (CrossStream m ) ()
161+ getSequenceEitherAbove :: MonadIO m => ExceptT String (Nested m ) ()
162162getSequenceEitherAbove = do
163163 liftIO $ putStrLn " ExceptT above streamly: Enter one char per line: "
164164
165- i <- lift $ mkCross $ Stream. fromList [1 .. 2 :: Int ]
165+ i <- lift $ Nested $ Stream. fromList [1 .. 2 :: Int ]
166166 liftIO $ putStrLn $ " iteration = " <> show i
167167
168168 r1 <- liftIO getLine
@@ -171,7 +171,7 @@ getSequenceEitherAbove = do
171171 r2 <- liftIO getLine
172172 when (r2 /= " y" ) $ throwE $ " Expecting y got: " <> r2
173173
174- mainEitherAbove :: MonadIO m => ExceptT String (CrossStream m ) ()
174+ mainEitherAbove :: MonadIO m => ExceptT String (Nested m ) ()
175175mainEitherAbove =
176176 catchE (getSequenceEitherAbove >> liftIO (putStrLn " Bingo" ))
177177 (liftIO . putStrLn )
@@ -188,20 +188,20 @@ instance Exception Unexpected
188188-- iterations of non-determinism rather then just the current iteration.
189189--
190190getSequenceMonadThrow :: (MonadIO m , MonadThrow m ) => Stream m ()
191- getSequenceMonadThrow = unCross $ do
191+ getSequenceMonadThrow = unNested $ do
192192 liftIO $ putStrLn " MonadThrow in streamly: Enter one char per line: "
193193
194- i <- mkCross $ Stream. fromList [1 .. 2 :: Int ]
194+ i <- Nested $ Stream. fromList [1 .. 2 :: Int ]
195195 liftIO $ putStrLn $ " iteration = " <> show i
196196
197197 r1 <- liftIO getLine
198198 when (r1 /= " x" )
199- $ mkCross
199+ $ Nested
200200 $ Stream. fromEffect $ throwM $ Unexpected $ " Expecting x got: " <> r1
201201
202202 r2 <- liftIO getLine
203203 when (r2 /= " y" )
204- $ mkCross
204+ $ Nested
205205 $ Stream. fromEffect $ throwM $ Unexpected $ " Expecting y got: " <> r2
206206
207207mainMonadThrow :: IO ()
@@ -218,11 +218,11 @@ mainMonadThrow =
218218--
219219-- XXX need to have a specialized liftCallCC to actually lift callCC
220220--
221- getSequenceContBelow :: MonadIO m => CrossStream (ContT r m ) (Either String () )
221+ getSequenceContBelow :: MonadIO m => Nested (ContT r m ) (Either String () )
222222getSequenceContBelow = do
223223 liftIO $ putStrLn " ContT below streamly: Enter one char per line: "
224224
225- i <- mkCross $ Stream. fromList [1 .. 2 :: Int ]
225+ i <- Nested $ Stream. fromList [1 .. 2 :: Int ]
226226 liftIO $ putStrLn $ " iteration = " <> show i
227227
228228 r <- lift $ callCC $ \ exit -> do
@@ -239,7 +239,7 @@ getSequenceContBelow = do
239239 return r
240240
241241mainContBelow :: MonadIO m => Stream (ContT r m ) ()
242- mainContBelow = unCross $ do
242+ mainContBelow = unNested $ do
243243 r <- getSequenceContBelow
244244 case r of
245245 Right _ -> liftIO $ putStrLn " Bingo"
@@ -249,11 +249,11 @@ mainContBelow = unCross $ do
249249-- Using ContT above streamly
250250-------------------------------------------------------------------------------
251251--
252- getSequenceContAbove :: MonadIO m => ContT r (CrossStream m ) (Either String () )
252+ getSequenceContAbove :: MonadIO m => ContT r (Nested m ) (Either String () )
253253getSequenceContAbove = do
254254 liftIO $ putStrLn " ContT above streamly: Enter one char per line: "
255255
256- i <- lift $ mkCross $ Stream. fromList [1 .. 2 :: Int ]
256+ i <- lift $ Nested $ Stream. fromList [1 .. 2 :: Int ]
257257 liftIO $ putStrLn $ " iteration = " <> show i
258258
259259 callCC $ \ exit -> do
@@ -267,7 +267,7 @@ getSequenceContAbove = do
267267 then exit $ Left $ " Expecting y got: " <> r2
268268 else return $ Right ()
269269
270- mainContAbove :: MonadIO m => ContT r (CrossStream m ) ()
270+ mainContAbove :: MonadIO m => ContT r (Nested m ) ()
271271mainContAbove = do
272272 r <- getSequenceContAbove
273273 case r of
@@ -282,10 +282,10 @@ mainContAbove = do
282282main :: IO ()
283283main = do
284284 mainMaybeBelow
285- Stream. fold Fold. drain $ unCross $ runMaybeT mainMaybeAbove
285+ Stream. fold Fold. drain $ unNested $ runMaybeT mainMaybeAbove
286286 runContT (Stream. fold Fold. drain mainContBelow) return
287- Stream. fold Fold. drain $ unCross $ runContT mainContAbove return
287+ Stream. fold Fold. drain $ unNested $ runContT mainContAbove return
288288 mainEitherBelow
289- Stream. fold Fold. drain $ unCross $ runExceptT mainEitherAbove
289+ Stream. fold Fold. drain $ unNested $ runExceptT mainEitherAbove
290290 mainMonadThrow
291291 mainEitherAsyncBelow
0 commit comments