ytl-0.1.0.0: mtl-style transformations for Yesod sites
Safe HaskellNone
LanguageHaskell2010

Yesod.Trans.TH

Synopsis

Documentation

defaultYesodInstanceExcept Source #

Arguments

:: Q Exp

How to go from the wrapped site to the base site. If the instance is for a type of the form 't site', then this should be an expression of type 't site -> site'. This operation is necessary to use some of the default implementations.

-> Q [Dec]

The partial Yesod instance. Should just be a since instance declaration, except that its body can be as empty as you like. For example:

defaultYesodInstanceExcept [| myLowerer |] [d|
  instance (Yesod site) => Yesod (MyWrapper site) where
    yesodMiddleware = ... -- insert some middleware

    -- But everything else should be defined in the default way
  |]

This declaration will include the custom definition for yesodMiddleware, as well as implementations for the other class methods that just delegate to the base class.

-> Q [Dec] 

Fills in an instance for the Yesod class for a SiteTrans wrapper with implementations which just invoke the base class, *except* for those implementations which are defined on the instance itself.

This is useful for SiteTrans implementations that want to modify some of the Yesod behaviour of the site, but mostly want to delegate behaviour to the base site. Instead of writing out a whole Yesod instance, you can just override the class methods that you need. The rest will be filled in with working implementations that do what you expect.