packages feed

yesod-routes 0.0.1 → 1.0.0

raw patch · 4 files changed

+36/−12 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Yesod.Routes.TH: mkRenderRouteInstance' :: Cxt -> Type -> [Resource Type] -> Q Dec

Files

Yesod/Routes/Dispatch.lhs view
@@ -61,7 +61,7 @@ >     , rhDispatch :: Dispatch res >     } -Your application needs to provide this moudle with a list of routes, and then+Your application needs to provide this module with a list of routes, and then this module will give you back a new dispatch function. In other words:  > toDispatch :: [Route res] -> Dispatch res
Yesod/Routes/TH/Dispatch.hs view
@@ -19,10 +19,10 @@  -- | ----- This function will generate a single clause that will address all your--- routing needs. It takes three arguments. The third (a list of 'Resource's)--- is self-explanatory. We\'ll discuss the first two. But first, let\'s cover--- the terminology.+-- This function will generate a single clause that will address all+-- your routing needs. It takes four arguments. The fourth (a list of+-- 'Resource's) is self-explanatory. We\'ll discuss the first+-- three. But first, let\'s cover the terminology. -- -- Dispatching involves a master type and a sub type. When you dispatch to the -- top level type, master and sub are the same. Each time to dispatch to@@ -63,7 +63,23 @@ -- > dispatcher :: master -> sub -> (Route sub -> Route master) -> app -> handler sub master -> Text -> [Text] -> app -- -- Where the parameters mean master, sub, toMaster, 404 response, 405 response,--- request method and path pieces.+-- request method and path pieces. This is the second argument of our function.+--+-- Finally, we need a way to decide which of the possible formats+-- should the handler send the data out. Think of each URL holding an+-- abstract object which has multiple representation (JSON, plain HTML+-- etc). Each client might have a preference on which format it wants+-- the abstract object in. For example, a javascript making a request+-- (on behalf of a browser) might prefer a JSON object over a plain+-- HTML file where as a user browsing with javascript disabled would+-- want the page in HTML. The third argument is a function that+-- converts the abstract object to the desired representation+-- depending on the preferences sent by the client.+--+-- The typical values for the first three arguments are,+-- @'yesodRunner'@ for the first, @'yesodDispatch'@ for the second and+-- @fmap 'chooseRep'@.+ mkDispatchClause :: Q Exp -- ^ runHandler function                  -> Q Exp -- ^ dispatcher function                  -> Q Exp -- ^ fixHandler function
Yesod/Routes/TH/RenderRoute.hs view
@@ -2,6 +2,7 @@ module Yesod.Routes.TH.RenderRoute     ( -- ** RenderRoute       mkRenderRouteInstance+    , mkRenderRouteInstance'     , mkRouteCons     , mkRenderRouteClauses     ) where@@ -89,12 +90,19 @@  -- | Generate the 'RenderRoute' instance. ----- This includes both the 'Route' associated type and the 'renderRoute' method.--- This function uses both 'mkRouteCons' and 'mkRenderRouteClasses'.+-- This includes both the 'Route' associated type and the+-- 'renderRoute' method.  This function uses both 'mkRouteCons' and+-- 'mkRenderRouteClasses'. mkRenderRouteInstance :: Type -> [Resource Type] -> Q Dec-mkRenderRouteInstance typ ress = do+mkRenderRouteInstance = mkRenderRouteInstance' []++-- | A more general version of 'mkRenderRouteInstance' which takes an+-- additional context.++mkRenderRouteInstance' :: Cxt -> Type -> [Resource Type] -> Q Dec+mkRenderRouteInstance' cxt typ ress = do     cls <- mkRenderRouteClauses ress-    return $ InstanceD [] (ConT ''RenderRoute `AppT` typ)+    return $ InstanceD cxt (ConT ''RenderRoute `AppT` typ)         [ DataInstD [] ''Route [typ] (mkRouteCons ress) clazzes         , FunD (mkName "renderRoute") cls         ]
yesod-routes.cabal view
@@ -1,6 +1,6 @@ name:            yesod-routes-version:         0.0.1-license:         BSD3+version:         1.0.0+license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com> maintainer:      Michael Snoyman <michael@snoyman.com>