on master help sign in
Add another type of input mapping in Producer
commit8bfff35b442a9e74b1fe476f65159ee5be50e37d authorAdithya Kumar <adithya@composewell.com> dateSat 4 Jun 2022, 03:32 (4 years ago) parentbf8561e
1 file changed+8
core/src/Streamly/Internal/Data/Producer/Type.hs+8
core/src/Streamly/Internal/Data/Producer/Type.hs+8
@@ -23,6 +23,7 @@ module Streamly.Internal.Data.Producer.Type
2323 -- * Mapping
2424 , translate
2525 , lmap
26+ , lmap_
2627
2728 -- * Nesting
2829 , NestedLoop (..)
@@ -112,6 +113,13 @@ translate f g (Producer step inject extract) =
112113lmap :: (a -> a) -> Producer m a b -> Producer m a b
113114lmap f (Producer step inject extract) = Producer step (inject . f) extract
114115
116+-- | Map the producer input using the provided translation functions
117+--
118+-- /Pre-release/
119+{-# INLINE_NORMAL lmap_ #-}
120+lmap_ :: Functor m => (a -> c) -> (c -> a) -> Producer m c b -> Producer m a b
121+lmap_ f g (Producer step inject extract) = Producer step (inject . f) (fmap g . extract)
122+
115123------------------------------------------------------------------------------
116124-- Functor
117125------------------------------------------------------------------------------