@@ -25,6 +25,7 @@ import Data.Csv hiding (Parser, decodeWith, decodeByNameWith)
25import Data.Csv.Incremental
25import Data.Csv.Incremental
26import Data.Either (lefts, rights)
26import Data.Either (lefts, rights)
27import Data.IORef
27import Data.IORef
28+import Data.List (intercalate)
28import System.IO.Streams (InputStream, makeInputStream)
29import System.IO.Streams (InputStream, makeInputStream)
29import qualified System.IO.Streams as Streams
30import qualified System.IO.Streams as Streams
@@ -102,15 +103,13 @@ dispatch queueRef parserRef input = do
103 -- Send more data to the CSV parser. If there is no more data
104 -- Send more data to the CSV parser. If there is no more data
104 -- from upstream then send an empty @ByteString@.
105 -- from upstream then send an empty @ByteString@.
106− bytes <- Streams.read input
107− writeIORef parserRef (maybe (f BS.empty) f bytes)
106+ more f = Streams.read input >>= writeIORef parserRef . maybe (f BS.empty) f
109 -- Feed more data downstream or fail if some records didn't parse
108 -- Feed more data downstream or fail if some records didn't parse
110 -- correctly. The elements are wrapped in an @Either@ which
109 -- correctly. The elements are wrapped in an @Either@ which
111 -- indicates decoding failures.
110 -- indicates decoding failures.
112 feed xs = if not $ null (lefts xs)
111 feed xs = if not $ null (lefts xs)
113− then bomb $ concat (lefts xs)
112+ then bomb $ intercalate "\n" (lefts xs)
114 else writeIORef queueRef (rights xs) >>
113 else writeIORef queueRef (rights xs) >>
115 dispatch queueRef parserRef input
114 dispatch queueRef parserRef input