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, blaze-builder has been updated
via 1d1c0a134a185c1d01d4923fddabdb1e523f6006 (commit)
via 8ba8f064fa0828b9b1c81da3192465412216119e (commit)
from 371e3a3c19638fb6a466395090ae39686de6261d (commit)
Summary of changes:
snap-core.cabal | 1 -
src/Snap/Internal/Http/Types.hs | 7 ++--
src/Snap/Internal/Types.hs | 2 +-
src/Snap/Iteratee.hs | 64 +++++++++++++++++++++++++++-----------
src/Snap/Util/GZip.hs | 4 +-
5 files changed, 52 insertions(+), 26 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 1d1c0a134a185c1d01d4923fddabdb1e523f6006
Author: Gregory Collins <[email protected]>
Date: Mon Dec 27 11:43:56 2010 +0100
Tweak iteratee/enumerator map types
diff --git a/src/Snap/Internal/Http/Types.hs b/src/Snap/Internal/Http/Types.hs
index cdce09f..fc1a8f4 100644
--- a/src/Snap/Internal/Http/Types.hs
+++ b/src/Snap/Internal/Http/Types.hs
@@ -372,9 +372,10 @@ rspBodyMap f b = Enum $ f $ rspBodyToEnum b
------------------------------------------------------------------------------
rspBodyToEnum :: ResponseBody -> Enumerator Builder IO a
rspBodyToEnum (Enum e) = e
-rspBodyToEnum (SendFile fp Nothing) = I.mapEnum fromByteString $ I.enumFile fp
-rspBodyToEnum (SendFile fp (Just s)) = I.mapEnum fromByteString $
- I.enumFilePartial fp s
+rspBodyToEnum (SendFile fp Nothing) =
+ I.mapEnum toByteString fromByteString $ I.enumFile fp
+rspBodyToEnum (SendFile fp (Just s)) =
+ I.mapEnum toByteString fromByteString $ I.enumFilePartial fp s
------------------------------------------------------------------------------
diff --git a/src/Snap/Internal/Types.hs b/src/Snap/Internal/Types.hs
index ec5216a..6d1acfd 100644
--- a/src/Snap/Internal/Types.hs
+++ b/src/Snap/Internal/Types.hs
@@ -251,7 +251,7 @@ transformRequestBody trans = do
let ioref = rqBody req
senum <- liftIO $ readIORef ioref
let (SomeEnumerator enum') = senum
- let enum = mapEnum fromByteString enum'
+ let enum = mapEnum toByteString fromByteString enum'
liftIO $ writeIORef ioref (SomeEnumerator enumEOF)
origRsp <- getResponse
diff --git a/src/Snap/Iteratee.hs b/src/Snap/Iteratee.hs
index 13de58c..97d2bc7 100644
--- a/src/Snap/Iteratee.hs
+++ b/src/Snap/Iteratee.hs
@@ -641,29 +641,55 @@ enumFilePartial fp rng@(start,end) st@(Continue k) = do
------------------------------------------------------------------------------
+mapEnum :: (Monad m) =>
+ (aOut -> aIn)
+ -> (aIn -> aOut)
+ -> Enumerator aIn m a
+ -> Enumerator aOut m a
+mapEnum f g enum outStep = do
+ let z = I.map g outStep
+ let p = joinI z
+ let q = enum $$ p
+ (I.joinI . I.map f) $$ q
+
+
+------------------------------------------------------------------------------
mapIter :: (Monad m) =>
(aOut -> aIn)
- -> Iteratee aOut m a
+ -> (aIn -> aOut)
-> Iteratee aIn m a
-mapIter f iter = iter >>== check
+ -> Iteratee aOut m a
+mapIter f g iter = do
+ step <- lift $ runIteratee iter
+ mapStep step
where
- check (Continue k) = k EOF >>== \s -> case s of
- Continue _ -> error "divergent iteratee"
- _ -> check s
- check (Yield x rest) = yield x (fmap f rest)
- check (Error e) = throwError e
+ -- mapStep :: Step aIn m a -> Iteratee aOut m a
+ mapStep (Continue k) = continue $ wrapK k
+ mapStep (Yield x rest) = yield x (fmap g rest)
+ mapStep (Error e) = throwError e
+
+ -- wrapK :: (Stream aIn -> Iteratee aIn m a)
+ -- -> (Stream aOut -> Iteratee aOut m a)
+ wrapK k streamOut = mapIter f g iterIn
+ where
+ streamIn = fmap f streamOut
+ iterIn = k streamIn
------------------------------------------------------------------------------
-mapEnum :: (Monad m) =>
- (aOut -> aIn)
- -> Enumerator aOut m a
- -> Enumerator aIn m a
-mapEnum f enum builderStep = do
- -- z :: Iteratee ByteString m (Step Builder m a)
- let z = I.map f builderStep
- -- p :: Iteratee ByteString m a
- let p = joinI z
- -- q :: Iteratee ByteString m a
- let q = enum $$ p
- mapIter f q
+-- testIt :: IO ()
+-- testIt = do
+-- xs <- run_ (eInt $$ consume)
+-- putStrLn (show xs)
+
+-- ys <- run_ (eInt $$ replicateM 3 iter1)
+-- putStrLn (show ys)
+
+-- where
+-- eBS :: Enumerator ByteString IO a
+-- eBS = enumList 1 ["12345", "300", "200", "400"]
+
+-- eInt :: Enumerator Int IO a
+-- eInt = mapEnum (S.pack . show) (read . S.unpack) eBS
+
+-- iter1 = mapIter (S.pack . show) (read . S.unpack) I.head
diff --git a/src/Snap/Util/GZip.hs b/src/Snap/Util/GZip.hs
index ad109b0..a97e03f 100644
--- a/src/Snap/Util/GZip.hs
+++ b/src/Snap/Util/GZip.hs
@@ -180,9 +180,9 @@ compressEnumerator compFunc enum' origStep = do
readEnd <- liftIO $ newChan
tid <- liftIO $ forkIO $ threadProc readEnd writeEnd
- let enum = mapEnum toByteString enum'
+ let enum = mapEnum fromByteString toByteString enum'
let outEnum = enum (f readEnd writeEnd tid step)
- mapIter fromByteString outEnum
+ mapIter toByteString fromByteString outEnum
where
--------------------------------------------------------------------------
commit 8ba8f064fa0828b9b1c81da3192465412216119e
Author: Gregory Collins <[email protected]>
Date: Sun Dec 26 19:10:06 2010 +0100
Remove cereal dep
diff --git a/snap-core.cabal b/snap-core.cabal
index a010117..c26ed9e 100644
--- a/snap-core.cabal
+++ b/snap-core.cabal
@@ -144,7 +144,6 @@ Library
blaze-builder >= 0.2.1 && <0.3,
bytestring,
bytestring-nums,
- cereal >= 0.3 && < 0.4,
containers,
deepseq >= 1.1 && <1.2,
directory,
-----------------------------------------------------------------------
hooks/post-receive
--
snap-core
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap