My  goal is to parse a big text-file line by line using the same parser for every line.

I am new to Conduit and I’ve read this https://www.fpcomplete.com/user/chad/snippets/random-code-snippets/folding-lines-in-conduit  article.

 

After adding import  Control.Monad.Trans.Resource for runResourceT and adding rankNTypes, I got it working.

Code in www.tbsoftware.nl/TestConduit/TestConduit7.hs

 

I don't understand what is going on in myFunc. Does CL.fold fold over the already read lines?

I wonder whether CL.fold loads the whole file in memory?

 

if I change

            count <- CL.fold (\count t -> count + T.length t) 0 to

            count <- CL.fold (\count t -> T.length t) 0        

nothing changes in the output.  If count is always zero, why using a fold?

 

How can I get the ‘current line’ in myFunc?

 

Kees