[Haskell-cafe] Help using CGIT
Rich Neswold
rich.neswold at gmail.com
Wed Aug 22 21:34:53 EDT 2007
On 8/22/07, Ian Lynagh <igloo at earth.li> wrote:
>
> On Wed, Aug 22, 2007 at 01:27:00PM -0500, Rich Neswold wrote:
> >
> > > newtype App a = App (ReaderT Connection (CGIT IO) a)
> > > deriving (Monad, MonadIO, MonadReader Connection)
> >
> > Unfortunately, when another module tries to actually use the monad, I
> > get warnings about "No instance for (MonadCGI App)". I tried making an
> > instance:
> >
> > > instance MonadCGI App where
> > > cgiAddHeader = ?
> > > cgiGet = ?
>
> You have three choices:
>
> 1:
>
> 2:
>
> 3:
> Provide a single instance for App that does the whole thing:
> instance MonadCGI App where
> cgiAddHeader n v = App $ lift $ cgiAddHeader n v
> cgiGet x = App $ lift $ cgiGet x
> This one you would obviously have to change if you added a StateT.
>
Bingo! Method #3 works beautifully! I missed the
using-lift-with-the-constructor permutation.
Thanks for your help!
--
Rich
JID: rich at neswold.homeunix.net
AIM: rnezzy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070822/f4fe0015/attachment.htm
More information about the Haskell-Cafe
mailing list