on master help sign in
Add parser to consume one element from the stream
d08d73aHarendra Kumar
core/src/Streamly/Internal/Data/Parser.hs+11
@@ -69,6 +69,7 @@ module Streamly.Internal.Data.Parser
69
69
70 -- * Element parsers
70 -- * Element parsers
71 , peek
71 , peek
72+ , one
72 , eof
73 , eof
73 , satisfy
74 , satisfy
74 , next
75 , next
@@ -392,6 +393,16 @@ eof = D.toParserK D.eof
392satisfy :: MonadCatch m => (a -> Bool) -> Parser m a a
393satisfy :: MonadCatch m => (a -> Bool) -> Parser m a a
393satisfy = D.toParserK . D.satisfy
394satisfy = D.toParserK . D.satisfy
394
395
396+-- | Consume one element from the head of the stream. Fails if it encounters
397+-- end of input.
398+--
399+-- >>> one = satisfy $ const True
400+--
401+-- /Pre-release/
402+--
403+one :: MonadCatch m => Parser m a a
404+one = satisfy $ const True
405+
395-- | Return the next element of the input. Returns 'Nothing'
406-- | Return the next element of the input. Returns 'Nothing'
396-- on end of input. Also known as 'head'.
407-- on end of input. Also known as 'head'.
397--
408--