on master help sign in
Remove map from Internal.Data.Fold
8d93967Ranjeet Kumar Ranjan
benchmark/Streamly/Benchmark/Data/Fold.hs+5−5
@@ -142,7 +142,7 @@ partition =
142 if odd a
142 if odd a
143 then Left a
143 then Left a
144 else Right a
144 else Right a
145− in IP.fold $ FL.map f (FL.partition FL.sum FL.length)
145+ in IP.fold $ FL.lmap f (FL.partition FL.sum FL.length)
146
146
147{-# INLINE demuxWith #-}
147{-# INLINE demuxWith #-}
148demuxWith ::
148demuxWith ::
@@ -160,7 +160,7 @@ demuxDefaultWith ::
160 -> Map k (Fold m b b)
160 -> Map k (Fold m b b)
161 -> SerialT m a
161 -> SerialT m a
162 -> m (Map k b, b)
162 -> m (Map k b, b)
163−demuxDefaultWith f mp = S.fold (FL.demuxDefaultWith f mp (FL.map snd FL.sum))
163+demuxDefaultWith f mp = S.fold (FL.demuxDefaultWith f mp (FL.lmap snd FL.sum))
164
164
165{-# INLINE classifyWith #-}
165{-# INLINE classifyWith #-}
166classifyWith ::
166classifyWith ::
@@ -173,7 +173,7 @@ classifyWith f = S.fold (FL.classifyWith f FL.sum)
173
173
174{-# INLINE unzip #-}
174{-# INLINE unzip #-}
175unzip :: Monad m => SerialT m Int -> m (Int, Int)
175unzip :: Monad m => SerialT m Int -> m (Int, Int)
176−unzip = IP.fold $ FL.map (\a -> (a, a)) (FL.unzip FL.sum FL.length)
176+unzip = IP.fold $ FL.lmap (\a -> (a, a)) (FL.unzip FL.sum FL.length)
177
177
178-------------------------------------------------------------------------------
178-------------------------------------------------------------------------------
179-- Benchmarks
179-- Benchmarks
@@ -228,7 +228,7 @@ o_1_space_serial_elimination value =
228 , benchIOSink
228 , benchIOSink
229 value
229 value
230 "lookup"
230 "lookup"
231− (S.fold (FL.map (\a -> (a, a)) (FL.lookup (value + 1))))
231+ (S.fold (FL.lmap (\a -> (a, a)) (FL.lookup (value + 1))))
232 , benchIOSink
232 , benchIOSink
233 value
233 value
234 "findIndex"
234 "findIndex"
@@ -252,7 +252,7 @@ o_1_space_serial_elimination value =
252o_1_space_serial_transformation :: Int -> [Benchmark]
252o_1_space_serial_transformation :: Int -> [Benchmark]
253o_1_space_serial_transformation value =
253o_1_space_serial_transformation value =
254 [ bgroup "transformation"
254 [ bgroup "transformation"
255− [ benchIOSink value "map" (S.fold (FL.map (+ 1) FL.drain))
255+ [ benchIOSink value "map" (S.fold (FL.lmap (+ 1) FL.drain))
256 , let f x = if even x then Just x else Nothing
256 , let f x = if even x then Just x else Nothing
257 fld = FL.mapMaybe f FL.drain
257 fld = FL.mapMaybe f FL.drain
258 in benchIOSink value "mapMaybe" (S.fold fld)
258 in benchIOSink value "mapMaybe" (S.fold fld)
src/Streamly/Internal/Data/Array/Stream/Foreign.hs+1−1
@@ -211,7 +211,7 @@ packArraysChunksOf n str =
211lpackArraysChunksOf :: (MonadIO m, Storable a)
211lpackArraysChunksOf :: (MonadIO m, Storable a)
212 => Int -> Fold m (Array a) () -> Fold m (Array a) ()
212 => Int -> Fold m (Array a) () -> Fold m (Array a) ()
213lpackArraysChunksOf n fld =
213lpackArraysChunksOf n fld =
214− FL.map A.unsafeThaw $ AS.lpackArraysChunksOf n (FL.map A.unsafeFreeze fld)
214+ FL.lmap A.unsafeThaw $ AS.lpackArraysChunksOf n (FL.lmap A.unsafeFreeze fld)
215
215
216-- | Coalesce adjacent arrays in incoming stream to form bigger arrays of a
216-- | Coalesce adjacent arrays in incoming stream to form bigger arrays of a
217-- maximum specified size in bytes.
217-- maximum specified size in bytes.
src/Streamly/Internal/Data/Fold.hs+4−5
@@ -109,7 +109,6 @@ module Streamly.Internal.Data.Fold
109
109
110 -- ** Mapping on Input
110 -- ** Mapping on Input
111 , transform
111 , transform
112− , map
113 , lmap
112 , lmap
114 --, lsequence
113 --, lsequence
115 , lmapM
114 , lmapM
@@ -328,7 +327,7 @@ mapM = rmapM
328-- @since 0.8.0
327-- @since 0.8.0
329{-# INLINE mapMaybe #-}
328{-# INLINE mapMaybe #-}
330mapMaybe :: (Monad m) => (a -> Maybe b) -> Fold m b r -> Fold m a r
329mapMaybe :: (Monad m) => (a -> Maybe b) -> Fold m b r -> Fold m a r
331−mapMaybe f = map f . filter isJust . map fromJust
330+mapMaybe f = lmap f . filter isJust . lmap fromJust
332
331
333------------------------------------------------------------------------------
332------------------------------------------------------------------------------
334-- Transformations on fold inputs
333-- Transformations on fold inputs
@@ -1550,12 +1549,12 @@ classifyWith f (Fold step1 initial1 extract1) =
1550--
1549--
1551-- Same as:
1550-- Same as:
1552--
1551--
1553−-- > classify fld = Fold.classifyWith fst (map snd fld)
1552+-- > classify fld = Fold.classifyWith fst (lmap snd fld)
1554--
1553--
1555-- /Pre-release/
1554-- /Pre-release/
1556{-# INLINE classify #-}
1555{-# INLINE classify #-}
1557classify :: (Monad m, Ord k) => Fold m a b -> Fold m (k, a) (Map k b)
1556classify :: (Monad m, Ord k) => Fold m a b -> Fold m (k, a) (Map k b)
1558−classify fld = classifyWith fst (map snd fld)
1557+classify fld = classifyWith fst (lmap snd fld)
1559
1558
1560------------------------------------------------------------------------------
1559------------------------------------------------------------------------------
1561-- Unzipping
1560-- Unzipping
@@ -1719,7 +1718,7 @@ with ::
1719 (Fold m (s, a) b -> Fold m a b)
1718 (Fold m (s, a) b -> Fold m a b)
1720 -> (((s, a) -> c) -> Fold m (s, a) b -> Fold m (s, a) b)
1719 -> (((s, a) -> c) -> Fold m (s, a) b -> Fold m (s, a) b)
1721 -> (((s, a) -> c) -> Fold m a b -> Fold m a b)
1720 -> (((s, a) -> c) -> Fold m a b -> Fold m a b)
1722−with f comb g = f . comb g . map snd
1721+with f comb g = f . comb g . lmap snd
1723
1722
1724-- | @sampleFromthen offset stride@ samples the element at @offset@ index and
1723-- | @sampleFromthen offset stride@ samples the element at @offset@ index and
1725-- then every element at strides of @stride@.
1724-- then every element at strides of @stride@.
src/Streamly/Internal/Data/Fold/Type.hs+1−9
@@ -218,7 +218,6 @@ module Streamly.Internal.Data.Fold.Type
218 , rmapM
218 , rmapM
219
219
220 -- ** Mapping Input
220 -- ** Mapping Input
221− , map
222 , lmap
221 , lmap
223 , lmapM
222 , lmapM
224
223
@@ -917,13 +916,6 @@ lmap f (Fold step begin done) = Fold step' begin done
917 where
916 where
918 step' x a = step x (f a)
917 step' x a = step x (f a)
919
918
920−-- XXX should be removed
921−-- |
922−-- /Internal/
923−{-# INLINE map #-}
924−map :: (a -> b) -> Fold m b r -> Fold m a r
925−map = lmap
926−
927-- | @lmapM f fold@ maps the monadic function @f@ on the input of the fold.
919-- | @lmapM f fold@ maps the monadic function @f@ on the input of the fold.
928--
920--
929-- @since 0.8.0
921-- @since 0.8.0
@@ -968,7 +960,7 @@ filterM f (Fold step begin done) = Fold step' begin done
968-- @since 0.8.0
960-- @since 0.8.0
969{-# INLINE catMaybes #-}
961{-# INLINE catMaybes #-}
970catMaybes :: Monad m => Fold m a b -> Fold m (Maybe a) b
962catMaybes :: Monad m => Fold m a b -> Fold m (Maybe a) b
971−catMaybes = filter isJust . map fromJust
963+catMaybes = filter isJust . lmap fromJust
972
964
973------------------------------------------------------------------------------
965------------------------------------------------------------------------------
974-- Parsing
966-- Parsing