|
DebuggingA few words on debugging. One thing you can do is put debugFilter before the serverPartT that seems to be causing trouble. This will spit out the request and response objects, which can be helpful. *Main> :i debugFilter
I personally don't use debugFilter much, as it gives almost too much information. Instead, I depend on Debug.Trace.trace (a standard library function which sneaks IO in anywhere you have a showable value), which I augmented with some helper functions (in Misc.hs). traceTrue x = trace (show x ++ "nn") True
Typical (basically only) use of traceTrue: view arguments to a function in stdout, by putting it on the right side of the "execute this branch if true" bar in a function definition. The function executes as it normally would, because traceTrue always returns true, but you get debugging info as a side effect. tutlayout (RenderGlobals ts mbU) attrs tmpl0 | traceTrue ((RenderGlobals ts mbU), attrs, tmpl0) = ..... Typical use of traceIt: quickie print to stdout of some var or expression: mainUserMenu = if (isJust mbU)
traceMsg does pretty much the same thing as traceIt, except you preface the shown expression with your own message like "show the menu: ". This can be useful if you are doing more than one trace and need to distinguish them. There are probably smarter ways of debugging a happs app; the above is just what works for me. (Actually, I debug using these trace helpers all the time, not just in Happstack.) If I get useful feedback on how other Happstack users approach debugging I will update this page. Incidentally, ghci has a debugger since 6.8.3. Overall it's great, but I didn't find it too useful for Happstack, because it would die out on me in ways I didn't understand, typically around hard to understand exceptions. Basically, Happstack would behave differently when I was stepping through it with the ghci debugger than it would when running without the debugger. I suspect it's because the ghci debugger lacks support for multithreaded programs, or something along those lines. At any rate, I wound up not using the interactive debugger much, though I would have liked to. Now, on to the pragmatic matter of form data. |