Reputation: 2481
I decided to try and get a handle on conduit, and I thought I was doing well, but when I try to make this simple source with conduit 4, I get an infinite loop and I don't understand why. This is simplified, the original version would create a temporary file name and return it via yield. This just returns a ().
import Control.Monad.IO.Class
import Data.Conduit
import Data.Conduit.List as CL
tempfiles :: MonadIO m => Source m ()
tempfiles = loop
where
loop = do
x <- liftIO $ print "tempfile"
yield x
loop
If I run:
runResourceT $ (tempfiles $$ CL.take 5)
I get an infinite loop. Why doesn't it just run five times and give me a list of five ()s?
Upvotes: 4
Views: 238
Reputation: 31305
In conduit 0.4, yield does not perform auto-termination. This is an important change in the 0.5 release; your code works as expected there.
Upvotes: 4