[web-devel] Single step debugging a yesod application

Nubis nubis at woobiz.com.ar
Wed Nov 3 15:48:05 CET 2010


Hi guys,
As I said in another thread, I've been debugging a yesod application single
stepping through one of the handlers. I'm using ghci built in debugger and
it's pretty good, but I always fail to set the breakpoint in the right scope
where I can evaluate the stuff I'm interested in learning more about.
For instance, in the following code I would like to set the debugger on the
line before "mv <- maybeAuth", in order to :force the values  of (uid, u).
But even when I set it at the beginnig of the 'mv' line, the scope ends up
being the entire do block. Which makes sense, but doesn't helpe me solve my
problem :)

getUserR :: String -> Handler RepHtmlJson
getUserR input = do
    (uid, u) <-
        case readIntegral input of
            Just uid -> debugRunDB $ do
                u <- get404 uid
                mun <- getBy $ UniqueUsernameUser uid
                case mun of
                    Nothing -> return (uid, u)
                    Just (_, Username _ un) ->
                        lift $ redirect RedirectPermanent $ UserR un
            Nothing -> debugRunDB $ do
                mun <- getBy $ UniqueUsername input
                case mun of
                    Nothing -> lift notFound
                    Just (_, Username uid _) -> do
                        u <- get404 uid
                        return (uid, u)
    mv <- maybeAuth


Maybe the problem is that I'm thinking in a too procedural fashion about do
blocks, or that evaluating those results is kind of paranoid. I'm too
spoiled by REPL's, I would even like to be able to use a REPL that runs
inside runDB for querying models and doing stuff with them interactively.

How do you debug your yesod apps? am I drifting too far away from the
haskell way?

thanks in advance for your comments :)

cheers
----nubis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/web-devel/attachments/20101103/0284e6fa/attachment.html


More information about the web-devel mailing list