haskell - 如何将 `readfile` 函数的输出变成管道的源?

标签 haskell conduit haskell-pipes

我正在通过以下方式打开一些 .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]< 的形式

最佳答案

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

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

关于haskell - 如何将 `readfile` 函数的输出变成管道的源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38863636/

相关文章:

haskell - 无限循环 Haskell

haskell - 为什么在 Haskell 中显式推导 Show/Read?

haskell - 管道广播

haskell - 具有下游状态且无损失的惯用双向管道

haskell - 连接管道与返回不同值的消费者和生产者

haskell - 使用 Yesod 和 Persistent 的类型不匹配

json - Haskell 导管 Aeson : Parsing Large JSONs and filter matching key/values

windows - Windows 8 上的 "InternalIOException getAddrInfo: does not exist (error 10093)"

Haskell Pipes - 获取管道中最后一个代理的返回值

haskell - 当我的 getter 和 setter 返回 `Either` 时,我可以构建类似镜头的东西吗?