
17 May
2011
17 May
'11
6:32 p.m.
Another lazy question:
fun :: Int -> Int
foo a = runReader ask (fun a)
bar a = runReader (return 3) (fun a)
foo causes (fun a) to be evaluated but bar doesn't. Is the same true for database connections? Are they created lazily? I ask because it would be neat to be able to write:
runDB $ getFromCache cache key
where getFromCache queries the DB only on a cache miss, and have a connection created only in the case of a cache miss. I have tried test this myself, but I can't get ghci to cooperate and load yesod from source. Cheers, J