@@ -195,6 +195,8 @@ import Data.Bifunctor (first)
195195import Fusion.Plugin.Types (Fuse(..))
196196import Streamly.Internal.Data.Fold.Type (Fold(..))
197197import Streamly.Internal.Data.SVar.Type (defState)
198+import Streamly.Internal.Data.Either.Strict (Either'(..))
199+import Streamly.Internal.Data.Maybe.Strict (Maybe'(..))
198200import Streamly.Internal.Data.Tuple.Strict (Tuple'(..))
199201
200202import qualified Streamly.Internal.Data.Fold.Type as FL
@@ -639,7 +641,7 @@ takeWhile1 predicate (Fold fstep finitial fextract) =
639641 initial = do
640642 res <- finitial
641643 return $ case res of
642− FL.Partial s -> IPartial (Left s)
644+ FL.Partial s -> IPartial (Left' s)
643645 FL.Done _ ->
644646 IError
645647 $ "takeWhile1: fold terminated without consuming:"
@@ -650,22 +652,22 @@ takeWhile1 predicate (Fold fstep finitial fextract) =
650652 res <- fstep s a
651653 return
652654 $ case res of
653− FL.Partial s1 -> Partial 0 (Right s1)
655+ FL.Partial s1 -> Partial 0 (Right' s1)
654656 FL.Done b -> Done 0 b
655657
656− step (Left s) a =
658+ step (Left' s) a =
657659 if predicate a
658660 then process s a
659661 else return $ Error "takeWhile1: predicate failed on first element"
660− step (Right s) a =
662+ step (Right' s) a =
661663 if predicate a
662664 then process s a
663665 else do
664666 b <- fextract s
665667 return $ Done 1 b
666668
667− extract (Left _) = throwM $ ParseError "takeWhile1: end of input"
668− extract (Right s) = fextract s
669+ extract (Left' _) = throwM $ ParseError "takeWhile1: end of input"
670+ extract (Right' s) = fextract s
669671
670672-------------------------------------------------------------------------------
671673-- Separators
@@ -704,23 +706,23 @@ takeEndByEsc isEsc isSep (Parser pstep pinitial pextract) =
704706
705707 where
706708
707− initial = first Left <$> pinitial
709+ initial = first Left' <$> pinitial
708710
709− step (Left s) a = do
711+ step (Left' s) a = do
710712 if isEsc a
711− then return $ Partial 0 $ Right s
713+ then return $ Partial 0 $ Right' s
712714 else do
713715 res <- pstep s a
714716 if not (isSep a)
715− then return $ mapStateStep Left res
717+ then return $ mapStateStep Left' res
716718 else extractStep pextract res
717719
718− step (Right s) a = do
720+ step (Right' s) a = do
719721 res <- pstep s a
720− return $ mapStateStep Left res
722+ return $ mapStateStep Left' res
721723
722− extract (Left s) = pextract s
723− extract (Right _) =
724+ extract (Left' s) = pextract s
725+ extract (Right' _) =
724726 throwM $ ParseError "takeEndByEsc: trailing escape, end of input"
725727
726728-- | See 'Streamly.Internal.Data.Parser.takeEndBy_'.
@@ -749,7 +751,6 @@ takeEndBy_ cond (Parser pstep pinitial pextract) =
749751--
750752-- /Pre-release/
751753--
752−data SliceBeginWithState s = Left' s | Right' s
753754
754755{-# INLINE takeStartBy #-}
755756takeStartBy :: 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
10421043 initial = do
10431044 r <- sstep defState state
10441045 case r of
1045− D.Yield x s -> return $ IPartial (Just x, s)
1046+ D.Yield x s -> return $ IPartial (Just' x, s)
10461047 D.Stop -> return $ IDone ()
10471048 -- 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)
10491050
1050− step (Just x, st) a =
1051+ step (Just' x, st) a =
10511052 if x `cmp` a
10521053 then do
10531054 r <- sstep defState st
10541055 return
10551056 $ case r of
1056− D.Yield x1 s -> Continue 0 (Just x1, s)
1057+ D.Yield x1 s -> Continue 0 (Just' x1, s)
10571058 D.Stop -> Done 0 ()
1058− D.Skip s -> Continue 1 (Nothing, s)
1059+ D.Skip s -> Continue 1 (Nothing', s)
10591060 else return $ Error "match: mismtach occurred"
1060− step (Nothing, st) a = do
1061+ step (Nothing', st) a = do
10611062 r <- sstep defState st
10621063 return
10631064 $ case r of
10641065 D.Yield x s -> do
10651066 if x `cmp` a
1066− then Continue 0 (Nothing, s)
1067+ then Continue 0 (Nothing', s)
10671068 else Error "match: mismatch occurred"
10681069 D.Stop -> Done 1 ()
1069− D.Skip s -> Continue 1 (Nothing, s)
1070+ D.Skip s -> Continue 1 (Nothing', s)
10701071
10711072 extract _ = throwM $ ParseError "match: end of input"
10721073
@@ -1084,40 +1085,41 @@ zipWithM zf (D.Stream sstep state) (Fold fstep finitial fextract) =
10841085 FL.Partial fs -> do
10851086 r <- sstep defState state
10861087 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)
10881089 D.Stop -> do
10891090 x <- fextract fs
10901091 return $ IDone x
10911092 -- 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)
10931094 FL.Done x -> return $ IDone x
10941095
1095− step (Just a, st, fs) b = do
1096+ step (Just' a, st, fs) b = do
10961097 c <- zf a b
10971098 fres <- fstep fs c
10981099 case fres of
10991100 FL.Partial fs1 -> do
11001101 r <- sstep defState st
11011102 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)
11031104 D.Stop -> do
11041105 x <- fextract fs1
11051106 return $ Done 0 x
1106− D.Skip s -> return $ Continue 1 (Nothing, s, fs1)
1107+ D.Skip s -> return $ Continue 1 (Nothing', s, fs1)
11071108 FL.Done x -> return $ Done 0 x
1108− step (Nothing, st, fs) b = do
1109+ step (Nothing', st, fs) b = do
11091110 r <- sstep defState st
11101111 case r of
11111112 D.Yield a s -> do
11121113 c <- zf a b
11131114 fres <- fstep fs c
11141115 case fres of
1115− FL.Partial fs1 -> return $ Continue 0 (Nothing, s, fs1)
1116+ FL.Partial fs1 ->
1117+ return $ Continue 0 (Nothing', s, fs1)
11161118 FL.Done x -> return $ Done 0 x
11171119 D.Stop -> do
11181120 x <- fextract fs
11191121 return $ Done 1 x
1120− D.Skip s -> return $ Continue 1 (Nothing, s, fs)
1122+ D.Skip s -> return $ Continue 1 (Nothing', s, fs)
11211123
11221124 extract _ = throwM $ ParseError "zipWithM: end of input"
11231125
@@ -1319,8 +1321,8 @@ lookAhead (Parser step1 initial1 _) = Parser step initial extract
13191321-------------------------------------------------------------------------------
13201322
13211323data DeintercalateState fs sp ss =
1322− DeintercalateL fs sp
1323− | DeintercalateR fs ss Bool
1324+ DeintercalateL !fs !sp
1325+ | DeintercalateR !fs !ss !Bool
13241326
13251327-- | See 'Streamly.Internal.Data.Parser.deintercalate'.
13261328--
@@ -1407,8 +1409,8 @@ deintercalate
14071409 FL.Done c -> return c
14081410
14091411data SepByState fs sp ss =
1410− SepByInit fs sp
1411− | SepBySeparator fs ss Bool
1412+ SepByInit !fs !sp
1413+ | SepBySeparator !fs !ss !Bool
14121414
14131415-- This is a special case of deintercalate and can be easily implemented in
14141416-- terms of deintercalate.