[web-devel] Template Haskell intricacies with mkPersist

Michael Snoyman michael at snoyman.com
Tue May 10 05:15:06 CEST 2011

Basically, consider each Template Haskell splice to be a roadblock:
functions before it cannot reference functions after it. In the case
of Yesod, I would recommend you look at how the default scaffolded
site is structured. In particular, instead of using mkYesod, it uses a
combination of mkYesodData and mkYesodDispatch to try and work around
some of these issues.


On Tue, May 10, 2011 at 1:20 AM, Patrick Palka <patrick at parcs.ath.cx> wrote:
> Hey,
> I've attached a file that fails to compile, resulting in a "not in scope:
> getHomeR" error message. The culprit seems to be the mkPersist TH splice,
> which, when ocurring before the getHomeR view, causes it to not be seen by
> GHC when it parses the mkYesod splice. Moving the mkPersist splice to occur
> after the getHomeR view will alleviate this problem, but then one can't use
> the data constructors that mkPersist generates within the getHomeR view.
> Moving the mkPersist splice into a seperate module and importing that works
> perfectly fine, however.
> Can anyone clarify what is going on?
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel

More information about the web-devel mailing list