One way to do it would be (explanation below):
getHomeR :: Handler Html
getHomeR = do
muid <- maybeAuthId
m <- case muid of
Nothing -> return Nothing
Just i -> runDB $ get i
defaultLayout $ do
[whamlet|
<p>Welcome!
$maybe user <- m
<p>
Welcome #{userIdent user}<br>
<a href=@{AuthR LogoutR}>Logout
$nothing
<p>
<a href=@{AuthR LoginR}>Go to the login page
|]
This way, we make a Maybe User out of m, and parse that in our template file.
Notice the $maybe user <- m
, this (roughly) translates to
case m of
Just user -> do
-- Do stuff with user, which is now of type User (and not Maybe User)
Nothing -> do
--Do stuff if m was nothing
So it's better not to wildcard your $maybe _ <- muid