@@ -69,7 +69,7 @@ toSource :: Enumerator -> IO Source
69toSource (Enumerator e) = do
69toSource (Enumerator e) = do
70 buffer <- newEmptyMVar
70 buffer <- newEmptyMVar
71 _ <- forkIO $ e (helper buffer) () >> putMVar buffer Nothing
71 _ <- forkIO $ e (helper buffer) () >> putMVar buffer Nothing
72− return $ Source () $ source buffer
72+ return $ source buffer
74 helper :: MVar (Maybe B.ByteString)
74 helper :: MVar (Maybe B.ByteString)
@@ -78,9 +78,9 @@ toSource (Enumerator e) = do
78 helper buffer _ bs = do
78 helper buffer _ bs = do
79 putMVar buffer $ Just bs
79 putMVar buffer $ Just bs
80 return $ Right ()
80 return $ Right ()
81− source :: MVar (Maybe B.ByteString) -> ()
81+ source :: MVar (Maybe B.ByteString)
82− -> IO (Maybe (B.ByteString, ()))
82+ -> Source
83− source mmbs () = do
83+ source mmbs = Source $ do
84 mbs <- takeMVar mmbs
84 mbs <- takeMVar mmbs
85 case mbs of
85 case mbs of
86 Nothing -> do
86 Nothing -> do
@@ -88,7 +88,7 @@ toSource (Enumerator e) = do
88 -- again without causing a deadlock.
88 -- again without causing a deadlock.
89 putMVar mmbs Nothing
89 putMVar mmbs Nothing
90 return Nothing
90 return Nothing
91− Just bs -> return $ Just (bs, ())
91+ Just bs -> return $ Just (bs, source mmbs)
93-- | Read a chunk of data from the given 'Handle' at a time. We use
93-- | Read a chunk of data from the given 'Handle' at a time. We use
94-- 'defaultChunkSize' from the bytestring package to determine the largest
94-- 'defaultChunkSize' from the bytestring package to determine the largest