2

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

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

.txt 文件的格式为

str_1 \n str_2 \n ... str_m

我想把 xxs 变成一个源代码,这样它可能看起来像:

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

管道 API 是否提供了一种方法来做到这一点,而无需先进行一些字符串操作xxs,从而使其成为表单[str_1, str_2, ..., str_m]

4

1 回答 1

5

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

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

于 2016-08-10T04:33:32.323 回答