[Haskell-cafe] Wai and http-enumerator not as lazy as I'd like

Erik de Castro Lopo mle+hs at mega-nerd.com
Tue Apr 26 14:27:46 CEST 2011


Hi all,

I'm using Wai and http-enumerator to build a http proxy. The core of
the code looks like this:

    import qualified Network.HTTP.Enumerator     as HE
    import qualified Network.Wai                 as Wai

    serveRequest :: forall (m :: * -> *).
             (MonadControlIO m, Failure HE.HttpException m) =>
             HE.Request m -> m Wai.Response
    serveRequest request
     = do   HE.Response sc rh bs <- HE.withManager $ HE.httpLbsRedirect request
            return $ Wai.responseLBS (mkStatus sc) rh bs

This works but does not run in constant space as I would have hoped.
The thing is, HE.httpLbsRedirect returns a lazy ByteString and
Wai.responseLBS writes a lazy ByteString, so why isn't the whole thing
lazy?

I'd appreciate any clues.

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



More information about the Haskell-Cafe mailing list