Permalink
Browse files

Malte's fix to bug in 'callback' function

  • Loading branch information...
1 parent cb787ee commit cc4bcabf0d2a65037cf8775f761eaa0a3f33d8e6 @tanimoto tanimoto committed Mar 13, 2011
Showing with 6 additions and 6 deletions.
  1. +6 −6 Codec/Zlib/Enum.hs
View
12 Codec/Zlib/Enum.hs
@@ -57,13 +57,13 @@ compress level config step0 = do
callback :: MonadIO m =>
(Stream a -> Iteratee a m b) -> IO (Maybe a) -> m (Step a m b)
-callback k pop = maybe done more =<< liftIO pop
+callback k pop = runIteratee . k . Chunks =<< liftIO (go id)
where
- done = return (Continue k)
- more y = do step <- runIteratee (k (Chunks [y]))
- case step of
- Continue k' -> callback k' pop
- other -> return other
+ go front = do
+ x <- pop
+ case x of
+ Nothing -> return $ front []
+ Just y -> go (front . (:) y)
-- testInflate = do
-- h <- openBinaryFile "test-out" WriteMode

0 comments on commit cc4bcab

Please sign in to comment.