I'm writing a subsite for my yesod project, and I need to display the logged in user's name on that subsite (I'm using yesod-auth hardcoded where the type of AuthId master = Text).
However, the user is logged in on the master site. I'm able to get a value of type AuthId master using maybeAuthId, but I am unable to display this value because it is not an instance of Show.
Is there a type constraint I can put on my Handler to make sure the type of AuthId master derives Show?
getSubsiteHomeR :: (YesodAuth master) => HandlerT Subsite (HandlerT master IO) Html
getSubsiteHomeR = do
lift $ do
maid <- maybeAuthId -- I want to display the value of 'maid'
liftIO $ print maid
defaultLayout [whamlet|.......|]
EDIT: Here is the error message:
Could not deduce (Show (AuthId master))
arising from a use of `print'
from the context: YesodAuth master
bound by the type signature for:
getSubsiteHomeR :: YesodAuth master =>
HandlerT Subsite (HandlerT master IO) Html
at src/Subsite.hs:24:1-89
* In the second argument of `($)', namely `print maid'
In a stmt of a 'do' block: liftIO $ print maid
In the second argument of `($)', namely
`do { maid <- maybeAuthId;
liftIO $ print maid;
defaultLayout
(do { (asWidgetT . toWidget)
((blaze-markup-0.8.0.0:Text.Blaze.Internal.preEscapedText . T.pack)
"<p>Welcome to the Subsite!</br><a href=\"");
(getUrlRenderParams
>>=
(\ urender_alJ6
-> (asWidgetT . toWidget)
(toHtml
((\ u_alJ7 -> urender_alJ6 u_alJ7 ...)
(toParent SubsiteHomeR)))));
(asWidgetT . toWidget)
((blaze-markup-0.8.0.0:Text.Blaze.Internal.preEscapedText . T.pack)
"\">Subsite</br></a>\n\
\<a href=\"");
.... }) }'