@@ -78,6 +78,8 @@ module Streamly.Internal.Data.Parser.ParserD
78 -- ** Exact match
78 -- ** Exact match
80 , listEqBy
80 , listEqBy
81 , streamEqBy
83 , streamEqBy
82 , subsequenceBy
84 , subsequenceBy
@@ -2203,6 +2205,37 @@ streamEqBy cmp stream = streamEqByInternal cmp stream *> fromPure ()
2203listEq :: (Monad m, Eq a) => [a] -> Parser a m [a]
2205listEq :: (Monad m, Eq a) => [a] -> Parser a m [a]
2204listEq = listEqBy (==)
2206listEq = listEqBy (==)
2208+-- | Match the given sequence of elements using the given comparison function.
2209+-- Returns the original sequence if successful.
2213+-- >>> chunkEqBy cmp xs = Parser.streamEqBy cmp (Stream.fromFoldable xs) *> Parser.fromPure xs
2217+-- >>> Stream.parse (Parser.chunkEqBy (==) "string") $ Stream.fromList "string"
2220+-- >>> Stream.parse (Parser.chunkEqBy (==) "mismatch") $ Stream.fromList "match"
2221+-- Left (ParseError "streamEqBy: mismtach occurred")
2223+{-# INLINE chunkEqBy #-}
2225+ :: (Foldable f, Monad m) => (a -> a -> Bool) -> f a -> Parser a m (f a)
2226+chunkEqBy cmp xs = streamEqByInternal cmp (D.fromFoldable xs) *> fromPure xs
2228+-- | Match the input sequence with the supplied Foldable and return it if
2231+-- >>> chunkEq = Parser.chunkEqBy (==)
2233+{-# INLINE chunkEq #-}
2235+ :: (Eq a, Foldable f, Monad m)
2236+ => f a -> Parser a m (f a)
2237+chunkEq = chunkEqBy (==)
2206-- | Match if the input stream is a subsequence of the argument stream i.e. all
2239-- | Match if the input stream is a subsequence of the argument stream i.e. all
2207-- the elements of the input stream occur, in order, in the argument stream.
2240-- the elements of the input stream occur, in order, in the argument stream.
2208-- The elements do not have to occur consecutively. A sequence is considered a
2241-- The elements do not have to occur consecutively. A sequence is considered a