git.iko.soy/typeable/attoparsec
on master help sign in
Drop the redundant takeWith function
14ea384Bryan O'Sullivan
Data/Attoparsec/ByteString/Internal.hs+4−11
@@ -139,19 +139,12 @@ storable = hack undefined
139 return . inlinePerformIO . withForeignPtr fp $ \p ->
139 return . inlinePerformIO . withForeignPtr fp $ \p ->
140 peek (castPtr $ p `plusPtr` o)
140 peek (castPtr $ p `plusPtr` o)
141
141
142−-- | Consume @n@ bytes of input, but succeed only if the predicate
143−-- returns 'True'.
144−takeWith :: Int -> (ByteString -> Bool) -> Parser ByteString
145−takeWith n0 p = do
146− let n = max n0 0
147− s <- ensure n
148− if p s
149− then advance n >> return s
150− else fail "takeWith"
151−
152-- | Consume exactly @n@ bytes of input.
142-- | Consume exactly @n@ bytes of input.
153take :: Int -> Parser ByteString
143take :: Int -> Parser ByteString
154−take n = takeWith n (const True)
144+take n0 = do
145+ let n = max n0 0
146+ s <- ensure n
147+ advance n >> return s
155{-# INLINE take #-}
148{-# INLINE take #-}
156
149
157-- | @string s@ parses a sequence of bytes that identically match
150-- | @string s@ parses a sequence of bytes that identically match