--- iteratee-0.3.1/src/Data/Iteratee/Base.hs.orig	2009-11-09 20:40:29.000000000 +0200
+++ iteratee-0.3.1/src/Data/Iteratee/Base.hs	2010-01-14 15:02:23.617234593 +0200
@@ -466,21 +466,20 @@
 -- stream of the read elements. Unless the stream is terminated early, we
 -- read exactly n elements (even if the iteratee has accepted fewer).
 take :: (SC.StreamChunk s el, Monad m) =>
-  Int ->
-  EnumeratorN s el s el m a
+  Int -> EnumeratorN s el s el m a
 take 0 iter = return iter
-take n' iter = IterateeG (step n')
+take n iter = IterateeG step
   where
-  step n chk@(Chunk str)
-    | SC.null str = return $ Cont (take n iter) Nothing
-    | SC.length str < n = liftM (flip Cont Nothing) inner
-      where inner = liftM (check (n - SC.length str)) (runIter iter chk)
-  step n (Chunk str) = done (Chunk s1) (Chunk s2)
-    where (s1, s2) = SC.splitAt n str
-  step _n stream            = done stream stream
-  check n (Done x _)        = drop n >> return (return x)
-  check n (Cont x Nothing)  = take n x
-  check n (Cont _ (Just e)) = drop n >> throwErr e
+  step s@(Chunk str)
+    | LL.null str       = return $ Cont (take n iter) Nothing
+    | LL.length str < n = liftM (flip Cont Nothing) inner
+      where inner = check (n - LL.length str) `liftM` runIter iter s
+  step (Chunk str) = done (Chunk s1) (Chunk s2)
+    where (s1, s2) = LL.splitAt n str
+  step str = done str str
+  check n' (Done x _)        = drop n' >> return (return x)
+  check n' (Cont x Nothing)  = take n' x
+  check n' (Cont _ (Just e)) = drop n' >> throwErr e
   done s1 s2 = liftM (flip Done s2) (runIter iter s1 >>= checkIfDone return)
 
 
@@ -491,20 +490,18 @@
 -- of processing of the outer stream once the processing of the inner stream
 -- finished early.
 takeR :: (SC.StreamChunk s el, Monad m) =>
-  Int ->
-  IterateeG s el m a ->
-  IterateeG s el m (IterateeG s el m a)
+  Int -> EnumeratorN s el s el m a
 takeR 0 iter = return iter
-takeR n iter = IterateeG (step n)
+takeR n iter = IterateeG step
   where
-  step n' s@(Chunk str)
+  step s@(Chunk str)
     | LL.null str        = return $ Cont (takeR n iter) Nothing
     | LL.length str <= n = runIter iter s >>= check (n - LL.length str)
     | otherwise          = done (Chunk str1) (Chunk str2)
-      where (str1, str2) = LL.splitAt n' str
-  step _n str            = done str str
-  check _n' (Done a str)   = return $ Done (return a) str
-  check n'  (Cont k mErr)  = return $ Cont (takeR n' k) mErr
+      where (str1, str2) = LL.splitAt n str
+  step str = done str str
+  check _ (Done a str)   = return $ Done (return a) str
+  check n' (Cont k mErr) = return $ Cont (takeR n' k) mErr
   done s1 s2 = liftM (flip Done s2) (runIter iter s1 >>= checkIfDone return)
 
 
