on master help sign in
Rename drainWhile parser to dropWhile
769564dHarendra Kumar
benchmark/Streamly/Benchmark/Data/Parser.hs+24−24
@@ -23,8 +23,8 @@ import GHC.Magic (inline)
23import GHC.Magic (noinline)
23import GHC.Magic (noinline)
24import System.IO (Handle)
24import System.IO (Handle)
25import System.Random (randomRIO)
25import System.Random (randomRIO)
26−import Prelude
26+import Prelude hiding
27− hiding (any, all, take, sequence, sequence_, sequenceA, takeWhile)
27+ (any, all, take, sequence, sequence_, sequenceA, takeWhile, dropWhile)
28
28
29import qualified Data.Traversable as TR
29import qualified Data.Traversable as TR
30import qualified Data.Foldable as F
30import qualified Data.Foldable as F
@@ -88,9 +88,9 @@ takeBetween value = IP.parse (PR.takeBetween 0 value FL.drain)
88takeEQ :: MonadCatch m => Int -> SerialT m a -> m ()
88takeEQ :: MonadCatch m => Int -> SerialT m a -> m ()
89takeEQ value = IP.parse (PR.takeEQ value FL.drain)
89takeEQ value = IP.parse (PR.takeEQ value FL.drain)
90
90
91−{-# INLINE drainWhile #-}
91+{-# INLINE dropWhile #-}
92−drainWhile :: MonadCatch m => Int -> SerialT m Int -> m ()
92+dropWhile :: MonadCatch m => Int -> SerialT m Int -> m ()
93−drainWhile value = IP.parse (PR.drainWhile (<= value))
93+dropWhile value = IP.parse (PR.dropWhile (<= value))
94
94
95{-# INLINE sliceBeginWith #-}
95{-# INLINE sliceBeginWith #-}
96sliceBeginWith :: MonadCatch m => Int -> SerialT m Int -> m ()
96sliceBeginWith :: MonadCatch m => Int -> SerialT m Int -> m ()
@@ -154,8 +154,8 @@ splitAp :: MonadCatch m
154splitAp value =
154splitAp value =
155 IP.parse
155 IP.parse
156 ((,)
156 ((,)
157− <$> PR.drainWhile (<= (value `div` 2))
157+ <$> PR.dropWhile (<= (value `div` 2))
158− <*> PR.drainWhile (<= value)
158+ <*> PR.dropWhile (<= value)
159 )
159 )
160
160
161{-# INLINE splitApBefore #-}
161{-# INLINE splitApBefore #-}
@@ -163,8 +163,8 @@ splitApBefore :: MonadCatch m
163 => Int -> SerialT m Int -> m ()
163 => Int -> SerialT m Int -> m ()
164splitApBefore value =
164splitApBefore value =
165 IP.parse
165 IP.parse
166− ( PR.drainWhile (<= (value `div` 2))
166+ ( PR.dropWhile (<= (value `div` 2))
167− *> PR.drainWhile (<= value)
167+ *> PR.dropWhile (<= value)
168 )
168 )
169
169
170{-# INLINE splitApAfter #-}
170{-# INLINE splitApAfter #-}
@@ -172,8 +172,8 @@ splitApAfter :: MonadCatch m
172 => Int -> SerialT m Int -> m ()
172 => Int -> SerialT m Int -> m ()
173splitApAfter value =
173splitApAfter value =
174 IP.parse
174 IP.parse
175− ( PR.drainWhile (<= (value `div` 2))
175+ ( PR.dropWhile (<= (value `div` 2))
176− <* PR.drainWhile (<= value)
176+ <* PR.dropWhile (<= value)
177 )
177 )
178
178
179{-# INLINE serialWith #-}
179{-# INLINE serialWith #-}
@@ -182,8 +182,8 @@ serialWith :: MonadCatch m
182serialWith value =
182serialWith value =
183 IP.parse
183 IP.parse
184 (PR.serialWith (,)
184 (PR.serialWith (,)
185− (PR.drainWhile (<= (value `div` 2)))
185+ (PR.dropWhile (<= (value `div` 2)))
186− (PR.drainWhile (<= value))
186+ (PR.dropWhile (<= value))
187 )
187 )
188
188
189{-# INLINE split_ #-}
189{-# INLINE split_ #-}
@@ -192,8 +192,8 @@ split_ :: MonadCatch m
192split_ value =
192split_ value =
193 IP.parse
193 IP.parse
194 (PR.split_
194 (PR.split_
195− (PR.drainWhile (<= (value `div` 2)))
195+ (PR.dropWhile (<= (value `div` 2)))
196− (PR.drainWhile (<= value))
196+ (PR.dropWhile (<= value))
197 )
197 )
198
198
199{-# INLINE sliceSepByP #-}
199{-# INLINE sliceSepByP #-}
@@ -207,8 +207,8 @@ teeAllAny :: MonadCatch m
207teeAllAny value =
207teeAllAny value =
208 IP.parse
208 IP.parse
209 (PR.teeWith (,)
209 (PR.teeWith (,)
210− (PR.drainWhile (<= value))
210+ (PR.dropWhile (<= value))
211− (PR.drainWhile (<= value))
211+ (PR.dropWhile (<= value))
212 )
212 )
213
213
214{-# INLINE teeFstAllAny #-}
214{-# INLINE teeFstAllAny #-}
@@ -217,8 +217,8 @@ teeFstAllAny :: MonadCatch m
217teeFstAllAny value =
217teeFstAllAny value =
218 IP.parse
218 IP.parse
219 (PR.teeWithFst (,)
219 (PR.teeWithFst (,)
220− (PR.drainWhile (<= value))
220+ (PR.dropWhile (<= value))
221− (PR.drainWhile (<= value))
221+ (PR.dropWhile (<= value))
222 )
222 )
223
223
224{-# INLINE shortestAllAny #-}
224{-# INLINE shortestAllAny #-}
@@ -227,8 +227,8 @@ shortestAllAny :: MonadCatch m
227shortestAllAny value =
227shortestAllAny value =
228 IP.parse
228 IP.parse
229 (PR.shortest
229 (PR.shortest
230− (PR.drainWhile (<= value))
230+ (PR.dropWhile (<= value))
231− (PR.drainWhile (<= value))
231+ (PR.dropWhile (<= value))
232 )
232 )
233
233
234{-# INLINE longestAllAny #-}
234{-# INLINE longestAllAny #-}
@@ -237,8 +237,8 @@ longestAllAny :: MonadCatch m
237longestAllAny value =
237longestAllAny value =
238 IP.parse
238 IP.parse
239 (PR.longest
239 (PR.longest
240− (PR.drainWhile (<= value))
240+ (PR.dropWhile (<= value))
241− (PR.drainWhile (<= value))
241+ (PR.dropWhile (<= value))
242 )
242 )
243
243
244parseManyChunksOfSum :: Int -> Handle -> IO Int
244parseManyChunksOfSum :: Int -> Handle -> IO Int
@@ -345,7 +345,7 @@ o_1_space_serial value =
345 , benchIOSink value "takeEQ" $ takeEQ value
345 , benchIOSink value "takeEQ" $ takeEQ value
346 , benchIOSink value "takeWhile" $ takeWhile value
346 , benchIOSink value "takeWhile" $ takeWhile value
347 , benchIOSink value "takeP" $ takeP value
347 , benchIOSink value "takeP" $ takeP value
348− , benchIOSink value "drainWhile" $ drainWhile value
348+ , benchIOSink value "dropWhile" $ dropWhile value
349 , benchIOSink value "sliceBeginWith" $ sliceBeginWith value
349 , benchIOSink value "sliceBeginWith" $ sliceBeginWith value
350 , benchIOSink value "groupBy" $ groupBy
350 , benchIOSink value "groupBy" $ groupBy
351 , benchIOSink value "groupByRolling" $ groupByRolling
351 , benchIOSink value "groupByRolling" $ groupByRolling
core/src/Streamly/Internal/Data/Parser.hs+7−6
@@ -100,7 +100,7 @@ module Streamly.Internal.Data.Parser
100 , takeWhile
100 , takeWhile
101 -- $takeWhile
101 -- $takeWhile
102 , takeWhile1
102 , takeWhile1
103− , drainWhile
103+ , dropWhile
104
104
105 -- Separators
105 -- Separators
106 , sliceSepByP
106 , sliceSepByP
@@ -223,7 +223,8 @@ import Control.Applicative ((<|>))
223import Control.Monad.Catch (MonadCatch, MonadThrow)
223import Control.Monad.Catch (MonadCatch, MonadThrow)
224import Data.Functor (($>))
224import Data.Functor (($>))
225import Prelude hiding
225import Prelude hiding
226− (any, all, take, takeWhile, sequence, concatMap, maybe, either, filter)
226+ ( any, all, dropWhile, take, takeWhile, sequence, concatMap, maybe, either
227+ , filter )
227
228
228import Streamly.Internal.Data.Fold.Type (Fold(..))
229import Streamly.Internal.Data.Fold.Type (Fold(..))
229import Streamly.Internal.Data.Parser.ParserK.Type (Parser)
230import Streamly.Internal.Data.Parser.ParserK.Type (Parser)
@@ -236,7 +237,7 @@ import qualified Streamly.Internal.Data.Parser.ParserK.Type as K
236-- $setup
237-- $setup
237-- >>> :m
238-- >>> :m
238-- >>> :set -package streamly
239-- >>> :set -package streamly
239−-- >>> import Prelude hiding (any, all, take, takeWhile, sequence, concatMap, maybe, either)
240+-- >>> import Prelude hiding (any, all, dropWhile, take, takeWhile, sequence, concatMap, maybe, either, filter)
240-- >>> import qualified Streamly.Prelude as Stream
241-- >>> import qualified Streamly.Prelude as Stream
241-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (parse, parseMany)
242-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (parse, parseMany)
242-- >>> import qualified Streamly.Data.Fold as Fold
243-- >>> import qualified Streamly.Data.Fold as Fold
@@ -634,9 +635,9 @@ takeWhile1 cond = D.toParserK . D.takeWhile1 cond
634--
635--
635-- /Pre-release/
636-- /Pre-release/
636--
637--
637−{-# INLINE drainWhile #-}
638+{-# INLINE dropWhile #-}
638−drainWhile :: MonadCatch m => (a -> Bool) -> Parser m a ()
639+dropWhile :: MonadCatch m => (a -> Bool) -> Parser m a ()
639−drainWhile p = takeWhile p FL.drain
640+dropWhile p = takeWhile p FL.drain
640
641
641-------------------------------------------------------------------------------
642-------------------------------------------------------------------------------
642-- Separators
643-- Separators