packages feed

yesod-core 1.4.14 → 1.4.15

raw patch · 4 files changed

+30/−18 lines, 4 filesdep ~basedep ~bytestringdep ~conduit-extra

Dependency ranges changed: base, bytestring, conduit-extra, template-haskell

Files

ChangeLog.md view
@@ -1,10 +1,17 @@+## 1.4.15++* mkYesod avoids using reify when it isn't necessary. This avoids needing to define the site type below the call to mkYesod.+ ## 1.4.14  * Add CSRF protection functions and middleware based on HTTP cookies and headers [#1017](https://github.com/yesodweb/yesod/pull/1017)+* Add mkYesodWith, which allows creating sites with polymorphic type parameters [#1055](https://github.com/yesodweb/yesod/pull/1055)+* Do not define the site type below a call to mkYesod (or any variant), as it will be required at splicing time for reification.+  This was allowed before because reification was not in use. Reification was introduced to allow parametrized types to be used+  by mkYesod (and variants), with potentially polymorphic variables.  ## 1.4.13 -* Add mkYesodGeneral, which allows creating sites with polymorphic type parameters [#1055](https://github.com/yesodweb/yesod/pull/1055) * Add getsYesod function [#1042](https://github.com/yesodweb/yesod/pull/1042) * Add IsString instance for WidgetT site m () [#1038](https://github.com/yesodweb/yesod/pull/1038) 
Yesod/Core/Internal/TH.hs view
@@ -9,7 +9,7 @@ import Prelude hiding (exp) import Yesod.Core.Handler -import Language.Haskell.TH+import Language.Haskell.TH hiding (cxt) import Language.Haskell.TH.Syntax  import qualified Network.Wai as W@@ -76,17 +76,22 @@                -> Bool                     -- ^ is this a subsite                -> [ResourceTree String]                -> Q([Dec],[Dec])-mkYesodGeneral name args isSub resS = do-    info <- reify $ mkName name-    let arity =-          case info of-            TyConI dec ->-              case dec of-                DataD _ _ vs _ _ -> length vs-                NewtypeD _ _ vs _ _ -> length vs-                _ -> 0-            _ -> 0-        (mtys,ptys) = partitionEithers args+mkYesodGeneral namestr args isSub resS = do+    mname <- lookupTypeName namestr+    arity <- case mname of+               Just name -> do+                 info <- reify name+                 return $+                   case info of+                     TyConI dec ->+                       case dec of+                         DataD _ _ vs _ _ -> length vs+                         NewtypeD _ _ vs _ _ -> length vs+                         _ -> 0+                     _ -> 0+               _ -> return 0+    let name = mkName namestr+        (mtys,_) = partitionEithers args     -- Generate as many variable names as the arity indicates     vns <- replicateM (arity - length mtys) $ newName "t"         -- Base type (site type with variables)@@ -103,13 +108,13 @@ #endif                                           ) ts ++ cs )                  ) ([],vns,[]) args-        site = foldl' AppT (ConT $ mkName name) argtypes+        site = foldl' AppT (ConT name) argtypes         res = map (fmap parseType) resS     renderRouteDec <- mkRenderRouteInstance site res     routeAttrsDec  <- mkRouteAttrsInstance site res     dispatchDec    <- mkDispatchInstance site cxt res     parse <- mkParseRouteInstance site res-    let rname = mkName $ "resources" ++ name+    let rname = mkName $ "resources" ++ namestr     eres <- lift resS     let resourcesDec =             [ SigD rname $ ListT `AppT` (ConT ''ResourceTree `AppT` ConT ''String)
test/YesodCoreTest/RawResponse.hs view
@@ -24,13 +24,13 @@ import Network.HTTP.Types (status200) import Blaze.ByteString.Builder (fromByteString) -data App = App- mkYesod "App" [parseRoutes| / HomeR GET /wai-stream WaiStreamR GET /wai-app-stream WaiAppStreamR GET |]++data App = App  instance Yesod App 
yesod-core.cabal view
@@ -1,5 +1,5 @@ name:            yesod-core-version:         1.4.14+version:         1.4.15 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>