Read from file and output one line at a time
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource
import Data.Conduit
import qualified Data.Conduit.Binary as CB
import qualified Data.Conduit.List as CL
import qualified Data.Conduit.Text as CT
main :: IO ()
main = runResourceT
$ CB.sourceFile "tester.Rmd"
$$ CT.decode CT.utf8
=$ CT.lines
=$ CL.mapM_ (\t -> liftIO $ putStrLn $ "Got a line: " ++ show t)
{- output
Got a line: "% latex table generated in R 3.2.1 by xtable 1.7-4 package"
Got a line: "% Mon Nov 9 21:01:01 2015"
Got a line: "\\begin{table}[ht]"
Got a line: "\\centering"
Got a line: "\\begin{tabular}{rrrrr}"
Got a line: " \\hline"
Got a line: " & Disputed & Firearm & Knife & No \\\\ "
Got a line: " \\hline"
Got a line: "Death in custody & 0.00 & 0.00 & 0.00 & 3.86 \\\\ "
Got a line: " Gunshot & 0.30 & 47.92 & 14.24 & 9.50 \\\\ "
Got a line: " Struck by vehicle & 0.00 & 0.15 & 0.00 & 3.26 \\\\ "
Got a line: " Taser & 0.00 & 0.00 & 0.15 & 4.60 \\\\ "
Got a line: " Unknown & 0.00 & 0.00 & 0.00 & 0.45 \\\\ "
Got a line: " Sum & 0.30 & 48.07 & 14.39 & 21.66 \\\\ "
Got a line: " \\hline"
Got a line: "\\end{tabular}"
Got a line: "\\caption{Causes of 674 civilian deaths by type of weapon carried by civilian, part 1} "
Got a line: "\\label{2}"
Got a line: "\\end{table}"
-}