@@ -70,9 +70,13 @@ module Streamly.Internal.Data.Parser
7070 -- * Element parsers
7171 , peek
7272 , one
73+ , next
74+ , element
75+ , except
76+ , oneOf
77+ , noneOf
7378 , eof
7479 , satisfy
75− , next
7680 , maybe
7781 , either
7882
@@ -396,13 +400,62 @@ satisfy = D.toParserK . D.satisfy
396400-- | Consume one element from the head of the stream. Fails if it encounters
397401-- end of input.
398402--
399−-- >>> one = satisfy $ const True
403+-- >>> one = Parser.satisfy $ const True
400404--
401405-- /Pre-release/
402406--
407+{-# INLINE one #-}
403408one :: MonadCatch m => Parser m a a
404409one = satisfy $ const True
405410
411+-- | Match a specific element.
412+--
413+-- >>> element x = Parser.satisfy (== x)
414+--
415+{-# INLINE element #-}
416+element :: (MonadCatch m, Eq a) => a -> Parser m a a
417+element x = satisfy (== x)
418+
419+-- | Match anything other than the supplied element.
420+--
421+-- >>> except x = Parser.satisfy (/= x)
422+--
423+{-# INLINE except #-}
424+except :: (MonadCatch m, Eq a) => a -> Parser m a a
425+except x = satisfy (/= x)
426+
427+-- | Match any one of the elements in the supplied list.
428+--
429+-- >>> oneOf xs = Parser.satisfy (`elem` xs)
430+--
431+-- When performance matters a pattern matching predicate could be more
432+-- efficient than a list:
433+--
434+-- @
435+-- let p x =
436+-- case x of
437+-- 'a' -> True
438+-- 'e' -> True
439+-- _ -> False
440+-- in satisfy p
441+-- @
442+--
443+-- GHC may use a binary search instead of linear search in the list.
444+-- Alternatively, you can also use an array instead of list for storage and
445+-- search.
446+--
447+{-# INLINE oneOf #-}
448+oneOf :: (MonadCatch m, Eq a) => [a] -> Parser m a a
449+oneOf xs = satisfy (`elem` xs)
450+
451+-- | See performance notes in 'oneOf'.
452+--
453+-- >>> noneOf xs = Parser.satisfy (`notElem` xs)
454+--
455+{-# INLINE noneOf #-}
456+noneOf :: (MonadCatch m, Eq a) => [a] -> Parser m a a
457+noneOf xs = satisfy (`notElem` xs)
458+
406459-- | Return the next element of the input. Returns 'Nothing'
407460-- on end of input. Also known as 'head'.
408461--