Search code examples
haskellconduithaskell-pipes

How do you make the output of a `readfile` function into source for conduit?


I am opening some .txt file via:

main :: IO ()
main = do
  xxs  <- TIO.readFile pathToFile
  return ()

The .txt file is of form

str_1 \n str_2 \n ... str_m

And I would like to make xxs into a source so that it might look like:

sourceList [str_1, str_2, ..., str_m]

Does the conduit API provide a way to do it without doing some string manipulation on xxs first, thus making it into the form [str_1, str_2, ..., str_m]?


Solution

  • How do you make the output of a readfile function into source for conduit?

    The source function for reading files already exists in the package conduit-extra in the form of sourceFile. You can also see various other combinators in that module like conduitFile, etc.