Switch all HandlerT/WidgetT uses to HandlerFor/WidgetFor

This commit is contained in:
fr33domlover 2019-05-23 09:12:24 +00:00
parent c531f41565
commit b64984495f
5 changed files with 11 additions and 12 deletions

View file

@ -326,5 +326,5 @@ handler :: Handler a -> IO a
handler h = getAppSettings >>= makeFoundation >>= flip unsafeHandler h handler h = getAppSettings >>= makeFoundation >>= flip unsafeHandler h
-- | Run DB queries -- | Run DB queries
db :: ReaderT SqlBackend (HandlerT App IO) a -> IO a db :: ReaderT SqlBackend (HandlerFor App) a -> IO a
db = handler . runDB db = handler . runDB

View file

@ -135,12 +135,12 @@ type LocalMessageKeyHashid = KeyHashid LocalMessage
-- http://www.yesodweb.com/book/scaffolding-and-the-site-template#scaffolding-and-the-site-template_foundation_and_application_modules -- http://www.yesodweb.com/book/scaffolding-and-the-site-template#scaffolding-and-the-site-template_foundation_and_application_modules
-- --
-- This function also generates the following type synonyms: -- This function also generates the following type synonyms:
-- type Handler = HandlerT App IO -- type Handler = HandlerFor App
-- type Widget = WidgetT App IO () -- type Widget = WidgetFor App ()
mkYesodData "App" $(parseRoutesFile "config/routes") mkYesodData "App" $(parseRoutesFile "config/routes")
-- | A convenient synonym for creating forms. -- | A convenient synonym for creating forms.
type Form a = Html -> MForm (HandlerT App IO) (FormResult a, Widget) type Form a = Html -> MForm (HandlerFor App) (FormResult a, Widget)
type AppDB = YesodDB App type AppDB = YesodDB App

View file

@ -34,7 +34,6 @@ import Data.Traversable
import Formatting (sformat, stext, int, (%)) import Formatting (sformat, stext, int, (%))
import Yesod.Core import Yesod.Core
import Yesod.Core.Handler import Yesod.Core.Handler
import Yesod.Core.Widget (WidgetT)
import qualified Data.Text as T (null, pack) import qualified Data.Text as T (null, pack)
import qualified Data.Text.Read as TR (decimal) import qualified Data.Text.Read as TR (decimal)
@ -106,7 +105,7 @@ getPageAndNavTop
-> m (Int, Int, f i, NavModel) -> m (Int, Int, f i, NavModel)
getPageAndNavTop select = paginateTop (paginateSettings select) navSettings getPageAndNavTop select = paginateTop (paginateSettings select) navSettings
navWidget :: NavModel -> WidgetT site IO () navWidget :: NavModel -> WidgetFor site ()
navWidget nm = do navWidget nm = do
route <- route <-
fromMaybe (error "Pagination in invalid response content") <$> fromMaybe (error "Pagination in invalid response content") <$>

View file

@ -40,12 +40,12 @@ import Vervis.Settings (widgetFile)
import Vervis.Style import Vervis.Style
import Vervis.Time (showDate) import Vervis.Time (showDate)
breadcrumbsW :: YesodBreadcrumbs site => WidgetT site IO () breadcrumbsW :: YesodBreadcrumbs site => WidgetFor site ()
breadcrumbsW = do breadcrumbsW = do
(current, bcs) <- handlerToWidget breadcrumbs (current, bcs) <- handlerToWidget breadcrumbs
$(widgetFile "widget/breadcrumbs") $(widgetFile "widget/breadcrumbs")
revisionW :: WidgetT site IO () revisionW :: WidgetFor site ()
revisionW = revisionW =
let cgTimeFmt = showDate . cgTime let cgTimeFmt = showDate . cgTime
mrev = $darcsRevision mrev = $darcsRevision
@ -54,7 +54,7 @@ revisionW =
changes = $darcsTotalPatches :: Int changes = $darcsTotalPatches :: Int
in $(widgetFile "widget/revision") in $(widgetFile "widget/revision")
avatarW :: Bool -> Text -> WidgetT site IO () avatarW :: Bool -> Text -> WidgetFor site ()
avatarW secure email = do avatarW secure email = do
murl <- getAvatarUrl secure email murl <- getAvatarUrl secure email
[whamlet| [whamlet|
@ -65,7 +65,7 @@ avatarW secure email = do
<p>INVALID EMAIL <p>INVALID EMAIL
|] |]
buttonW :: StdMethod -> Text -> Route site -> WidgetT site IO () buttonW :: StdMethod -> Text -> Route site -> WidgetFor site ()
buttonW method content route = do buttonW method content route = do
let tokenKey = defaultCsrfParamName let tokenKey = defaultCsrfParamName
mtoken <- reqToken <$> getRequest mtoken <- reqToken <$> getRequest

View file

@ -34,7 +34,7 @@ import Data.Default.Class
import Data.Text (Text) import Data.Text (Text)
import Text.Blaze (ToMarkup) import Text.Blaze (ToMarkup)
import Yesod.Core import Yesod.Core
import Yesod.Core.Widget (WidgetT, whamlet) import Yesod.Core.Widget
import qualified Data.Text as T (pack) import qualified Data.Text as T (pack)
import qualified Formatting as F import qualified Formatting as F
@ -76,7 +76,7 @@ pageNavWidget
=> NavModel => NavModel
-> NavWidgetSettings -> NavWidgetSettings
-> (Int -> (Route site, t)) -> (Int -> (Route site, t))
-> WidgetT site IO () -> WidgetFor site ()
pageNavWidget nm nws mklink = pageNavWidget nm nws mklink =
let link n label = let link n label =
let (route, suffix) = mklink n let (route, suffix) = mklink n