From aebf9e6dd5c7163df4d260ca01e526228cca30f5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 22 Apr 2018 13:56:35 -0400 Subject: [PATCH] Fix build with yesod 1.6. Also avoid some depreaction warnings. --- Assistant/WebApp/Form.hs | 5 +++++ Assistant/WebApp/Types.hs | 9 +++++++++ CHANGELOG | 1 + Utility/Yesod.hs | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/Assistant/WebApp/Form.hs b/Assistant/WebApp/Form.hs index c2687c0dab..43b367d4ca 100644 --- a/Assistant/WebApp/Form.hs +++ b/Assistant/WebApp/Form.hs @@ -7,6 +7,7 @@ {-# LANGUAGE FlexibleContexts, TypeFamilies, QuasiQuotes #-} {-# LANGUAGE MultiParamTypeClasses, TemplateHaskell #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings, RankNTypes #-} module Assistant.WebApp.Form where @@ -67,7 +68,11 @@ withExpandableNote field (toggle, note) = withNote field $ [whamlet| ident = "toggle_" ++ toggle {- Adds a check box to an AForm to control encryption. -} +#if MIN_VERSION_yesod_core(1,6,0) +enableEncryptionField :: (RenderMessage site FormMessage) => AForm (HandlerFor site) EnableEncryption +#else enableEncryptionField :: (RenderMessage site FormMessage) => AForm (HandlerT site IO) EnableEncryption +#endif enableEncryptionField = areq (selectFieldList choices) (bfs "Encryption") (Just SharedEncryption) where choices :: [(Text, EnableEncryption)] diff --git a/Assistant/WebApp/Types.hs b/Assistant/WebApp/Types.hs index daefce84f9..11da2722bc 100644 --- a/Assistant/WebApp/Types.hs +++ b/Assistant/WebApp/Types.hs @@ -8,6 +8,7 @@ {-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses #-} {-# LANGUAGE TemplateHaskell, OverloadedStrings, RankNTypes #-} {-# LANGUAGE FlexibleInstances, FlexibleContexts, ViewPatterns #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Assistant.WebApp.Types ( @@ -94,7 +95,11 @@ instance LiftAnnex Handler where , liftAssistant $ liftAnnex a ) +#if MIN_VERSION_yesod_core(1,6,0) +instance LiftAnnex (WidgetFor WebApp) where +#else instance LiftAnnex (WidgetT WebApp IO) where +#endif liftAnnex = liftH . liftAnnex class LiftAssistant m where @@ -104,7 +109,11 @@ instance LiftAssistant Handler where liftAssistant a = liftIO . flip runAssistant a =<< assistantData <$> getYesod +#if MIN_VERSION_yesod_core(1,6,0) +instance LiftAssistant (WidgetFor WebApp) where +#else instance LiftAssistant (WidgetT WebApp IO) where +#endif liftAssistant = liftH . liftAssistant type MkMForm x = MForm Handler (FormResult x, Widget) diff --git a/CHANGELOG b/CHANGELOG index 126a80dc69..fe491223d3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ git-annex (6.20180410) UNRELEASED; urgency=medium as the move does not result in there being fewer copies. * Fix mangling of --json output of utf-8 characters when not running in a utf-8 locale. + * Fix build with yesod 1.6. -- Joey Hess Mon, 09 Apr 2018 14:03:28 -0400 diff --git a/Utility/Yesod.hs b/Utility/Yesod.hs index 0223f9fc4b..5e85f3147e 100644 --- a/Utility/Yesod.hs +++ b/Utility/Yesod.hs @@ -47,7 +47,11 @@ hamletTemplate f = globFile "hamlet" f #endif {- Lift Handler to Widget -} +#if MIN_VERSION_yesod_core(1,6,0) +liftH :: HandlerFor site a -> WidgetFor site a +#else liftH :: Monad m => HandlerT site m a -> WidgetT site m a +#endif liftH = handlerToWidget #if ! MIN_VERSION_yesod_core(1,2,20)