@@ -78,6 +78,8 @@ module Streamly.Internal.Data.Parser.ParserD
7878 -- ** Exact match
7979 , listEq
8080 , listEqBy
81+ , chunkEq
82+ , chunkEqBy
8183 , streamEqBy
8284 , subsequenceBy
8385
@@ -2203,6 +2205,37 @@ streamEqBy cmp stream = streamEqByInternal cmp stream *> fromPure ()
22032205listEq :: (Monad m, Eq a) => [a] -> Parser a m [a]
22042206listEq = listEqBy (==)
22052207
2208+-- | Match the given sequence of elements using the given comparison function.
2209+-- Returns the original sequence if successful.
2210+--
2211+-- Definition:
2212+--
2213+-- >>> chunkEqBy cmp xs = Parser.streamEqBy cmp (Stream.fromFoldable xs) *> Parser.fromPure xs
2214+--
2215+-- Examples:
2216+--
2217+-- >>> Stream.parse (Parser.chunkEqBy (==) "string") $ Stream.fromList "string"
2218+-- Right "string"
2219+--
2220+-- >>> Stream.parse (Parser.chunkEqBy (==) "mismatch") $ Stream.fromList "match"
2221+-- Left (ParseError "streamEqBy: mismtach occurred")
2222+--
2223+{-# INLINE chunkEqBy #-}
2224+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
2227+
2228+-- | Match the input sequence with the supplied Foldable and return it if
2229+-- successful.
2230+--
2231+-- >>> chunkEq = Parser.chunkEqBy (==)
2232+--
2233+{-# INLINE chunkEq #-}
2234+chunkEq
2235+ :: (Eq a, Foldable f, Monad m)
2236+ => f a -> Parser a m (f a)
2237+chunkEq = chunkEqBy (==)
2238+
22062239-- | Match if the input stream is a subsequence of the argument stream i.e. all
22072240-- the elements of the input stream occur, in order, in the argument stream.
22082241-- The elements do not have to occur consecutively. A sequence is considered a