@@ -126,6 +126,8 @@ module Streamly.Internal.Data.Parser.ParserD.Types
126 , splitMany -- parseMany?
126 , splitMany -- parseMany?
128 , concatMap
128 , concatMap
130+ , noErrorUnsafeSplitWith
@@ -325,6 +327,41 @@ splitWith func (Parser stepL initialL extractL)
325 rR <- extractR sR
327 rR <- extractR sR
326 return $ func rL rR
328 return $ func rL rR
330+-- Only use this if you know what you're doing
331+{-# INLINE noErrorUnsafeSplitWith #-}
332+noErrorUnsafeSplitWith :: Monad m
333+ => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
334+noErrorUnsafeSplitWith func (Parser stepL initialL extractL)
335+ (Parser stepR initialR extractR) =
336+ Parser step initial extract
340+ initial = SeqParseL <$> initialL
342+ step (SeqParseL st) a = do
345+ Partial n s -> return $ Partial n (SeqParseL s)
346+ Continue n s -> return $ Partial n (SeqParseL s)
347+ Done n b -> Partial n <$> (SeqParseR (func b) <$> initialR)
348+ Error err -> return $ Error err
350+ step (SeqParseR f st) a = do
353+ Partial n s -> Partial n (SeqParseR f s)
354+ Continue n s -> Partial n (SeqParseR f s)
355+ Done n b -> Done n (f b)
356+ Error err -> Error err
358+ extract (SeqParseR f sR) = fmap f (extractR sR)
359+ extract (SeqParseL sL) = do
328{-# ANN type SeqAState Fuse #-}
365{-# ANN type SeqAState Fuse #-}
329data SeqAState sl sr = SeqAL sl | SeqAR sr
366data SeqAState sl sr = SeqAL sl | SeqAR sr