Skip to content

Commit

Permalink
Old bytestring doesn't have NFData instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbe committed Feb 26, 2013
1 parent 50f2e53 commit f5e9c01
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Data/Csv/Streaming.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ import qualified Data.Csv.Incremental as I
import Data.Csv.Parser
import Data.Csv.Types

#if !MIN_VERSION_bytestring(0,10,0)
import qualified Data.ByteString.Lazy.Internal as BL -- for constructors
#endif

-- $example
--
-- A short usage example:
Expand Down Expand Up @@ -119,7 +123,15 @@ instance Traversable Records where

instance NFData a => NFData (Records a) where
rnf (Cons r rs) = rnf r `seq` rnf rs
#if MIN_VERSION_bytestring(0,10,0)
rnf (Nil errMsg rest) = rnf errMsg `seq` rnf rest
#else
rnf (Nil errMsg rest) = rnf errMsg `seq` rnfLazyByteString rest

rnfLazyByteString :: BL.ByteString -> ()
rnfLazyByteString BL.Empty = ()
rnfLazyByteString (BL.Chunk _ b) = rnfLazyByteString b
#endif

-- | Efficiently deserialize CSV records in a streaming fashion.
-- Equivalent to @'decodeWith' 'defaultDecodeOptions'@.
Expand Down

0 comments on commit f5e9c01

Please sign in to comment.