@@ -25,6 +25,7 @@ import Data.Csv hiding (Parser, decodeWith, decodeByNameWith)
2525import Data.Csv.Incremental
2626import Data.Either (lefts, rights)
2727import Data.IORef
28+import Data.List (intercalate)
2829import System.IO.Streams (InputStream, makeInputStream)
2930import qualified System.IO.Streams as Streams
3031
@@ -102,15 +103,13 @@ dispatch queueRef parserRef input = do
102103 where
103104 -- Send more data to the CSV parser. If there is no more data
104105 -- from upstream then send an empty @ByteString@.
105− more f = do
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
108107
109108 -- Feed more data downstream or fail if some records didn't parse
110109 -- correctly. The elements are wrapped in an @Either@ which
111110 -- indicates decoding failures.
112111 feed xs = if not $ null (lefts xs)
113− then bomb $ concat (lefts xs)
112+ then bomb $ intercalate "\n" (lefts xs)
114113 else writeIORef queueRef (rights xs) >>
115114 dispatch queueRef parserRef input
116115