git.iko.soy/typeable/attoparsec
on master help sign in
Document parseOnly not forcing consumption of all input (gh-59)

--HG-- extra : amend_source : bc5bcf11f4926e2e337e78f5492dfd22fe726a07

commitdebb1978cab15db70f0b32f887fdc34a2c9af254 authorBryan O'Sullivan <bos@serpentine.com> dateThu 29 May 2014, 00:41 (12 years ago) parentb6a4c1e
2 files changed+16
Data/Attoparsec/ByteString/Internal.hs+8 Data/Attoparsec/Text/Internal.hs+8
Data/Attoparsec/ByteString/Internal.hs+8
@@ -418,6 +418,14 @@ parse m s = T.runParser m (buffer s) (Pos 0) Incomplete failK successK
418418{-# INLINE parse #-}
419419
420420-- | Run a parser that cannot be resupplied via a 'Partial' result.
421+--
422+-- This function does not force a parser to consume all of its input.
423+-- Instead, any residual input will be discarded. To force a parser
424+-- to consume all of its input, use something like this:
425+--
426+-- @
427+--'parseOnly' (myParser 'Control.Applicative.<*' 'endOfInput')
428+-- @
421429parseOnly :: Parser a -> ByteString -> Either String a
422430parseOnly m s = case T.runParser m (buffer s) (Pos 0) Complete failK successK of
423431 Fail _ _ err -> Left err
Data/Attoparsec/Text/Internal.hs+8
@@ -427,6 +427,14 @@ parse m s = runParser m (buffer s) 0 Incomplete failK successK
427427{-# INLINE parse #-}
428428
429429-- | Run a parser that cannot be resupplied via a 'Partial' result.
430+--
431+-- This function does not force a parser to consume all of its input.
432+-- Instead, any residual input will be discarded. To force a parser
433+-- to consume all of its input, use something like this:
434+--
435+-- @
436+--'parseOnly' (myParser 'Control.Applicative.<*' 'endOfInput')
437+-- @
430438parseOnly :: Parser a -> Text -> Either String a
431439parseOnly m s = case runParser m (buffer s) 0 Complete failK successK of
432440 Fail _ _ err -> Left err