[web-devel] Hoogle Advice

Michael Snoyman michael at snoyman.com
Tue Jan 25 21:58:58 CET 2011

On Tue, Jan 25, 2011 at 10:52 PM, Neil Mitchell <ndmitchell at gmail.com> wrote:
> Hi,
> On feature requests for Warp, I have only two outstanding requests:
> 1) A way of finding how long a response took to generate.
> 2) A way of finding out when exceptions happen.
> Can either of these be achieved with middleware, or Response
> transformers? I thought the timing one could probably be done by
> consuming all the Response output, and then as a final action at the
> end writing to an MVar or a Chan, which some other thread could read
> from to see the time elapsed. Is that possible? It seems feasible...

Are you talking about timing how long it takes to *generate* a
response, or how long it takes to *send* a response? The latter would
require changes to Warp which I do not want to make for the moment.
The former would require forcing evaluation of your response body,
which will kill any lazy IO advantages you have. However, it should be
implementable at the application/middleware level.

> I couldn't think of any way of displaying exceptions though, so
> perhaps allow runEx which takes an exception handler:
> runEx :: Port -> Application -> (Request -> SomeException -> IO ()) -> IO ()
> Is there any other way to robustly get all exceptions?

See the other email I just sent; I added a function runOnException.
However, I think runEx is a nicer name, so I'm going to steal it. As
for the requested type signature (including a Request): it's not
really feasible at the Warp level: the exceptions Warp will be
catching are not necessarily part of a request, it could be in the
middle of receiving a request, a timeout in between one response and
the next request, etc. If you want the Request information, you'll
need to implement that as a middleware.

> Regarding Jeremy's points about using Happstack, I originally
> considered Happs for use in Hoogle many years ago. Then I came to the
> conclusion that just installing Happs was too much pain (this was the
> days before cabal install), and I wouldn't get enough payoff. All the
> things you describe about setting cookies, transforming output etc.
> aren't things that Hoogle yet does, so I still think the payoff is
> still too small. If Hoogle gets more features, I'll evaluate once
> more. I certainly don't consider Happstack to be sewerage :-)
> Thanks, Neil

More information about the web-devel mailing list