[Haskell-beginners] Snap 0.3 - problem with embedding IO operations
Karol Samborski
edv.karol at gmail.com
Mon Jan 10 13:45:23 CET 2011
Hi,
Recently I decided to port little project from snap 0.2 to 0.3 and I
saw there were many changes in style of writing code (I mean
heistLocal, render functions, extensions etc.).
In snap 0.2 I had some function that was fetching data from database
and then did some binding (via bindSplice) and finally disconnect from
database.
Here is the type of this function:
myPageBind :: TempleState Snap -> Snap (TempleState Snap)
Since Snap is instance of MonadIO I can use liftIO to embed IO
computations but now in the 0.3 version I have to pass this function
to heistLocal which type is:
heistLocal :: (TemplateState n -> TemplateState n) -> m a -> m a
so type of my function should be (in new version I need to have my
application monad so I used it from bare template project from snap
init) :
myPageBind :: TemplateState Application -> TemplateState Application
How then can I embed IO computations in that function? I can't use my
last function either because I don't how to get TemplateState m now.
Any suggestions?
I'm sorry for my English and lack of code because I'm in work now so I
don't have access to it.
Best regards,
Karol Samborski
More information about the Beginners
mailing list