[Haskell-cafe] Conduit and foldLines

Kees Bleijenberg K.Bleijenberg at lijbrandt.nl
Mon Sep 7 10:04:55 UTC 2015


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-l
ines-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

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150907/d6467209/attachment.html>


More information about the Haskell-Cafe mailing list