Skip to content

Commit 683891a

Browse files
committed
Bump streamly to the latest master
1 parent ebf9470 commit 683891a

File tree

7 files changed

+59
-60
lines changed

7 files changed

+59
-60
lines changed

examples/ControlFlow.hs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Control.Monad.Trans.Maybe (MaybeT (..))
2727
import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE, catchE)
2828
import Control.Monad.Trans.Cont (ContT(..), callCC)
2929
import Streamly.Data.Stream (Stream)
30-
import Streamly.Internal.Data.Stream (CrossStream, mkCross, unCross)
30+
import Streamly.Internal.Data.Stream (Nested(..))
3131

3232
import qualified Streamly.Data.Fold as Fold
3333
import qualified Streamly.Data.Stream as Stream
@@ -40,10 +40,10 @@ import qualified Streamly.Data.Stream as Stream
4040
-- non-determinism.
4141
--
4242
getSequenceMaybeBelow :: 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) ()
7373
getSequenceMaybeAbove = 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) ()
8686
mainMaybeAbove = 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.
9898
getSequenceEitherBelow :: 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

126126
getSequenceEitherAsyncBelow :: 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) ()
162162
getSequenceEitherAbove = 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) ()
175175
mainEitherAbove =
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
--
190190
getSequenceMonadThrow :: (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

207207
mainMonadThrow :: 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 ())
222222
getSequenceContBelow = 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

241241
mainContBelow :: 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 ())
253253
getSequenceContAbove = 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) ()
271271
mainContAbove = do
272272
r <- getSequenceContAbove
273273
case r of
@@ -282,10 +282,10 @@ mainContAbove = do
282282
main :: IO ()
283283
main = 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

