[Haskell-cafe] An example of enumerator processing some data between input and output

Paul Sujkov psujkov at gmail.com
Tue Apr 19 19:10:11 CEST 2011


Hi haskellers,

I played a bit with the enumerator package, and I'm quite stuck with the
question how to duplex data to two (or more) consumers using combinators
from xml-enumerator (for example) package. What I mean is:

main = withFile "out.xml" WriteMode $ \h ->
       parseFile "in.xml" decodeEntities $
       (joinI $ renderText $$ iterHandle h) >> (force "data required"
parseData)

where parseData is a simple xml-enumerator parser. Combining consumers in
such a way I can get text being output to the file "out.xml" (like in the
example given) or parsed with parseData (if I switch the order of the
consumers), but not both. Can anybody tell me how to make a pipe (input ->
process -> output) to have text both parsed and then put back to the file?
While pretty straightforward with the arrow approach, it doesn't seem
obvious to me with the iteratees :(

-- 
Regards, Paul Sujkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110419/2f4b3c2c/attachment.htm>


More information about the Haskell-Cafe mailing list