Is it possible to have a subsite for a subsite in Yesod?

35 views
Skip to first unread message

Sergiu Starciuc

unread,
Jun 20, 2022, 1:54:42 AM6/20/22
to Yesod Web Framework
Is it possible to have a subsite for a subsite in Yesod?
That is, to navigate from a Yesod site to a subsite and from there to another subsite which is a subsite for previous subsite?

From https://www.yesodweb.com/book/understanding-request it seems to be possible:
"
ysreParentRunner provides a means of running a handler function. It may seem a bit boring to just provide yesodRunner, but by having a separate parameter we allow the construction of deeply nested subsites, which will wrap and unwrap many layers of interleaving subsites. (This is a more advanced concept which we won’t be covering in this chapter.)
"
Although I can't run the simplest scenario:
@SubData.hs
newtype Sub = Sub
  { getSubSub :: SubSub
  }

mkYesodSubData "Sub" [parseRoutes|
/        SubHomeR GET
/sub-sub SubSubR SubSub getSubSub
|]

@Sub.hs
getSubHomeR :: SubHandlerFor Sub m Html
getSubHomeR = error "TODO"

instance YesodSubDispatch Sub m where
  yesodSubDispatch = $(mkYesodSubDispatch resourcesSub)

I get a compilation error instead:

‘(mkYesodSubDispat...’: • Couldn't match expected type: Yesod.Core.Types.YesodSubRunnerEnv
                                  Sub master0
              with actual type: Yesod.Core.Types.YesodRunnerEnv Sub
• In the second argument of ‘yesod-core-1.6.23.1:Yesod.Core.Class.Dispatch.subHelper’, namely


Reply all
Reply to author
Forward
0 new messages