I'm trying to parse a very large XML file, so I've hooked up tagsoup to 
create a minimalistic streaming XML parser.

The following Parser I've been using to do a little bit of cleanup, but 
when I introduce it into the pipeline with parseForever_ the last element 
disappears.

textCombiner :: (Monad m) => PP.Parser TTag m (Maybe TTag)
textCombiner = do
  first   <- PP.draw
  second  <- PP.peek
  case (first, second) of
    (Just firstTag@(TS.TagText firstText), (Just secondTag@(TS.TagOpen _ 
_))) -> trace "1" $ if T.all (== ' ') firstText then PP.draw >> return 
(Just secondTag) else return (Just firstTag)
    (Just (TS.TagText firstText), Just (TS.TagText secondText))             
  -> trace "2" $ PP.draw >> (return $ Just $ TS.TagText $ append firstText 
secondText)
    (Just firstTag, _)                                                     
   -> trace "3" $ return (Just firstTag)
    (Nothing, _)                                                           
   -> trace "4" $ return Nothing 

With a TagOpen, TagText and then TagClose test combination I see the trace 
"3" twice and only the TagOpen and TagText elements make it through the 
pipeline.

Originally this code used draw twice, but I changed the second one to use 
peek as I thought that might make a difference, but nothing has changed.

What do I do?
Sean.

-- 
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 haskell-pipes+unsubscr...@googlegroups.com.
To post to this group, send email to haskell-pipes@googlegroups.com.

Reply via email to