Attoparsec 具有专门用于 Strict/Lazy、ByteString/Text、Char8 (ascii)/Char 的模块。但它没有所有的组合。
我认为Data.Attoparsec.ByteString.Lazy.Char8
未提供的内容对于浏览倾向于编码为 ascii 的大型报告特别方便。
你知道它为什么不存在吗?
Attoparsec 具有专门用于 Strict/Lazy、ByteString/Text、Char8 (ascii)/Char 的模块。但它没有所有的组合。
我认为Data.Attoparsec.ByteString.Lazy.Char8
未提供的内容对于浏览倾向于编码为 ascii 的大型报告特别方便。
你知道它为什么不存在吗?
我认为这不是必需的,因为这两个模块似乎没有相互重叠。
Data.Attoparsec.ByteString.Char8
提供专门用于解析 ASCII 数据的额外解析器。这些只是它们Word8
对应物的变体,并且它们使用相同的底层 monad,因此您应该能够毫无问题地混合和匹配。
Data.Attoparsec.ByteString.Lazy
提供了一个替代parse
函数,可用于针对惰性字节串运行解析器。这在任何方面都不是特别的,它只是严格版本的包装器,迭代地将惰性块的块推ByteString
入你的解析器。
据我所知,你没有理由不能同时使用它们。例如:
import Data.ByteString.Lazy
import qualified Data.Attoparsec.ByteString.Char8 as Char8
import qualified Data.Attoparsec.ByteString.Lazy as Lazy
myParser :: Char8.Parser T
myParser = -- use parsers from Char8 if you'd like
lazyParse :: Char8.Parser T -> ByteString -> Lazy.Result T
lazyParse p s = Lazy.parse p s -- parse a lazy ByteString
您使用组合器 fromChar8
来定义您的解析器,然后您使用函数 fromLazy
来运行它。所以不需要Data.Attoparsec.ByteString.Lazy.Char8
.