@@ -27,9 +27,9 @@ module Streamly.Internal.Data.Parser.ParserK.Type
27 , Input (..)
27 , Input (..)
28 , ParseResult (..)
28 , ParseResult (..)
29 , ParserK (..)
29 , ParserK (..)
30− , fromParser
30+ , adaptC
31− , fromParserSingular
31+ , adapt
32− , fromParserGeneric
32+ , adaptCG
33 -- , toParser
33 -- , toParser
34 , fromPure
34 , fromPure
35 , fromEffect
35 , fromEffect
@@ -380,8 +380,8 @@ instance MonadTrans (ParserK a) where
380-- Chunked
380-- Chunked
381--------------------------------------------------------------------------------
381--------------------------------------------------------------------------------
383−{-# INLINE parseDToK #-}
383+{-# INLINE adaptCWith #-}
384−parseDToK
384+adaptCWith
385 :: forall m a s b r. (Monad m, Unbox a)
385 :: forall m a s b r. (Monad m, Unbox a)
386 => (s -> a -> m (ParserD.Step s b))
386 => (s -> a -> m (ParserD.Step s b))
387 -> m (ParserD.Initial s b)
387 -> m (ParserD.Initial s b)
@@ -391,7 +391,7 @@ parseDToK
392 -> Input (Array a)
392 -> Input (Array a)
393 -> m (Step (Array a) m r)
393 -> m (Step (Array a) m r)
394−parseDToK pstep initial extract cont !offset0 !usedCount !input = do
394+adaptCWith pstep initial extract cont !offset0 !usedCount !input = do
395 res <- initial
395 res <- initial
396 case res of
396 case res of
397 ParserD.IPartial pst -> do
397 ParserD.IPartial pst -> do
@@ -495,7 +495,7 @@ parseDToK pstep initial extract cont !offset0 !usedCount !input = do
495 -- XXX It is called only when there is no input arr. So using 0
495 -- XXX It is called only when there is no input arr. So using 0
496 -- as the position is correct?
496 -- as the position is correct?
497 cont (Failure 0 err) count None
497 cont (Failure 0 err) count None
498− ParserD.Partial _ _ -> error "Bug: parseDToK Partial unreachable"
498+ ParserD.Partial _ _ -> error "Bug: adaptCWith Partial unreachable"
500 -- XXX Maybe we can use two separate continuations instead of using
500 -- XXX Maybe we can use two separate continuations instead of using
501 -- Just/Nothing cases here. That may help in avoiding the parseContJust
501 -- Just/Nothing cases here. That may help in avoiding the parseContJust
@@ -508,17 +508,17 @@ parseDToK pstep initial extract cont !offset0 !usedCount !input = do
509-- /Pre-release/
509-- /Pre-release/
511−{-# INLINE_LATE fromParser #-}
511+{-# INLINE_LATE adaptC #-}
512−fromParser :: (Monad m, Unbox a) => ParserD.Parser a m b -> ParserK (Array a) m b
512+adaptC :: (Monad m, Unbox a) => ParserD.Parser a m b -> ParserK (Array a) m b
513−fromParser (ParserD.Parser step initial extract) =
513+adaptC (ParserD.Parser step initial extract) =
514− MkParser $ parseDToK step initial extract
514+ MkParser $ adaptCWith step initial extract
516--------------------------------------------------------------------------------
516--------------------------------------------------------------------------------
517-- Singular
517-- Singular
518--------------------------------------------------------------------------------
518--------------------------------------------------------------------------------
520−{-# INLINE parseDToKSingular #-}
520+{-# INLINE adaptWith #-}
521−parseDToKSingular
521+adaptWith
522 :: forall m a s b r. (Monad m)
522 :: forall m a s b r. (Monad m)
523 => (s -> a -> m (ParserD.Step s b))
523 => (s -> a -> m (ParserD.Step s b))
524 -> m (ParserD.Initial s b)
524 -> m (ParserD.Initial s b)
@@ -528,7 +528,7 @@ parseDToKSingular
529 -> Input a
529 -> Input a
530 -> m (Step a m r)
530 -> m (Step a m r)
531−parseDToKSingular pstep initial extract cont !relPos !usedCount !input = do
531+adaptWith pstep initial extract cont !relPos !usedCount !input = do
532 res <- initial
532 res <- initial
533 case res of
533 case res of
534 ParserD.IPartial pst -> do
534 ParserD.IPartial pst -> do
@@ -597,7 +597,7 @@ parseDToKSingular pstep initial extract cont !relPos !usedCount !input = do
597 -- XXX It is called only when there is no input arr. So using 0
597 -- XXX It is called only when there is no input arr. So using 0
598 -- as the position is correct?
598 -- as the position is correct?
599 cont (Failure 0 err) count None
599 cont (Failure 0 err) count None
600− ParserD.Partial _ _ -> error "Bug: parseDToK Partial unreachable"
600+ ParserD.Partial _ _ -> error "Bug: adaptCWith Partial unreachable"
602 -- XXX Maybe we can use two separate continuations instead of using
602 -- XXX Maybe we can use two separate continuations instead of using
603 -- Just/Nothing cases here. That may help in avoiding the parseContJust
603 -- Just/Nothing cases here. That may help in avoiding the parseContJust
@@ -606,19 +606,19 @@ parseDToKSingular pstep initial extract cont !relPos !usedCount !input = do
606 parseCont !cnt !pst (Chunk arr) = parseContChunk cnt pst arr
606 parseCont !cnt !pst (Chunk arr) = parseContChunk cnt pst arr
607 parseCont !cnt !pst None = parseContNothing cnt pst
607 parseCont !cnt !pst None = parseContNothing cnt pst
609−-- | Similar to "fromParser" but for singular elements.
609+-- | Similar to "adaptC" but for non-chunked input.
611−{-# INLINE_LATE fromParserSingular #-}
611+{-# INLINE_LATE adapt #-}
612−fromParserSingular :: Monad m => ParserD.Parser a m b -> ParserK a m b
612+adapt :: Monad m => ParserD.Parser a m b -> ParserK a m b
613−fromParserSingular (ParserD.Parser step initial extract) =
613+adapt (ParserD.Parser step initial extract) =
614− MkParser $ parseDToKSingular step initial extract
614+ MkParser $ adaptWith step initial extract
616--------------------------------------------------------------------------------
616--------------------------------------------------------------------------------
617-- Chunked Generic
617-- Chunked Generic
618--------------------------------------------------------------------------------
618--------------------------------------------------------------------------------
620−{-# INLINE parseDToKGeneric #-}
620+{-# INLINE adaptCGWith #-}
621−parseDToKGeneric
621+adaptCGWith
622 :: forall m a s b r. (Monad m)
622 :: forall m a s b r. (Monad m)
623 => (s -> a -> m (ParserD.Step s b))
623 => (s -> a -> m (ParserD.Step s b))
624 -> m (ParserD.Initial s b)
624 -> m (ParserD.Initial s b)
@@ -628,7 +628,7 @@ parseDToKGeneric
629 -> Input (GenArr.Array a)
629 -> Input (GenArr.Array a)
630 -> m (Step (GenArr.Array a) m r)
630 -> m (Step (GenArr.Array a) m r)
631−parseDToKGeneric pstep initial extract cont !offset0 !usedCount !input = do
631+adaptCGWith pstep initial extract cont !offset0 !usedCount !input = do
632 res <- initial
632 res <- initial
633 case res of
633 case res of
634 ParserD.IPartial pst -> do
634 ParserD.IPartial pst -> do
@@ -728,19 +728,19 @@ parseDToKGeneric pstep initial extract cont !offset0 !usedCount !input = do
728 -- XXX It is called only when there is no input arr. So using 0
728 -- XXX It is called only when there is no input arr. So using 0
729 -- as the position is correct?
729 -- as the position is correct?
730 cont (Failure 0 err) count None
730 cont (Failure 0 err) count None
731− ParserD.Partial _ _ -> error "Bug: parseDToKGeneric Partial unreachable"
731+ ParserD.Partial _ _ -> error "Bug: adaptCGWith Partial unreachable"
733 {-# INLINE parseCont #-}
733 {-# INLINE parseCont #-}
734 parseCont !cnt !pst (Chunk arr) = parseContChunk cnt 0 pst arr
734 parseCont !cnt !pst (Chunk arr) = parseContChunk cnt 0 pst arr
735 parseCont !cnt !pst None = parseContNothing cnt pst
735 parseCont !cnt !pst None = parseContNothing cnt pst
737−-- | Similar to "fromParser" but is not constrained.
737+-- | Similar to "adaptC" but is not constrained.
739−{-# INLINE_LATE fromParserGeneric #-}
739+{-# INLINE_LATE adaptCG #-}
740−fromParserGeneric ::
740+adaptCG ::
741 Monad m => ParserD.Parser a m b -> ParserK (GenArr.Array a) m b
741 Monad m => ParserD.Parser a m b -> ParserK (GenArr.Array a) m b
742−fromParserGeneric (ParserD.Parser step initial extract) =
742+adaptCG (ParserD.Parser step initial extract) =
743− MkParser $ parseDToKGeneric step initial extract
743+ MkParser $ adaptCGWith step initial extract
746-------------------------------------------------------------------------------
746-------------------------------------------------------------------------------