@@ -195,6 +195,8 @@ import Data.Bifunctor (first)
195import Fusion.Plugin.Types (Fuse(..))
195import Fusion.Plugin.Types (Fuse(..))
196import Streamly.Internal.Data.Fold.Type (Fold(..))
196import Streamly.Internal.Data.Fold.Type (Fold(..))
197import Streamly.Internal.Data.SVar.Type (defState)
197import Streamly.Internal.Data.SVar.Type (defState)
198+import Streamly.Internal.Data.Either.Strict (Either'(..))
199+import Streamly.Internal.Data.Maybe.Strict (Maybe'(..))
198import Streamly.Internal.Data.Tuple.Strict (Tuple'(..))
200import Streamly.Internal.Data.Tuple.Strict (Tuple'(..))
200import qualified Streamly.Internal.Data.Fold.Type as FL
202import qualified Streamly.Internal.Data.Fold.Type as FL
@@ -639,7 +641,7 @@ takeWhile1 predicate (Fold fstep finitial fextract) =
639 initial = do
641 initial = do
640 res <- finitial
642 res <- finitial
641 return $ case res of
643 return $ case res of
642− FL.Partial s -> IPartial (Left s)
644+ FL.Partial s -> IPartial (Left' s)
643 FL.Done _ ->
645 FL.Done _ ->
645 $ "takeWhile1: fold terminated without consuming:"
647 $ "takeWhile1: fold terminated without consuming:"
@@ -650,22 +652,22 @@ takeWhile1 predicate (Fold fstep finitial fextract) =
650 res <- fstep s a
652 res <- fstep s a
652 $ case res of
654 $ case res of
653− FL.Partial s1 -> Partial 0 (Right s1)
655+ FL.Partial s1 -> Partial 0 (Right' s1)
654 FL.Done b -> Done 0 b
656 FL.Done b -> Done 0 b
656− step (Left s) a =
658+ step (Left' s) a =
657 if predicate a
659 if predicate a
658 then process s a
660 then process s a
659 else return $ Error "takeWhile1: predicate failed on first element"
661 else return $ Error "takeWhile1: predicate failed on first element"
660− step (Right s) a =
662+ step (Right' s) a =
661 if predicate a
663 if predicate a
662 then process s a
664 then process s a
664 b <- fextract s
666 b <- fextract s
665 return $ Done 1 b
667 return $ Done 1 b
667− extract (Left _) = throwM $ ParseError "takeWhile1: end of input"
669+ extract (Left' _) = throwM $ ParseError "takeWhile1: end of input"
668− extract (Right s) = fextract s
670+ extract (Right' s) = fextract s
670-------------------------------------------------------------------------------
672-------------------------------------------------------------------------------
671-- Separators
673-- Separators
@@ -704,23 +706,23 @@ takeEndByEsc isEsc isSep (Parser pstep pinitial pextract) =
707− initial = first Left <$> pinitial
709+ initial = first Left' <$> pinitial
709− step (Left s) a = do
711+ step (Left' s) a = do
710 if isEsc a
712 if isEsc a
711− then return $ Partial 0 $ Right s
713+ then return $ Partial 0 $ Right' s
713 res <- pstep s a
715 res <- pstep s a
714 if not (isSep a)
716 if not (isSep a)
715− then return $ mapStateStep Left res
717+ then return $ mapStateStep Left' res
716 else extractStep pextract res
718 else extractStep pextract res
718− step (Right s) a = do
720+ step (Right' s) a = do
719 res <- pstep s a
721 res <- pstep s a
720− return $ mapStateStep Left res
722+ return $ mapStateStep Left' res
722− extract (Left s) = pextract s
724+ extract (Left' s) = pextract s
723− extract (Right _) =
725+ extract (Right' _) =
724 throwM $ ParseError "takeEndByEsc: trailing escape, end of input"
726 throwM $ ParseError "takeEndByEsc: trailing escape, end of input"
726-- | See 'Streamly.Internal.Data.Parser.takeEndBy_'.
728-- | See 'Streamly.Internal.Data.Parser.takeEndBy_'.
@@ -749,7 +751,6 @@ takeEndBy_ cond (Parser pstep pinitial pextract) =
750-- /Pre-release/
752-- /Pre-release/
752−data SliceBeginWithState s = Left' s | Right' s
754{-# INLINE takeStartBy #-}
755{-# INLINE takeStartBy #-}
755takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
756takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
@@ -1042,31 +1043,31 @@ matchBy cmp (D.Stream sstep state) = Parser step initial extract
1042 initial = do
1043 initial = do
1043 r <- sstep defState state
1044 r <- sstep defState state
1044 case r of
1045 case r of
1045− D.Yield x s -> return $ IPartial (Just x, s)
1046+ D.Yield x s -> return $ IPartial (Just' x, s)
1046 D.Stop -> return $ IDone ()
1047 D.Stop -> return $ IDone ()
1047 -- Need Skip/Continue in initial to loop right here
1048 -- Need Skip/Continue in initial to loop right here
1048− D.Skip s -> return $ IPartial (Nothing, s)
1049+ D.Skip s -> return $ IPartial (Nothing', s)
1050− step (Just x, st) a =
1051+ step (Just' x, st) a =
1051 if x `cmp` a
1052 if x `cmp` a
1053 r <- sstep defState st
1054 r <- sstep defState st
1055 $ case r of
1056 $ case r of
1056− D.Yield x1 s -> Continue 0 (Just x1, s)
1057+ D.Yield x1 s -> Continue 0 (Just' x1, s)
1057 D.Stop -> Done 0 ()
1058 D.Stop -> Done 0 ()
1058− D.Skip s -> Continue 1 (Nothing, s)
1059+ D.Skip s -> Continue 1 (Nothing', s)
1059 else return $ Error "match: mismtach occurred"
1060 else return $ Error "match: mismtach occurred"
1060− step (Nothing, st) a = do
1061+ step (Nothing', st) a = do
1061 r <- sstep defState st
1062 r <- sstep defState st
1063 $ case r of
1064 $ case r of
1064 D.Yield x s -> do
1065 D.Yield x s -> do
1065 if x `cmp` a
1066 if x `cmp` a
1066− then Continue 0 (Nothing, s)
1067+ then Continue 0 (Nothing', s)
1067 else Error "match: mismatch occurred"
1068 else Error "match: mismatch occurred"
1068 D.Stop -> Done 1 ()
1069 D.Stop -> Done 1 ()
1069− D.Skip s -> Continue 1 (Nothing, s)
1070+ D.Skip s -> Continue 1 (Nothing', s)
1071 extract _ = throwM $ ParseError "match: end of input"
1072 extract _ = throwM $ ParseError "match: end of input"
@@ -1084,40 +1085,41 @@ zipWithM zf (D.Stream sstep state) (Fold fstep finitial fextract) =
1084 FL.Partial fs -> do
1085 FL.Partial fs -> do
1085 r <- sstep defState state
1086 r <- sstep defState state
1086 case r of
1087 case r of
1087− D.Yield x s -> return $ IPartial (Just x, s, fs)
1088+ D.Yield x s -> return $ IPartial (Just' x, s, fs)
1088 D.Stop -> do
1089 D.Stop -> do
1089 x <- fextract fs
1090 x <- fextract fs
1090 return $ IDone x
1091 return $ IDone x
1091 -- Need Skip/Continue in initial to loop right here
1092 -- Need Skip/Continue in initial to loop right here
1092− D.Skip s -> return $ IPartial (Nothing, s, fs)
1093+ D.Skip s -> return $ IPartial (Nothing', s, fs)
1093 FL.Done x -> return $ IDone x
1094 FL.Done x -> return $ IDone x
1095− step (Just a, st, fs) b = do
1096+ step (Just' a, st, fs) b = do
1096 c <- zf a b
1097 c <- zf a b
1097 fres <- fstep fs c
1098 fres <- fstep fs c
1098 case fres of
1099 case fres of
1099 FL.Partial fs1 -> do
1100 FL.Partial fs1 -> do
1100 r <- sstep defState st
1101 r <- sstep defState st
1101 case r of
1102 case r of
1102− D.Yield x1 s -> return $ Continue 0 (Just x1, s, fs1)
1103+ D.Yield x1 s -> return $ Continue 0 (Just' x1, s, fs1)
1103 D.Stop -> do
1104 D.Stop -> do
1104 x <- fextract fs1
1105 x <- fextract fs1
1105 return $ Done 0 x
1106 return $ Done 0 x
1106− D.Skip s -> return $ Continue 1 (Nothing, s, fs1)
1107+ D.Skip s -> return $ Continue 1 (Nothing', s, fs1)
1107 FL.Done x -> return $ Done 0 x
1108 FL.Done x -> return $ Done 0 x
1108− step (Nothing, st, fs) b = do
1109+ step (Nothing', st, fs) b = do
1109 r <- sstep defState st
1110 r <- sstep defState st
1110 case r of
1111 case r of
1111 D.Yield a s -> do
1112 D.Yield a s -> do
1112 c <- zf a b
1113 c <- zf a b
1113 fres <- fstep fs c
1114 fres <- fstep fs c
1114 case fres of
1115 case fres of
1115− FL.Partial fs1 -> return $ Continue 0 (Nothing, s, fs1)
1117+ return $ Continue 0 (Nothing', s, fs1)
1116 FL.Done x -> return $ Done 0 x
1118 FL.Done x -> return $ Done 0 x
1117 D.Stop -> do
1119 D.Stop -> do
1118 x <- fextract fs
1120 x <- fextract fs
1119 return $ Done 1 x
1121 return $ Done 1 x
1120− D.Skip s -> return $ Continue 1 (Nothing, s, fs)
1122+ D.Skip s -> return $ Continue 1 (Nothing', s, fs)
1122 extract _ = throwM $ ParseError "zipWithM: end of input"
1124 extract _ = throwM $ ParseError "zipWithM: end of input"
@@ -1319,8 +1321,8 @@ lookAhead (Parser step1 initial1 _) = Parser step initial extract
1319-------------------------------------------------------------------------------
1321-------------------------------------------------------------------------------
1321data DeintercalateState fs sp ss =
1323data DeintercalateState fs sp ss =
1322− DeintercalateL fs sp
1324+ DeintercalateL !fs !sp
1323− | DeintercalateR fs ss Bool
1325+ | DeintercalateR !fs !ss !Bool
1325-- | See 'Streamly.Internal.Data.Parser.deintercalate'.
1327-- | See 'Streamly.Internal.Data.Parser.deintercalate'.
@@ -1407,8 +1409,8 @@ deintercalate
1407 FL.Done c -> return c
1409 FL.Done c -> return c
1409data SepByState fs sp ss =
1411data SepByState fs sp ss =
1410− SepByInit fs sp
1412+ SepByInit !fs !sp
1411− | SepBySeparator fs ss Bool
1413+ | SepBySeparator !fs !ss !Bool
1413-- This is a special case of deintercalate and can be easily implemented in
1415-- This is a special case of deintercalate and can be easily implemented in
1414-- terms of deintercalate.
1416-- terms of deintercalate.