on master help sign in
Use yieldM from ParserK
f4e7f4bHarendra Kumar
src/Streamly/Internal/Data/Parser.hs+1−1
@@ -262,7 +262,7 @@ yield = K.toParserK . D.yield
262--
262--
263{-# INLINE yieldM #-}
263{-# INLINE yieldM #-}
264yieldM :: MonadCatch m => m b -> Parser m a b
264yieldM :: MonadCatch m => m b -> Parser m a b
265−yieldM = K.toParserK . D.yieldM
265+yieldM = K.yieldM -- K.toParserK . D.yieldM
266
266
267-- This is the dual of "nil".
267-- This is the dual of "nil".
268--
268--
src/Streamly/Internal/Data/Parser/ParserK/Types.hs+9
@@ -22,6 +22,7 @@ module Streamly.Internal.Data.Parser.ParserK.Types
22 (
22 (
23 Parser (..)
23 Parser (..)
24 , yield
24 , yield
25+ , yieldM
25 , die
26 , die
26
27
27 -- * Conversion
28 -- * Conversion
@@ -278,6 +279,14 @@ instance Functor m => Functor (Parser m a) where
278yield :: b -> Parser m a b
279yield :: b -> Parser m a b
279yield b = MkParser $ \lo st yieldk -> yieldk st (Done lo b)
280yield b = MkParser $ \lo st yieldk -> yieldk st (Done lo b)
280
281
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+
281-- | 'Applicative' form of 'Streamly.Internal.Data.Parser.splitWith'. Note that
290-- | 'Applicative' form of 'Streamly.Internal.Data.Parser.splitWith'. Note that
282-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.splitWith'
291-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.splitWith'
283-- when fusion is important.
292-- when fusion is important.