Splitting up Yesod's Foundation.hs into different modules

Viewed 36

Starting out with the scaffolded Yesod app, Foundation.hs has quite a lot going on. As my app has grown, I have been trying to split some functionality out into different modules. For example, the defaultLayout definition, and the related definition of MenuItem types, looks like something that would be better off moved to a separate module. However, my attempts to do so have been thwarted.

To define menu items as part of the defaultLayout requires importing Foundation to get the route data constructors (ie StaticR, AuthR and my own routes defined in config/routes), and importing Application to get the Yesod instances for the App type. But Foundation would need to import this module to define defaultLayout!

Is it possible to move this stuff into a separate module? How do people avoid massive monolithic Foundations?

0 Answers
Related