
On Aug 23, 2007, at 3:34 , Rich Neswold wrote:
On 8/22/07, Ian Lynagh
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!
I started writing a tutorial for Haskell web programming with the cgi package a while back, but haven't worked on it for a while, see http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell I haven't added it to the list of tutorials yet, since it's still rather incomplete. The section on using CGIT is just a stub, perhaps you would like to contribute to it? See http://www.haskell.org/haskellwiki/ Practical_web_programming_in_Haskell#Extending_the_CGI_monad_with_monad_ transformers /Björn