on master help sign in
Remove MonadCatch constraints from parser benchmarks
commitb870dbeb1e0c2e8233dd80c8b0118916b4d5c37b authorHarendra Kumar <harendra@composewell.com> dateSat 20 Aug 2022, 18:27 (4 years ago) parent2ae9759
1 file changed+17−17
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+17−17
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+17−17
@@ -15,7 +15,7 @@ module Main
1515 ) where
1616
1717import Control.DeepSeq (NFData(..))
18−import Control.Monad.Catch (MonadCatch, MonadThrow)
18+import Control.Monad.Catch (MonadThrow)
1919import Data.Foldable (asum)
2020import Data.Function ((&))
2121import Data.Functor (($>))
@@ -71,7 +71,7 @@ drainWhile :: MonadThrow m => (a -> Bool) -> PR.Parser m a ()
7171drainWhile p = PR.takeWhile p Fold.drain
7272
7373{-# INLINE takeStartBy #-}
74−takeStartBy :: MonadCatch m => Int -> Stream m Int -> m ()
74+takeStartBy :: MonadThrow m => Int -> Stream m Int -> m ()
7575takeStartBy value stream = do
7676 stream1 <- return . fromMaybe (Stream.fromPure (value + 1)) =<< IsStream.tail stream
7777 let stream2 = value `Stream.cons` stream1
@@ -86,7 +86,7 @@ takeP :: MonadThrow m => Int -> Stream m a -> m ()
8686takeP value = Stream.parseD (PR.takeP value (PR.fromFold Fold.drain))
8787
8888{-# INLINE takeBetween #-}
89−takeBetween :: MonadCatch m => Int -> Stream m a -> m ()
89+takeBetween :: MonadThrow m => Int -> Stream m a -> m ()
9090takeBetween value = Stream.parseD (PR.takeBetween 0 value Fold.drain)
9191
9292{-# INLINE groupBy #-}
@@ -102,36 +102,36 @@ wordBy :: MonadThrow m => Int -> Stream m Int -> m ()
102102wordBy value = Stream.parseD (PR.wordBy (>= value) Fold.drain)
103103
104104{-# INLINE manyWordByEven #-}
105−manyWordByEven :: MonadCatch m => Stream m Int -> m ()
105+manyWordByEven :: MonadThrow m => Stream m Int -> m ()
106106manyWordByEven =
107107 Stream.parseD (PR.many (PR.wordBy (Prelude.even) Fold.drain) Fold.drain)
108108
109109{-# INLINE many #-}
110−many :: MonadCatch m => Stream m Int -> m Int
110+many :: MonadThrow m => Stream m Int -> m Int
111111many = Stream.parseD (PR.many (PR.satisfy (> 0)) Fold.length)
112112
113113{-# INLINE manyAlt #-}
114−manyAlt :: MonadCatch m => Stream m Int -> m Int
114+manyAlt :: MonadThrow m => Stream m Int -> m Int
115115manyAlt xs = do
116116 x <- Stream.parseD (AP.many (PR.satisfy (> 0))) xs
117117 return $ Prelude.length x
118118
119119{-# INLINE some #-}
120−some :: MonadCatch m => Stream m Int -> m Int
120+some :: MonadThrow m => Stream m Int -> m Int
121121some = Stream.parseD (PR.some (PR.satisfy (> 0)) Fold.length)
122122
123123{-# INLINE someAlt #-}
124−someAlt :: MonadCatch m => Stream m Int -> m Int
124+someAlt :: MonadThrow m => Stream m Int -> m Int
125125someAlt xs = do
126126 x <- Stream.parseD (AP.some (PR.satisfy (> 0))) xs
127127 return $ Prelude.length x
128128
129129{-#INLINE takeEndBy_ #-}
130−takeEndBy_ :: MonadCatch m => Int -> Stream m Int -> m ()
130+takeEndBy_ :: MonadThrow m => Int -> Stream m Int -> m ()
131131takeEndBy_ value = Stream.parseD (PR.takeEndBy_ (>= value) (PR.fromFold Fold.drain))
132132
133133{-# INLINE manyTill #-}
134−manyTill :: MonadCatch m => Int -> Stream m Int -> m Int
134+manyTill :: MonadThrow m => Int -> Stream m Int -> m Int
135135manyTill value =
136136 let p = PR.satisfy (> 0)
137137 pcond = PR.satisfy (== value)
@@ -179,7 +179,7 @@ shortestAllAny value =
179179 )
180180
181181{-# INLINE longestAllAny #-}
182−longestAllAny :: MonadCatch m
182+longestAllAny :: MonadThrow m
183183 => Int -> Stream m Int -> m ()
184184longestAllAny value =
185185 Stream.parseD
@@ -190,7 +190,7 @@ longestAllAny value =
190190-}
191191
192192{-# INLINE sequenceParser #-}
193−sequenceParser :: MonadCatch m => Stream m Int -> m ()
193+sequenceParser :: MonadThrow m => Stream m Int -> m ()
194194sequenceParser = Stream.parseD (PR.sequence Fold.drain (D.repeat (PR.satisfy $ const True)))
195195
196196-------------------------------------------------------------------------------
@@ -229,7 +229,7 @@ parseManyGroupsRolling b =
229229 Stream.fold Fold.drain . Stream.parseManyD (PR.groupByRolling (\_ _ -> b) Fold.drain)
230230
231231{-# INLINE parseManyGroupsRollingEither #-}
232−parseManyGroupsRollingEither :: (MonadThrow m, MonadCatch m) =>
232+parseManyGroupsRollingEither :: MonadThrow m =>
233233 (Int -> Int -> Bool) -> Int -> m ()
234234parseManyGroupsRollingEither cmp value = do
235235 sourceUnfoldrM value 1
@@ -237,7 +237,7 @@ parseManyGroupsRollingEither cmp value = do
237237 & Stream.fold Fold.drain
238238
239239{-# INLINE parseManyGroupsRollingEitherAlt #-}
240−parseManyGroupsRollingEitherAlt :: (MonadThrow m, MonadCatch m) =>
240+parseManyGroupsRollingEitherAlt :: MonadThrow m =>
241241 (Int -> Int -> Bool) -> Int -> m ()
242242parseManyGroupsRollingEitherAlt cmp value = do
243243 sourceUnfoldrM value 1
@@ -296,7 +296,7 @@ sequence value xs = do
296296 return $ length x
297297
298298{-# INLINE sequence_ #-}
299−sequence_ :: MonadCatch m => Int -> Stream m Int -> m ()
299+sequence_ :: MonadThrow m => Int -> Stream m Int -> m ()
300300sequence_ value xs =
301301 Stream.parseD (foldr f (return ()) (replicate value (PR.takeBetween 0 1 Fold.drain))) xs
302302
@@ -309,14 +309,14 @@ sequence_ value xs =
309309-- quadratic performance complexity.
310310--
311311{-# INLINE choiceAsum #-}
312−choiceAsum :: MonadCatch m => Int -> Stream m Int -> m Int
312+choiceAsum :: MonadThrow m => Int -> Stream m Int -> m Int
313313choiceAsum value =
314314 Stream.parseD (asum (replicate value (PR.satisfy (< 0)))
315315 AP.<|> PR.satisfy (> 0))
316316
317317{-
318318{-# INLINE choice #-}
319−choice :: MonadCatch m => Int -> Stream m Int -> m Int
319+choice :: MonadThrow m => Int -> Stream m Int -> m Int
320320choice value =
321321 Stream.parseD
322322 (PR.choice (replicate value (PR.satisfy (< 0))) AP.<|> PR.satisfy (> 0))