我一直在使用attoparsec
写了以下分析代码:转换正常attoparsec解析器代码到管道/管
data Test = Test {
a :: Int,
b :: Int
} deriving (Show)
testParser :: Parser Test
testParser = do
a <- decimal
tab
b <- decimal
return $ Test a b
tParser :: Parser [Test]
tParser = many' $ testParser <* endOfLine
这正常为小大小的文件,我执行这样的:
main :: IO()
main = do
text <- TL.readFile "./testFile"
let (Right a) = parseOnly (manyTill anyChar endOfLine *> tParser) text
print a
但是,当文件大小大于70MB时,会消耗大量内存。作为解决方案,我认为我会使用attoparsec-conduit
。通过他们的API后,我不知道如何让他们一起工作。我的解析器的类型为Parser Test
,但它的实际接受的解析器类型为sinkParser
。我对如何在常量内存中执行这个解析器感兴趣? (基于甲管溶液也可以接受,但我不用于将管道API。)