
On Wed, 11 Aug 2010 22:25:45 +0200
Ertugrul Soeylemez
My way of doing this is the following (snippet):
import Control.Applicative import MonadLib
type DatabaseT = ReaderT Connection
myApplication :: DatabaseT IO () myApplication = do dbConn <- ask inBase $ runRaw dbConn "SELECT now();"
runDatabaseT :: BaseM m IO => DatabaseT m a -> m a runDatabaseT c = do conn <- inBase $ connectPostgreSQL "" runReaderT (Config conn) c
main :: IO () main = runDatabaseT myApplication
thank you ertugrul. i understand the explanations you and MAN have provided regarding global variables. however, i don't understand what you have done above despite the illustrative game example. i've been in the middle of trying to get info out of a monad (as indicated in other posts) and have finally gotten by the errors (although the understanding hasn't quite congealed yet). as a result i haven't been able to try to incorporate the above yet (which is why i haven't responded till now). i did note that MonadLib doesn't seem to exist, so is that something i get from cabal? is ask part of it too?
What you want is not a global variable, but a convenient way to pass environment values to functions and computations.
yes that is what i want, but i haven't gotten the gist of the code you have provided me with yet. i need to understand types better for one thing.
I hope this helps.
it will. i've flagged your post and will come back to it after acquiring a bit more competence - as well as repetitive readings. -- In friendship, prad ... with you on your journey Towards Freedom http://www.towardsfreedom.com (website) Information, Inspiration, Imagination - truly a site for soaring I's