From 62cdd6ba633a4bcef4ee707d944f2025ebec5435 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 13 Jan 2011 22:30:23 +0200 Subject: [PATCH] MonadTrans instances for GGHandler and GGWidget --- Yesod/Handler.hs | 3 +++ Yesod/Widget.hs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Yesod/Handler.hs b/Yesod/Handler.hs index 85354d50..3847bbda 100644 --- a/Yesod/Handler.hs +++ b/Yesod/Handler.hs @@ -213,6 +213,9 @@ newtype GGHandler sub master m a = } deriving (Functor, Applicative, Monad, MonadIO, MonadPeelIO) +instance MonadTrans (GGHandler s m) where + lift = GHandler . lift . lift . lift . lift + type GHandler sub master = GGHandler sub master (Iteratee ByteString IO) type GHInner s m monad = diff --git a/Yesod/Widget.hs b/Yesod/Widget.hs index 62a7cd07..df33ea1b 100644 --- a/Yesod/Widget.hs +++ b/Yesod/Widget.hs @@ -52,7 +52,7 @@ import Yesod.Handler ) import Control.Applicative (Applicative) import Control.Monad.IO.Class (MonadIO) -import Control.Monad.Trans.Class (lift) +import Control.Monad.Trans.Class (MonadTrans (lift)) import Yesod.Internal import Yesod.Content (RepHtml (RepHtml), Content, toContent) import Control.Monad (liftM) @@ -64,6 +64,10 @@ import Control.Monad.IO.Peel (MonadPeelIO) -- dependencies along with a 'StateT' to track unique identifiers. newtype GGWidget s m monad a = GWidget { unGWidget :: GWInner s m monad a } deriving (Functor, Applicative, Monad, MonadIO, MonadPeelIO) + +instance MonadTrans (GGWidget s m) where + lift = GWidget . lift . lift . lift . lift . lift . lift . lift . lift + type GWidget s m = GGWidget s m (GHandler s m) type GWInner sub master monad = WriterT (Body (Route master)) (