@@ -15,7 +15,7 @@ module Main
1515 ) where
1616
1717import Control.DeepSeq (NFData(..))
18−import Control.Monad.Catch (MonadCatch, try, SomeException)
18+import Control.Monad.Catch (MonadCatch, MonadThrow, try, SomeException)
1919import Data.Foldable (asum)
2020import Data.Functor (($>))
2121import Data.Maybe (fromMaybe)
@@ -112,7 +112,7 @@ benchIOSink value name f =
112112-------------------------------------------------------------------------------
113113
114114{-# INLINE one #-}
115−one :: MonadCatch m => Int -> Stream m Int -> m (Maybe Int)
115+one :: MonadThrow m => Int -> Stream m Int -> m (Maybe Int)
116116one value = Stream.parse p
117117
118118 where
@@ -124,25 +124,25 @@ one value = Stream.parse p
124124 Nothing -> pure Nothing
125125
126126{-# INLINE takeBetween #-}
127−takeBetween :: MonadCatch m => Int -> Stream m a -> m ()
127+takeBetween :: MonadThrow m => Int -> Stream m a -> m ()
128128takeBetween value = Stream.parse (PR.takeBetween 0 value Fold.drain)
129129
130130{-# INLINE takeEQ #-}
131−takeEQ :: MonadCatch m => Int -> Stream m a -> m ()
131+takeEQ :: MonadThrow m => Int -> Stream m a -> m ()
132132takeEQ value = Stream.parse (PR.takeEQ value Fold.drain)
133133
134134{-# INLINE dropWhile #-}
135−dropWhile :: MonadCatch m => Int -> Stream m Int -> m ()
135+dropWhile :: MonadThrow m => Int -> Stream m Int -> m ()
136136dropWhile value = Stream.parse (PR.dropWhile (<= value))
137137
138138{-# INLINE takeStartBy #-}
139−takeStartBy :: MonadCatch m => Int -> Stream m Int -> m ()
139+takeStartBy :: MonadThrow m => Int -> Stream m Int -> m ()
140140takeStartBy value stream = do
141141 stream1 <- return . fromMaybe (Stream.fromPure (value + 1)) =<< IsStream.tail stream
142142 let stream2 = value `Stream.cons` stream1
143143 Stream.parse (PR.takeStartBy (== value) Fold.drain) stream2
144144
145−takeFramedByEsc_ :: MonadCatch m => Int -> Stream m Char -> m ()
145+takeFramedByEsc_ :: MonadThrow m => Int -> Stream m Char -> m ()
146146takeFramedByEsc_ _ = Stream.parse parser
147147
148148 where
@@ -154,37 +154,37 @@ takeFramedByEsc_ _ = Stream.parse parser
154154 parser = PR.takeFramedByEsc_ isEsc isBegin isEnd Fold.drain
155155
156156{-# INLINE takeWhile #-}
157−takeWhile :: MonadCatch m => Int -> Stream m Int -> m ()
157+takeWhile :: MonadThrow m => Int -> Stream m Int -> m ()
158158takeWhile value = Stream.parse (PR.takeWhile (<= value) Fold.drain)
159159
160−takeWhileP :: MonadCatch m => Int -> Stream m Int -> m ()
160+takeWhileP :: MonadThrow m => Int -> Stream m Int -> m ()
161161takeWhileP value =
162162 Stream.parse (PR.takeWhileP (<= value) (PR.takeWhile (<= value - 1) Fold.drain))
163163
164164{-# INLINE takeP #-}
165−takeP :: MonadCatch m => Int -> Stream m a -> m ()
165+takeP :: MonadThrow m => Int -> Stream m a -> m ()
166166takeP value = Stream.parse (PR.takeP value (PR.fromFold Fold.drain))
167167
168168{-# INLINE groupBy #-}
169−groupBy :: MonadCatch m => Stream m Int -> m ()
169+groupBy :: MonadThrow m => Stream m Int -> m ()
170170groupBy = Stream.parse (PR.groupBy (<=) Fold.drain)
171171
172172{-# INLINE groupByRolling #-}
173−groupByRolling :: MonadCatch m => Stream m Int -> m ()
173+groupByRolling :: MonadThrow m => Stream m Int -> m ()
174174groupByRolling = Stream.parse (PR.groupByRolling (<=) Fold.drain)
175175
176176{-# INLINE wordBy #-}
177−wordBy :: MonadCatch m => Int -> Stream m Int -> m ()
177+wordBy :: MonadThrow m => Int -> Stream m Int -> m ()
178178wordBy value = Stream.parse (PR.wordBy (>= value) Fold.drain)
179179
180180{-# INLINE sepByWords #-}
181−sepByWords :: MonadCatch m => Int -> Stream m Int -> m ()
181+sepByWords :: MonadThrow m => Int -> Stream m Int -> m ()
182182sepByWords _ = Stream.parse (wrds even Fold.drain)
183183 where
184184 wrds p f = PR.sepBy f (PR.takeWhile (not . p) Fold.drain) (PR.dropWhile p)
185185
186186{-# INLINE deintercalate #-}
187−deintercalate :: MonadCatch m => Int -> Stream m Int -> m ()
187+deintercalate :: MonadThrow m => Int -> Stream m Int -> m ()
188188deintercalate _ = Stream.parse (partition even)
189189
190190 where
@@ -194,36 +194,36 @@ deintercalate _ = Stream.parse (partition even)
194194 Fold.drain (PR.takeWhile (not . p) Fold.sum) (PR.takeWhile p Fold.sum)
195195
196196{-# INLINE manyWordByEven #-}
197−manyWordByEven :: MonadCatch m => Stream m Int -> m ()
197+manyWordByEven :: MonadThrow m => Stream m Int -> m ()
198198manyWordByEven = Stream.parse (PR.many (PR.wordBy even Fold.drain) Fold.drain)
199199
200200{-# INLINE many #-}
201−many :: MonadCatch m => Stream m Int -> m Int
201+many :: MonadThrow m => Stream m Int -> m Int
202202many = Stream.parse (PR.many (PR.satisfy (> 0)) Fold.length)
203203
204204{-# INLINE manyAlt #-}
205−manyAlt :: MonadCatch m => Stream m Int -> m Int
205+manyAlt :: MonadThrow m => Stream m Int -> m Int
206206manyAlt xs = do
207207 x <- Stream.parse (AP.many (PR.satisfy (> 0))) xs
208208 return $ Prelude.length x
209209
210210{-# INLINE some #-}
211−some :: MonadCatch m => Stream m Int -> m Int
211+some :: MonadThrow m => Stream m Int -> m Int
212212some = Stream.parse (PR.some (PR.satisfy (> 0)) Fold.length)
213213
214214{-# INLINE someAlt #-}
215−someAlt :: MonadCatch m => Stream m Int -> m Int
215+someAlt :: MonadThrow m => Stream m Int -> m Int
216216someAlt xs = do
217217 x <- Stream.parse (AP.some (PR.satisfy (> 0))) xs
218218 return $ Prelude.length x
219219
220220{-# INLINE manyTill #-}
221−manyTill :: MonadCatch m => Int -> Stream m Int -> m Int
221+manyTill :: MonadThrow m => Int -> Stream m Int -> m Int
222222manyTill value =
223223 Stream.parse (PR.manyTill (PR.satisfy (> 0)) (PR.satisfy (== value)) Fold.length)
224224
225225{-# INLINE splitAp #-}
226−splitAp :: MonadCatch m
226+splitAp :: MonadThrow m
227227 => Int -> Stream m Int -> m ((), ())
228228splitAp value =
229229 Stream.parse
@@ -233,7 +233,7 @@ splitAp value =
233233 )
234234
235235{-# INLINE splitApBefore #-}
236−splitApBefore :: MonadCatch m
236+splitApBefore :: MonadThrow m
237237 => Int -> Stream m Int -> m ()
238238splitApBefore value =
239239 Stream.parse
@@ -242,7 +242,7 @@ splitApBefore value =
242242 )
243243
244244{-# INLINE splitApAfter #-}
245−splitApAfter :: MonadCatch m
245+splitApAfter :: MonadThrow m
246246 => Int -> Stream m Int -> m ()
247247splitApAfter value =
248248 Stream.parse
@@ -251,7 +251,7 @@ splitApAfter value =
251251 )
252252
253253{-# INLINE serialWith #-}
254−serialWith :: MonadCatch m
254+serialWith :: MonadThrow m
255255 => Int -> Stream m Int -> m ((), ())
256256serialWith value =
257257 Stream.parse
@@ -261,7 +261,7 @@ serialWith value =
261261 )
262262
263263{-# INLINE split_ #-}
264−split_ :: MonadCatch m
264+split_ :: MonadThrow m
265265 => Int -> Stream m Int -> m ()
266266split_ value =
267267 Stream.parse
@@ -271,13 +271,13 @@ split_ value =
271271 )
272272
273273{-# INLINE takeEndBy_ #-}
274−takeEndBy_ :: MonadCatch m
274+takeEndBy_ :: MonadThrow m
275275 => Int -> Stream m Int -> m()
276276takeEndBy_ value = Stream.parse (PR.takeEndBy_ (>= value) (PR.fromFold Fold.drain))
277277
278278{-
279279{-# INLINE teeAllAny #-}
280−teeAllAny :: MonadCatch m
280+teeAllAny :: MonadThrow m
281281 => Int -> Stream m Int -> m ((), ())
282282teeAllAny value =
283283 Stream.parse
@@ -287,7 +287,7 @@ teeAllAny value =
287287 )
288288
289289{-# INLINE teeFstAllAny #-}
290−teeFstAllAny :: MonadCatch m
290+teeFstAllAny :: MonadThrow m
291291 => Int -> Stream m Int -> m ((), ())
292292teeFstAllAny value =
293293 Stream.parse
@@ -297,7 +297,7 @@ teeFstAllAny value =
297297 )
298298
299299{-# INLINE shortestAllAny #-}
300−shortestAllAny :: MonadCatch m
300+shortestAllAny :: MonadThrow m
301301 => Int -> Stream m Int -> m ()
302302shortestAllAny value =
303303 Stream.parse
@@ -307,7 +307,7 @@ shortestAllAny value =
307307 )
308308
309309{-# INLINE longestAllAny #-}
310−longestAllAny :: MonadCatch m
310+longestAllAny :: MonadThrow m
311311 => Int -> Stream m Int -> m ()
312312longestAllAny value =
313313 Stream.parse
@@ -349,41 +349,41 @@ parseManyUnfoldArrays count arrays = do
349349-- not have to rely on it.
350350--
351351{-# INLINE lookAhead #-}
352−lookAhead :: MonadCatch m => Int -> Stream m Int -> m ()
352+lookAhead :: MonadThrow m => Int -> Stream m Int -> m ()
353353lookAhead value =
354354 Stream.parse (PR.lookAhead (PR.takeWhile (<= value) Fold.drain) $> ())
355355
356356{-# INLINE sequenceA #-}
357−sequenceA :: MonadCatch m => Int -> Stream m Int -> m Int
357+sequenceA :: MonadThrow m => Int -> Stream m Int -> m Int
358358sequenceA value xs = do
359359 x <- Stream.parse (TR.sequenceA (replicate value (PR.satisfy (> 0)))) xs
360360 return $ length x
361361
362362{-# INLINE sequenceA_ #-}
363−sequenceA_ :: MonadCatch m => Int -> Stream m Int -> m ()
363+sequenceA_ :: MonadThrow m => Int -> Stream m Int -> m ()
364364sequenceA_ value =
365365 Stream.parse (F.sequenceA_ $ replicate value (PR.satisfy (> 0)))
366366
367367{-# INLINE sequence #-}
368−sequence :: MonadCatch m => Int -> Stream m Int -> m Int
368+sequence :: MonadThrow m => Int -> Stream m Int -> m Int
369369sequence value xs = do
370370 x <- Stream.parse (TR.sequence (replicate value (PR.satisfy (> 0)))) xs
371371 return $ length x
372372
373373{-# INLINE sequence_ #-}
374−sequence_ :: MonadCatch m => Int -> Stream m Int -> m ()
374+sequence_ :: MonadThrow m => Int -> Stream m Int -> m ()
375375sequence_ value =
376376 Stream.parse (F.sequence_ $ replicate value (PR.satisfy (> 0)))
377377
378378{-# INLINE choiceAsum #-}
379−choiceAsum :: MonadCatch m => Int -> Stream m Int -> m Int
379+choiceAsum :: MonadThrow m => Int -> Stream m Int -> m Int
380380choiceAsum value =
381381 Stream.parse (asum (replicate value (PR.satisfy (< 0)))
382382 AP.<|> PR.satisfy (> 0))
383383
384384{-
385385{-# INLINE choice #-}
386−choice :: MonadCatch m => Int -> Stream m Int -> m Int
386+choice :: MonadThrow m => Int -> Stream m Int -> m Int
387387choice value =
388388 Stream.parse
389389 (PR.choice (replicate value (PR.satisfy (< 0))) AP.<|> PR.satisfy (> 0))
@@ -394,7 +394,7 @@ choice value =
394394-------------------------------------------------------------------------------
395395
396396{-# INLINE parseMany #-}
397−parseMany :: MonadCatch m => Int -> Stream m Int -> m ()
397+parseMany :: MonadThrow m => Int -> Stream m Int -> m ()
398398parseMany n =
399399 Stream.fold Fold.drain
400400 . fmap getSum
@@ -402,7 +402,7 @@ parseMany n =
402402 . fmap Sum
403403
404404{-# INLINE parseIterate #-}
405−parseIterate :: MonadCatch m => Int -> Stream m Int -> m ()
405+parseIterate :: MonadThrow m => Int -> Stream m Int -> m ()
406406parseIterate n =
407407 Stream.fold Fold.drain
408408 . fmap getSum
@@ -418,7 +418,7 @@ parseBreak s = do
418418 Right (_, s1) -> parseBreak s1
419419
420420{-# INLINE concatSequence #-}
421−concatSequence :: MonadCatch m => Stream m Int -> m ()
421+concatSequence :: MonadThrow m => Stream m Int -> m ()
422422concatSequence = Stream.parse $ PR.concatSequence Fold.drain $ Stream.repeat PR.one
423423
424424-------------------------------------------------------------------------------