@@ -70,9 +70,13 @@ module Streamly.Internal.Data.Parser
70 -- * Element parsers
70 -- * Element parsers
@@ -396,13 +400,62 @@ satisfy = D.toParserK . D.satisfy
396-- | Consume one element from the head of the stream. Fails if it encounters
400-- | Consume one element from the head of the stream. Fails if it encounters
397-- end of input.
401-- end of input.
399−-- >>> one = satisfy $ const True
403+-- >>> one = Parser.satisfy $ const True
401-- /Pre-release/
405-- /Pre-release/
403one :: MonadCatch m => Parser m a a
408one :: MonadCatch m => Parser m a a
404one = satisfy $ const True
409one = satisfy $ const True
411+-- | Match a specific element.
413+-- >>> element x = Parser.satisfy (== x)
415+{-# INLINE element #-}
416+element :: (MonadCatch m, Eq a) => a -> Parser m a a
417+element x = satisfy (== x)
419+-- | Match anything other than the supplied element.
421+-- >>> except x = Parser.satisfy (/= x)
423+{-# INLINE except #-}
424+except :: (MonadCatch m, Eq a) => a -> Parser m a a
425+except x = satisfy (/= x)
427+-- | Match any one of the elements in the supplied list.
429+-- >>> oneOf xs = Parser.satisfy (`elem` xs)
431+-- When performance matters a pattern matching predicate could be more
432+-- efficient than a list:
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
448+oneOf :: (MonadCatch m, Eq a) => [a] -> Parser m a a
449+oneOf xs = satisfy (`elem` xs)
451+-- | See performance notes in 'oneOf'.
453+-- >>> noneOf xs = Parser.satisfy (`notElem` xs)
455+{-# INLINE noneOf #-}
456+noneOf :: (MonadCatch m, Eq a) => [a] -> Parser m a a
457+noneOf xs = satisfy (`notElem` xs)
406-- | Return the next element of the input. Returns 'Nothing'
459-- | Return the next element of the input. Returns 'Nothing'
407-- on end of input. Also known as 'head'.
460-- on end of input. Also known as 'head'.