如何将`readfile`函数的输出转换为管道的源?

chi*_*ro2 2 haskell conduit haskell-pipes

我通过以下方式打开一些.txt文件:

main :: IO ()
main = do
  xxs  <- TIO.readFile pathToFile
  return ()
Run Code Online (Sandbox Code Playgroud)

.txt文件的格式

str_1 \n str_2 \n ... str_m
Run Code Online (Sandbox Code Playgroud)

我想将xxs变成一个源代码,以便它看起来像:

sourceList [str_1, str_2, ..., str_m]
Run Code Online (Sandbox Code Playgroud)

管道API是否提供了一种方法来实现它而不首先进行一些字符串操作xxs,从而使其成为形式[str_1, str_2, ..., str_m]

Sib*_*ibi 5

如何将readfile函数的输出转换为管道的源?

用于读取文件的源函数已经以sourceFile的形式存在于包管道中.您还可以在该模块中看到各种其他组合器,例如等.conduitFile