【发布时间】:2015-05-23 01:44:32
【问题描述】:
假设我有一个文本由 Jade 式括号分隔的文档,例如 {{foo}}。我编写了一个 Attoparsec 解析器,它似乎可以正确提取 foo:
findFoos :: Parser [T.Text]
findFoos = many $ do
manyTill anyChar (string "{{")
manyTill letter (string "}}")
测试表明它可以工作:
> parseOnly findFoos "{{foo}}"
Right ["foo"]
> parseOnly findFoos "{{foo}} "
Right ["foo"]
现在,使用conduit-extra 中的Data.Conduit.Attoparsec 模块,我似乎遇到了奇怪的行为:
> yield "{{foo}}" $= (mapOutput snd $ CA.conduitParser findFoos) $$ CL.mapM_ print
["foo"]
> yield "{{foo}} " $= (mapOutput snd $ CA.conduitParser findFoos) $$ CL.mapM_ print
-- floods stdout with empty lists
这是期望的行为吗?我应该在这里使用导管实用程序吗?对此的任何帮助都将是巨大的!
【问题讨论】:
标签: haskell conduit attoparsec