on master help sign in
Use yieldM from ParserK

ParserD yieldM requires an additional input to yield a value, ParserD needs to be fixed in general to avoid this issue.

commitf4e7f4b8b1216a9ed6ba35f3e29078c9ea797cfd authorHarendra Kumar <harendra@composewell.com> dateFri 23 Oct 2020, 17:47 (6 years ago) parent6c9941d
2 files changed+10−1
src/Streamly/Internal/Data/Parser.hs+1−1 src/Streamly/Internal/Data/Parser/ParserK/Types.hs+9
src/Streamly/Internal/Data/Parser.hs+1−1
@@ -262,7 +262,7 @@ yield = K.toParserK . D.yield
262262--
263263{-# INLINE yieldM #-}
264264yieldM :: MonadCatch m => m b -> Parser m a b
265−yieldM = K.toParserK . D.yieldM
265+yieldM = K.yieldM -- K.toParserK . D.yieldM
266266
267267-- This is the dual of "nil".
268268--
src/Streamly/Internal/Data/Parser/ParserK/Types.hs+9
@@ -22,6 +22,7 @@ module Streamly.Internal.Data.Parser.ParserK.Types
2222 (
2323 Parser (..)
2424 , yield
25+ , yieldM
2526 , die
2627
2728 -- * Conversion
@@ -278,6 +279,14 @@ instance Functor m => Functor (Parser m a) where
278279yield :: b -> Parser m a b
279280yield b = MkParser $ \lo st yieldk -> yieldk st (Done lo b)
280281
282+-- | See 'Streamly.Internal.Data.Parser.yieldM'.
283+--
284+-- /Internal/
285+--
286+{-# INLINE yieldM #-}
287+yieldM :: Monad m => m b -> Parser m a b
288+yieldM eff = MkParser $ \lo st yieldk -> eff >>= \b -> yieldk st (Done lo b)
289+
281290-- | 'Applicative' form of 'Streamly.Internal.Data.Parser.splitWith'. Note that
282291-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.splitWith'
283292-- when fusion is important.