@@ -34,6 +34,7 @@ module Data.Attoparsec.ByteString.Buffer
3434import Control.Exception (assert)
3535import Data.Attoparsec.ByteString.Fhthagn (inlinePerformIO)
3636import Data.ByteString.Internal (ByteString(..), memcpy, nullForeignPtr)
37+import Data.List (foldl1')
3738import Data.Monoid (Monoid(..))
3839import Data.Word (Word8)
3940import Foreign.ForeignPtr (ForeignPtr, withForeignPtr)
@@ -84,6 +85,9 @@ instance Monoid Buffer where
8485 memcpy (ptr `plusPtr` len0) (ptr1 `plusPtr` off1) len1
8586 return (Buf fp 0 newlen newcap)
8687
88+ mconcat [] = mempty
89+ mconcat xs = foldl1' mappend xs
90+
8791length :: Buffer -> Int
8892length (Buf _ _ len _) = len
8993{-# INLINE length #-}