On Wednesday, June 27, 2012 5:21:42 AM UTC-4, Michael Snoyman wrote:
I think you're looking for getRouteToMaster[1]:
getSubRootR = do
toMaster <- getRouteToMaster
defaultLayout [whamlet|<a href=@{toMaster SubRootR}>Link to self|]
I thought that once I had intra-subsite links that forms would be easier to get, but that doesn’t seem to be the case. When I take the same code and add a POST to the SubRootR resource with the following function:
postSubRootR :: Yesod master => GHandler HelloSub master RepHtml
postSubRootR = do
name <- runInputPost $ ireq textField "content"
defaultLayout [whamlet|<p>Hello, #{name}|]
I get the error:
simple.hs:21:26:
Could not deduce (RenderMessage master FormMessage)
arising from a use of `ireq'
from the context (Yesod master)
bound by the type signature for
postSubRootR :: Yesod master => GHandler HelloSub master RepHtml
at simple.hs:(20,1)-(22,44)
Possible fix:
add (RenderMessage master FormMessage) to the context of
the type signature for
postSubRootR :: Yesod master => GHandler HelloSub master RepHtml
or add an instance declaration for
(RenderMessage master FormMessage)
In the second argument of `($)', namely `ireq textField "content"'
In a stmt of a 'do' block:
name <- runInputPost $ ireq textField "content"
In the expression:
do { name <- runInputPost $ ireq textField "content";
defaultLayout
(do { toWidget
((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
"<p>Hello, ");
toWidget (toHtml name);
.... }) }
When I naïvely change the function’s type to:
postSubRootR :: (RenderMessage master FormMessage, Yesod master) => GHandler HelloSub master RepHtml
I get the error:
simple.hs:11:1:
Could not deduce (RenderMessage master FormMessage)
arising from a use of `postSubRootR'
from the context (Yesod master)
bound by the instance declaration at simple.hs:(11,1)-(13,2)
or from (Yesod master)
bound by the type signature for
yesodDispatch :: Yesod master =>
master
-> HelloSub
-> (Route HelloSub -> Route master)
-> (Maybe (SessionBackend master) -> Application)
-> (Route HelloSub
-> Maybe (SessionBackend master) -> Application)
-> Data.Text.Internal.Text
-> [Data.Text.Internal.Text]
-> Maybe (SessionBackend master)
-> Application
at simple.hs:(11,1)-(13,2)
Possible fix:
add (RenderMessage master FormMessage) to the context of
the type signature for
yesodDispatch :: Yesod master =>
master
-> HelloSub
-> (Route HelloSub -> Route master)
-> (Maybe (SessionBackend master) -> Application)
-> (Route HelloSub -> Maybe (SessionBackend master) -> Application)
-> Data.Text.Internal.Text
-> [Data.Text.Internal.Text]
-> Maybe (SessionBackend master)
-> Application
or the instance declaration
or add an instance declaration for
(RenderMessage master FormMessage)
In the second argument of `fmap', namely `postSubRootR'
In the expression: fmap chooseRep postSubRootR
In the expression: \ -> fmap chooseRep postSubRootR
I looked for a function similar to getRouteToMaster for forms, but without success. Is there a way to transform a subsite form into a master form? If the error said it couldn’t deduce (RenderMessage HelloSub FormMessage), then I could add an instance for that, but it seems like it’s supposed to be the master site that determines the implementation of renderMessage.
Thanks again.
Cheers,
Jason Whittle