On Thu, Mar 13, 2014 at 3:41 PM, Kai Wang <[email protected]> wrote: > Hi: > > Suppose I have a Bytestring producer, I want to use > pipes-attoparsec/binary/etc to parse this producer, and send the result to a > pipes-concurrent output mailbox. What's the idiomatic to achieve this > result? Is using "parse :: A.Parser a b -> P.Parser a m (Either ParsingError > b)" (from pipes-attoparsec) the correct approach for this situation? or > should I stick with "parsed :: A.Parser a b -> P.Producer a m r -> > P.Producer b m (Either (ParsingError P.Producer a m r) r)" (also from > pipes-attoparsec)
Kai, It depends on the contents of your original `ByteString` producer and on how you want to deal with parsing errors. If your original `ByteString` producer contains consecutive raw entries that can be parsed with nothing else in between them, then `Pipes.Attoparsec.parsed` will work; you'll just have to take care of matching the `Either (ParsingError, Producer a m r) r` return type from this new producer with the other `Proxy`s in your pipeline. For example, `pipes-concurrency`'s `toOutput`'s return value is incompatible with said return type, but you could use `Pipes.Lift.errorP` to reconcile them. Otherwise, if your original `ByteString` producer contains additional content in between each raw entry or you want to deal with parsing errors locally, then you should rely on `Pipes.Attoparsec.parse` and the infrastructure provided by `pipes-parse. Regards, Renzo Carbonara. -- You received this message because you are subscribed to the Google Groups "Haskell Pipes" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
