Version bump and fix for old versions of TH.
This commit is contained in:
parent
997714f4c2
commit
6b000ecfb4
@ -1,3 +1,8 @@
|
|||||||
|
## 1.4.34
|
||||||
|
|
||||||
|
* Contexts can be included in generated TH instances. [1365](https://github.com/yesodweb/yesod/issues/1365)
|
||||||
|
* Type variables can be included in routes.
|
||||||
|
|
||||||
## 1.4.32
|
## 1.4.32
|
||||||
|
|
||||||
* Fix warnings
|
* Fix warnings
|
||||||
|
|||||||
@ -16,7 +16,11 @@ import Language.Haskell.TH.Syntax
|
|||||||
import qualified Network.Wai as W
|
import qualified Network.Wai as W
|
||||||
|
|
||||||
import Data.ByteString.Lazy.Char8 ()
|
import Data.ByteString.Lazy.Char8 ()
|
||||||
|
#if MIN_VERSION_base(4,8,0)
|
||||||
import Data.List (foldl', uncons)
|
import Data.List (foldl', uncons)
|
||||||
|
#else
|
||||||
|
import Data.List (foldl')
|
||||||
|
#endif
|
||||||
#if __GLASGOW_HASKELL__ < 710
|
#if __GLASGOW_HASKELL__ < 710
|
||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
#endif
|
#endif
|
||||||
@ -125,7 +129,13 @@ mkYesodGeneral' :: [[String]] -- ^ Appliction context. Used in Ren
|
|||||||
-> [ResourceTree String]
|
-> [ResourceTree String]
|
||||||
-> Q([Dec],[Dec])
|
-> Q([Dec],[Dec])
|
||||||
mkYesodGeneral' appCxt' namestr args isSub f resS = do
|
mkYesodGeneral' appCxt' namestr args isSub f resS = do
|
||||||
let appCxt = fmap (\(c:rest) -> foldl' (\acc v -> acc `AppT` nameToType v) (ConT $ mkName c) rest) appCxt'
|
let appCxt = fmap (\(c:rest) ->
|
||||||
|
#if MIN_VERSION_template_haskell(2,10,0)
|
||||||
|
foldl' (\acc v -> acc `AppT` nameToType v) (ConT $ mkName c) rest
|
||||||
|
#else
|
||||||
|
ClassP (mkName c) $ fmap nameToType rest
|
||||||
|
#endif
|
||||||
|
) appCxt'
|
||||||
mname <- lookupTypeName namestr
|
mname <- lookupTypeName namestr
|
||||||
arity <- case mname of
|
arity <- case mname of
|
||||||
Just name -> do
|
Just name -> do
|
||||||
@ -186,6 +196,12 @@ mkYesodGeneral' appCxt' namestr args isSub f resS = do
|
|||||||
]
|
]
|
||||||
return (dataDec, dispatchDec)
|
return (dataDec, dispatchDec)
|
||||||
|
|
||||||
|
#if !MIN_VERSION_base(4,8,0)
|
||||||
|
where
|
||||||
|
uncons (h:t) = Just (h,t)
|
||||||
|
uncons _ = Nothing
|
||||||
|
#endif
|
||||||
|
|
||||||
mkMDS :: (Exp -> Q Exp) -> Q Exp -> MkDispatchSettings a site b
|
mkMDS :: (Exp -> Q Exp) -> Q Exp -> MkDispatchSettings a site b
|
||||||
mkMDS f rh = MkDispatchSettings
|
mkMDS f rh = MkDispatchSettings
|
||||||
{ mdsRunHandler = rh
|
{ mdsRunHandler = rh
|
||||||
|
|||||||
@ -12,7 +12,9 @@ import Yesod.Routes.TH.Types
|
|||||||
import Language.Haskell.TH (conT)
|
import Language.Haskell.TH (conT)
|
||||||
#endif
|
#endif
|
||||||
import Language.Haskell.TH.Syntax
|
import Language.Haskell.TH.Syntax
|
||||||
|
#if MIN_VERSION_template_haskell(2,11,0)
|
||||||
import Data.Bits (xor)
|
import Data.Bits (xor)
|
||||||
|
#endif
|
||||||
import Data.Maybe (maybeToList)
|
import Data.Maybe (maybeToList)
|
||||||
import Control.Monad (replicateM)
|
import Control.Monad (replicateM)
|
||||||
import Data.Text (pack)
|
import Data.Text (pack)
|
||||||
@ -158,22 +160,27 @@ mkRenderRouteInstance' cxt typ ress = do
|
|||||||
(cons, decs) <- mkRouteCons ress
|
(cons, decs) <- mkRouteCons ress
|
||||||
#if MIN_VERSION_template_haskell(2,12,0)
|
#if MIN_VERSION_template_haskell(2,12,0)
|
||||||
did <- DataInstD [] ''Route [typ] Nothing cons <$> fmap (pure . DerivClause Nothing) (mapM conT (clazzes False))
|
did <- DataInstD [] ''Route [typ] Nothing cons <$> fmap (pure . DerivClause Nothing) (mapM conT (clazzes False))
|
||||||
|
let sds = fmap (\t -> StandaloneDerivD cxt $ ConT t `AppT` ( ConT ''Route `AppT` typ)) (clazzes True)
|
||||||
#elif MIN_VERSION_template_haskell(2,11,0)
|
#elif MIN_VERSION_template_haskell(2,11,0)
|
||||||
did <- DataInstD [] ''Route [typ] Nothing cons <$> mapM conT (clazzes False)
|
did <- DataInstD [] ''Route [typ] Nothing cons <$> mapM conT (clazzes False)
|
||||||
#else
|
|
||||||
let did = DataInstD [] ''Route [typ] cons (clazzes False)
|
|
||||||
#endif
|
|
||||||
let sds = fmap (\t -> StandaloneDerivD cxt $ ConT t `AppT` ( ConT ''Route `AppT` typ)) (clazzes True)
|
let sds = fmap (\t -> StandaloneDerivD cxt $ ConT t `AppT` ( ConT ''Route `AppT` typ)) (clazzes True)
|
||||||
|
#else
|
||||||
|
let did = DataInstD [] ''Route [typ] cons clazzes'
|
||||||
|
let sds = []
|
||||||
|
#endif
|
||||||
return $ instanceD cxt (ConT ''RenderRoute `AppT` typ)
|
return $ instanceD cxt (ConT ''RenderRoute `AppT` typ)
|
||||||
[ did
|
[ did
|
||||||
, FunD (mkName "renderRoute") cls
|
, FunD (mkName "renderRoute") cls
|
||||||
]
|
]
|
||||||
: sds ++ decs
|
: sds ++ decs
|
||||||
where
|
where
|
||||||
|
#if MIN_VERSION_template_haskell(2,11,0)
|
||||||
clazzes standalone = if standalone `xor` null cxt then
|
clazzes standalone = if standalone `xor` null cxt then
|
||||||
[''Show, ''Eq, ''Read]
|
clazzes'
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
#endif
|
||||||
|
clazzes' = [''Show, ''Eq, ''Read]
|
||||||
|
|
||||||
#if MIN_VERSION_template_haskell(2,11,0)
|
#if MIN_VERSION_template_haskell(2,11,0)
|
||||||
notStrict :: Bang
|
notStrict :: Bang
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-core
|
name: yesod-core
|
||||||
version: 1.4.32
|
version: 1.4.34
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user