git.iko.soy/typeable/attoparsec
on master help sign in
peekChar/peekWord8: Return Nothing at end-of-input
464f095Johan Tibell
Data/Attoparsec/ByteString/Internal.hs+8−7
@@ -407,13 +407,14 @@ notWord8 c = satisfy (/= c) <?> "not " ++ show c
407-- combinators such as 'many', because such parsers loop until a
407-- combinators such as 'many', because such parsers loop until a
408-- failure occurs. Careless use will thus result in an infinite loop.
408-- failure occurs. Careless use will thus result in an infinite loop.
409peekWord8 :: Parser (Maybe Word8)
409peekWord8 :: Parser (Maybe Word8)
410−peekWord8 = T.Parser $ \i0 a0 m0 _kf ks ->
410+peekWord8 = T.Parser $ \i0 a0 m0 _kf ks -> case m0 of
411+ Complete -> ks i0 a0 m0 Nothing
411− let ks' i a m = let w = B.unsafeHead (unI i)
412+ Incomplete -> let ks' i a m = let w = B.unsafeHead (unI i)
412− in w `seq` ks i a m (Just w)
413+ in w `seq` ks i a m (Just w)
413− kf' i a m = ks i a m Nothing
414+ kf' i a m = ks i a m Nothing
414− in if B.null (unI i0)
415+ in if B.null (unI i0)
415− then prompt i0 a0 m0 kf' ks'
416+ then prompt i0 a0 m0 kf' ks'
416− else ks' i0 a0 m0
417+ else ks' i0 a0 m0
417{-# INLINE peekWord8 #-}
418{-# INLINE peekWord8 #-}
418
419
419-- | Match only if all input has been consumed.
420-- | Match only if all input has been consumed.
Data/Attoparsec/Text/Internal.hs+8−7
@@ -410,13 +410,14 @@ notChar c = satisfy (/= c) <?> "not " ++ show c
410-- combinators such as 'many', because such parsers loop until a
410-- combinators such as 'many', because such parsers loop until a
411-- failure occurs. Careless use will thus result in an infinite loop.
411-- failure occurs. Careless use will thus result in an infinite loop.
412peekChar :: Parser (Maybe Char)
412peekChar :: Parser (Maybe Char)
413−peekChar = T.Parser $ \i0 a0 m0 _kf ks ->
413+peekChar = T.Parser $ \i0 a0 m0 _kf ks -> case m0 of
414+ Complete -> ks i0 a0 m0 Nothing
414− let ks' i a m = let w = unsafeHead (unI i)
415+ Incomplete -> let ks' i a m = let w = unsafeHead (unI i)
415− in w `seq` ks i a m (Just w)
416+ in w `seq` ks i a m (Just w)
416− kf' i a m = ks i a m Nothing
417+ kf' i a m = ks i a m Nothing
417− in if T.null (unI i0)
418+ in if T.null (unI i0)
418− then prompt i0 a0 m0 kf' ks'
419+ then prompt i0 a0 m0 kf' ks'
419− else ks' i0 a0 m0
420+ else ks' i0 a0 m0
420{-# INLINE peekChar #-}
421{-# INLINE peekChar #-}
421
422
422-- | Match only if all input has been consumed.
423-- | Match only if all input has been consumed.
tests/QC.hs+1
@@ -1,3 +1,4 @@
1+{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
1module Main (main) where
2module Main (main) where
2
3
3import qualified QC.ByteString as ByteString
4import qualified QC.ByteString as ByteString
tests/QC/ByteString.hs+1−1
@@ -1,5 +1,5 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2−{-# OPTIONS_GHC -fno-warn-orphans #-}
2+{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-orphans #-}
3module QC.ByteString (tests) where
3module QC.ByteString (tests) where
4
4
5import Control.Applicative ((<$>), (<*>))
5import Control.Applicative ((<$>), (<*>))
tests/QC/Text.hs+1−1
@@ -1,5 +1,5 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2−{-# OPTIONS_GHC -fno-warn-orphans #-}
2+{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-orphans #-}
3module QC.Text (tests) where
3module QC.Text (tests) where
4
4
5import Control.Applicative ((<$>), (<*>))
5import Control.Applicative ((<$>), (<*>))