mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Add rmapM to Parser
This commit is contained in:
parent
88334a8190
commit
3a90efbd87
@ -59,6 +59,9 @@ module Streamly.Data.Parser
|
||||
, lmap
|
||||
, lmapM
|
||||
|
||||
-- * Map on output
|
||||
, rmapM
|
||||
|
||||
-- ** Filtering
|
||||
, filter
|
||||
|
||||
|
@ -68,6 +68,9 @@ module Streamly.Internal.Data.Parser
|
||||
, lmapM
|
||||
, filter
|
||||
|
||||
-- * Map on output
|
||||
, rmapM
|
||||
|
||||
-- * Element parsers
|
||||
, peek
|
||||
|
||||
@ -384,6 +387,13 @@ lmap f p = D.toParserK $ D.lmap f $ D.fromParserK p
|
||||
lmapM :: Monad m => (a -> m b) -> Parser m b r -> Parser m a r
|
||||
lmapM f p = D.toParserK $ D.lmapM f $ D.fromParserK p
|
||||
|
||||
-- | @rmapM f parser@ maps the monadic function @f@ on the output of the parser.
|
||||
--
|
||||
-- /Internal/
|
||||
{-# INLINE rmapM #-}
|
||||
rmapM :: Monad m => (b -> m c) -> Parser m a b -> Parser m a c
|
||||
rmapM f p = D.toParserK $ D.rmapM f $ D.fromParserK p
|
||||
|
||||
-- | Include only those elements that pass a predicate.
|
||||
--
|
||||
-- >>> Stream.parse (Parser.filter (> 5) (Parser.fromFold Fold.sum)) $ Stream.fromList [1..10]
|
||||
|
Loading…
Reference in New Issue
Block a user