on master help sign in
Add another type of input mapping in Producer
8bfff35Adithya Kumar
core/src/Streamly/Internal/Data/Producer/Type.hs+8
@@ -23,6 +23,7 @@ module Streamly.Internal.Data.Producer.Type
23 -- * Mapping
23 -- * Mapping
24 , translate
24 , translate
25 , lmap
25 , lmap
26+ , lmap_
26
27
27 -- * Nesting
28 -- * Nesting
28 , NestedLoop (..)
29 , NestedLoop (..)
@@ -112,6 +113,13 @@ translate f g (Producer step inject extract) =
112lmap :: (a -> a) -> Producer m a b -> Producer m a b
113lmap :: (a -> a) -> Producer m a b -> Producer m a b
113lmap f (Producer step inject extract) = Producer step (inject . f) extract
114lmap f (Producer step inject extract) = Producer step (inject . f) extract
114
115
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+
115------------------------------------------------------------------------------
123------------------------------------------------------------------------------
116-- Functor
124-- Functor
117------------------------------------------------------------------------------
125------------------------------------------------------------------------------