[web-devel] Yesod routes and Persistent entities in separate files

Michael Snoyman michael at snoyman.com
Mon Jan 3 20:50:59 CET 2011


Hi all,

The Yesod scaffolding tool currently does precisely one thing: produce
a scaffolded site. It does *not* provide any facilities for adding new
routes or entities after the fact, or creating basic CRUD interfaces
the way Rails or Django do. Nubis has proposed adding this
functionality. The current roadblock is that the Yesod routes and
Persistent entities are defined with quasi-quotation within the code.
I believe that technically speaking it should be possible to make this
kind of feature work, but it would make more sense to do it as a
separate file.

I think the proposal would essentially change:

mkYesod "MyApp" [$parseRoutes|...|]

to

mkYesod "MyApp" "MyApp.routes"

with the ... being in MyApp.routes, and a similar change for the
$persist quasi-quotation. What does everyone think of this? I see the
following advantages:

* Makes it more straight-forward to write these kinds of scaffolding tools.
* Gets away from quasi-quotation for those who have an aversion to it.

On the other hand, the downsides are:

* One more file to deal with.
* The standard issue of Haskell files not automatically recompiling
when an external files are changed. This can be worked around with
wai-handler-devel.

Another possibility is offering *both* options, but as much as
possible I'm trying to avoid creating multiple approaches.

Michael



More information about the web-devel mailing list