on master help sign in
Add the unimplemented postscan for parsers
da08f2aHarendra Kumar
core/src/Streamly/Internal/Data/Parser/ParserD.hs+19
@@ -36,6 +36,7 @@ module Streamly.Internal.Data.Parser.ParserD
36 -- * Map on input
36 -- * Map on input
37 , lmap
37 , lmap
38 , lmapM
38 , lmapM
39+ , postscan
39 , filter
40 , filter
40
41
41 -- * Element parsers
42 -- * Element parsers
@@ -1459,6 +1460,24 @@ matchBy cmp (D.Stream sstep state) = Parser step initial extract
1459
1460
1460 extract _ = throwM $ ParseError "match: end of input"
1461 extract _ = throwM $ ParseError "match: end of input"
1461
1462
1463+-------------------------------------------------------------------------------
1464+-- Transformations on input
1465+-------------------------------------------------------------------------------
1466+
1467+-- Initial needs a "Continue" constructor to implement scans on parsers. As a
1468+-- parser can always return a Continue in initial when we feed the fold's
1469+-- initial result to it. We can work this around for postscan by introducing an
1470+-- initial state and calling "initial" only on the first input.
1471+--
1472+-- | Stateful scan on the input of a parser using a Fold.
1473+--
1474+-- /Unimplemented/
1475+--
1476+{-# INLINE postscan #-}
1477+postscan :: -- Monad m =>
1478+ Fold m a b -> Parser m b c -> Parser m a c
1479+postscan = undefined
1480+
1462{-# INLINE zipWithM #-}
1481{-# INLINE zipWithM #-}
1463zipWithM :: MonadThrow m =>
1482zipWithM :: MonadThrow m =>
1464 (a -> b -> m c) -> D.Stream m a -> Fold m c x -> Parser m b x
1483 (a -> b -> m c) -> D.Stream m a -> Fold m c x -> Parser m b x