@@ -33,6 +33,7 @@ module Data.Attoparsec.ByteString.Lazy
3333 , eitherResult
3434 ) where
3535
36+import Control.DeepSeq (NFData(rnf))
3637import Data.ByteString.Lazy.Internal (ByteString(..), chunk)
3738import qualified Data.ByteString as B
3839import qualified Data.Attoparsec.ByteString as A
@@ -53,6 +54,16 @@ data Result r = Fail ByteString [String] String
5354 -- input that had not yet been consumed (if any) when
5455 -- the parse succeeded.
5556
57+instance NFData r => NFData (Result r) where
58+ rnf (Fail bs ctxs msg) = rnfBS bs `seq` rnf ctxs `seq` rnf msg
59+ rnf (Done bs r) = rnfBS bs `seq` rnf r
60+ {-# INLINE rnf #-}
61+
62+rnfBS :: ByteString -> ()
63+rnfBS (Chunk _ xs) = rnfBS xs
64+rnfBS Empty = ()
65+{-# INLINE rnfBS #-}
66+
5667instance Show r => Show (Result r) where
5768 show (Fail bs stk msg) =
5869 "Fail " ++ show bs ++ " " ++ show stk ++ " " ++ show msg