This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap-core".

The branch, master has been updated
       via  ec8dc2bcc812b696bbae143bda4eb5175c3d8572 (commit)
      from  79247a9980e38ff1de368aba267d4733e093fc77 (commit)


Summary of changes:
 src/Snap/Internal/Iteratee/Debug.hs |   38 +++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 2 deletions(-)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ec8dc2bcc812b696bbae143bda4eb5175c3d8572
Author: Gregory Collins <[email protected]>
Date:   Mon Jul 12 18:38:55 2010 -0400

    Add iterateeDebugWrapper

diff --git a/src/Snap/Internal/Iteratee/Debug.hs 
b/src/Snap/Internal/Iteratee/Debug.hs
index e20fc09..759bc0f 100644
--- a/src/Snap/Internal/Iteratee/Debug.hs
+++ b/src/Snap/Internal/Iteratee/Debug.hs
@@ -4,15 +4,21 @@
 -- depends on it.
 
 {-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleInstances #-}
 
-module Snap.Internal.Iteratee.Debug ( debugIteratee ) where
+
+module Snap.Internal.Iteratee.Debug
+  ( debugIteratee
+  , iterateeDebugWrapper
+  ) where
 
 ------------------------------------------------------------------------------
 import           Data.Iteratee.WrappedByteString
 import           Data.Word (Word8)
 import           System.IO
 ------------------------------------------------------------------------------
+import           Snap.Internal.Debug
 import           Snap.Iteratee
 ------------------------------------------------------------------------------
 
@@ -27,7 +33,7 @@ debugIteratee :: Iteratee IO ()
 debugIteratee = IterateeG f
   where
     f c@(EOF _) = do
-        putStrLn $ "got chunk: " ++ show c
+        putStrLn $ "got EOF: " ++ show c
         hFlush stdout
         return (Done () c)
 
@@ -35,3 +41,31 @@ debugIteratee = IterateeG f
         putStrLn $ "got chunk: " ++ show c
         hFlush stdout
         return $ Cont debugIteratee Nothing
+
+
+#if defined(DEBUG)
+
+iterateeDebugWrapper :: String -> Iteratee IO a -> Iteratee IO a
+iterateeDebugWrapper name iter = IterateeG f
+  where
+    f c@(EOF _) = do
+        debug $ name ++ ": got EOF: " ++ show c
+        runIter iter c
+
+    f c@(Chunk _) = do
+        debug $ name ++ ": got chunk: " ++ show c
+        wrapResult $ runIter iter c
+
+    wrapResult m = do
+        iv <- m
+        let i = liftI iv
+
+        return $ Cont (iterateeDebugWrapper name i) Nothing
+
+#else
+
+iterateeDebugWrapper :: String -> Iteratee IO a -> Iteratee IO a
+iterateeDebugWrapper _ = id
+{-# INLINE iterateeDebugWrapper #-}
+
+#endif
-----------------------------------------------------------------------


hooks/post-receive
-- 
snap-core
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to