examples/DateTimeParser.hs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import qualified Data.Char as Char
1919
import qualified Streamly.Data.Array as Array
2020
import qualified Streamly.Data.Fold as Fold
2121
import qualified Streamly.Data.Parser as Parser
22-
import qualified Streamly.Data.ParserK as ParserK
2322
import qualified Streamly.Data.StreamK as StreamK
2423
import qualified Streamly.Data.Stream as Stream
2524
import qualified Streamly.Internal.Data.Fold as Fold (foldt', satisfy)
@@ -153,19 +152,19 @@ _foldBreakDateTime arr = do
153152
_parseBreakDateTime :: Array Char -> IO Int
154153
_parseBreakDateTime arr = do
155154
let s = StreamK.fromStream $ Stream.fromPure arr
156-
p = ParserK.adaptC . Parser.fromFold
157-
(Right year, s1) <- StreamK.parseBreakChunks (p $ decimal 4) s
158-
(_, s2) <- StreamK.parseBreakChunks (p $ char '-') s1
159-
(Right month, s3) <- StreamK.parseBreakChunks (p $ decimal 2) s2
160-
(_, s4) <- StreamK.parseBreakChunks (p $ char '-') s3
161-
(Right day, s5) <- StreamK.parseBreakChunks (p $ decimal 2) s4
162-
(_, s6) <- StreamK.parseBreakChunks (p $ char 'T') s5
163-
(Right hr, s7) <- StreamK.parseBreakChunks (p $ decimal 2) s6
164-
(_, s8) <- StreamK.parseBreakChunks (p $ char ':') s7
165-
(Right mn, s9) <- StreamK.parseBreakChunks (p $ decimal 2) s8
166-
(_, s10) <- StreamK.parseBreakChunks (p $ char ':') s9
167-
(Right sec, s11) <- StreamK.parseBreakChunks (p $ decimal 2) s10
168-
(_, _) <- StreamK.parseBreakChunks (p $ char 'Z') s11
155+
p = Array.parserK . Parser.fromFold
156+
(Right year, s1) <- Array.parseBreak (p $ decimal 4) s
157+
(_, s2) <- Array.parseBreak (p $ char '-') s1
158+
(Right month, s3) <- Array.parseBreak (p $ decimal 2) s2
159+
(_, s4) <- Array.parseBreak (p $ char '-') s3
160+
(Right day, s5) <- Array.parseBreak (p $ decimal 2) s4
161+
(_, s6) <- Array.parseBreak (p $ char 'T') s5
162+
(Right hr, s7) <- Array.parseBreak (p $ decimal 2) s6
163+
(_, s8) <- Array.parseBreak (p $ char ':') s7
164+
(Right mn, s9) <- Array.parseBreak (p $ decimal 2) s8
165+
(_, s10) <- Array.parseBreak (p $ char ':') s9
166+
(Right sec, s11) <- Array.parseBreak (p $ decimal 2) s10
167+
(_, _) <- Array.parseBreak (p $ char 'Z') s11
169168
return (year + month + day + hr + mn + sec)
170169

171170
-------------------------------------------------------------------------------
@@ -175,12 +174,12 @@ _parseBreakDateTime arr = do
175174
{-# NOINLINE _parseKDateTime #-}
176175
_parseKDateTime :: Array Char -> IO Int
177176
_parseKDateTime arr = do
178-
r <- StreamK.parseChunks dateParser $ StreamK.fromPure arr
177+
r <- Array.parse dateParser $ StreamK.fromPure arr
179178
return $ fromRight (error "failed") r
180179

181180
where
182181

183-
p = ParserK.adaptC
182+
p = Array.parserK
184183

185184
dateParser = do
186185
year <- p $ Parser.decimal <* Parser.char '-'

examples/Intro.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Streamly.Data.Fold (Fold, Tee(..))
1414
import Streamly.Data.Stream.Prelude (Stream)
1515
import Streamly.Data.Unfold (Unfold)
1616
import Streamly.FileSystem.Path (path)
17-
import Streamly.Internal.Data.Stream (CrossStream, mkCross, unCross)
17+
import Streamly.Internal.Data.Stream (Nested(..))
1818

1919
import qualified Streamly.Data.Array as Array
2020
import qualified Streamly.Data.Fold as Fold
@@ -66,11 +66,11 @@ crossProduct range1 range2 =
6666
-- efficient. The second stream may depend on the first stream. The loops
6767
-- cannot fuse completely.
6868
--
69-
nestedLoops :: CrossStream IO ()
69+
nestedLoops :: Nested IO ()
7070
nestedLoops = do
71-
x <- mkCross $ Stream.fromList [3,4 :: Int]
72-
y <- mkCross $ Stream.fromList [1..x]
73-
mkCross $ Stream.fromEffect $ print (x, y)
71+
x <- Nested $ Stream.fromList [3,4 :: Int]
72+
y <- Nested $ Stream.fromList [1..x]
73+
Nested $ Stream.fromEffect $ print (x, y)
7474

7575
-------------------------------------------------------------------------------
7676
-- Text processing
@@ -187,7 +187,7 @@ main = do
187187
print $ runIdentity $ crossProduct (1,1000) (1000,2000)
188188
"nestedLoops" -> do
189189
putStrLn "nestedLoops"
190-
Stream.fold Fold.drain $ unCross nestedLoops
190+
Stream.fold Fold.drain $ unNested nestedLoops
191191
"avgLineLength" -> do
192192
putStrLn "avgLineLength"
193193
avgLineLength >>= print

examples/ListDir.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import qualified Streamly.Internal.FileSystem.DirIO as Dir
4747
(readEitherChunks, readEitherPaths, eitherReaderPaths)
4848
import qualified Streamly.FileSystem.Handle as Handle
4949
import qualified Streamly.FileSystem.Path as Path
50-
import qualified Streamly.Internal.FileSystem.Path as Path (toChunk)
50+
import qualified Streamly.Internal.FileSystem.Path as Path (toArray)
5151
#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
5252
import qualified Streamly.Internal.FileSystem.Posix.ReadDir as Dir
5353
(readEitherByteChunks)
@@ -57,9 +57,9 @@ import qualified Streamly.Internal.FileSystem.Posix.ReadDir as Dir
5757
recReadOpts :: ReadOptions -> ReadOptions
5858
recReadOpts =
5959
DirIO.followSymlinks True
60-
. DirIO.ignoreLoopErrors False
61-
. DirIO.ignoreNonExisting True
62-
. DirIO.ignoreInAccessible True
60+
. DirIO.ignoreSymlinkLoops False
61+
. DirIO.ignoreMissing True
62+
. DirIO.ignoreInaccessible True
6363

6464
#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
6565
-- Fastest implementation, only works for posix as of now.
@@ -112,7 +112,7 @@ listDirChunked :: IO ()
112112
listDirChunked = do
113113
Stream.fold (Handle.writeWith 32000 stdout)
114114
$ Stream.unfoldEachEndBy 10 Array.reader
115-
$ fmap Path.toChunk
115+
$ fmap Path.toArray
116116
$ Stream.unfoldEach Unfold.fromList
117117
$ fmap (either id id)
118118

@@ -154,7 +154,7 @@ listDir :: IO ()
154154
listDir = do
155155
Stream.fold (Handle.writeWith 32000 stdout)
156156
$ Stream.unfoldEachEndBy 10 Array.reader
157-
$ fmap (Path.toChunk . either id id)
157+
$ fmap (Path.toArray . either id id)
158158

159159
-- Serial using unfolds
160160
-- $ Stream.unfoldIterateDfs unfoldDir -- 284 ms

examples/ListDirBasic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import qualified Streamly.Internal.FileSystem.Posix.ReadDir as ReadDir
1010
main :: IO ()
1111
main = do
1212
name <- Path.fromString "."
13-
let arr = Path.toChunk name
13+
let arr = Path.toArray name
1414
buffer <- MutByteArray.new' 1024
1515
ReadDir.openDirStream name
1616
>>= loopDir0 buffer (arrContents arr)

examples/MergeSort.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import qualified Streamly.Data.Fold as Fold
1515
import qualified Streamly.Data.Stream.Prelude as Stream
1616
import qualified Streamly.Data.StreamK as K
1717

18-
import qualified Streamly.Internal.Data.Stream as Stream (reduceIterateBfs)
18+
import qualified Streamly.Internal.Data.Stream as Stream (bfsReduceIterate)
1919

2020
input :: [Int]
2121
input = [1000000,999999..1]
@@ -90,7 +90,7 @@ sortMergeChunks f =
9090
Stream.fromList input
9191
& Array.chunksOf chunkSize
9292
& f sortChunk
93-
& Stream.reduceIterateBfs reduce
93+
& Stream.bfsReduceIterate reduce
9494
& void
9595

9696
-- | Divide a stream in chunks, sort the chunks and merge them.

stack.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ extra-deps:
66
#- streamly-0.10.0
77
#- fusion-plugin-0.2.6
88
- git: https://github.com/composewell/streamly
9-
commit: 64dd83c750e8eb77b0aa28127ccf04010a186b3a
9+
commit: 4aa7ae215f64cf98f7b3c175d3a8c47c8bd3177e
1010
- git: https://github.com/composewell/streamly
11-
commit: 64dd83c750e8eb77b0aa28127ccf04010a186b3a
11+
commit: 4aa7ae215f64cf98f7b3c175d3a8c47c8bd3177e
1212
subdirs:
1313
- core
1414
- git: https://github.com/composewell/streamly-fsevents
15-
commit: 71cc64256464ded84feb6ee592860a820e0a41d0
15+
commit: 7c06c187f0437e6857108c89fe74dc7cc53a0bac
1616

1717
rebuild-ghc-options: true
1818

0 commit comments

Comments
 (0)