Permalink
Browse files

Modify finalChunk to return an empty stream when the parser is done, …

…and has consumed all of the input.
  • Loading branch information...
Grant Monroe
Grant Monroe committed Nov 16, 2010
1 parent aef7910 commit 9cd399da0133d9b0072ccbc8e32db97d065c48ca
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/Data/Attoparsec/Iteratee.hs
@@ -39,8 +39,11 @@ parserToIteratee p = IterateeG $ f (\s -> parse p s)
return $ Cont (error $ show m)
(Just $ Err m)
- finalChunk (Atto.Done rest r) =
- return $ Done r (Chunk $ toWrap $ L.fromChunks [rest])
+ finalChunk (Atto.Done rest r)
+ | S.null rest =
+ return $ Done r (EOF Nothing)
+ | otherwise =
+ return $ Done r (Chunk $ toWrap $ L.fromChunks [rest])
finalChunk (Atto.Partial _) =
return $ Cont (error "parser did not produce a value")

0 comments on commit 9cd399d

Please sign in to comment.