Created
August 13, 2009 06:05
-
-
Save cmoore/167016 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localSession = do | |
h <- oc | |
res <- (execStatement h "SELECT session from facebook limit 1") :: IO (Either String [[Row String]]) | |
cc h | |
case res of | |
Right [[[(_,xx)]]] -> return xx | |
_ -> return "-1" | |
{- | |
How can I condense this? I can tell that I will probably need to do {} the case | |
statement, but I'm unclear how to get out of using do notation for the first part. | |
I keep trying to write something like | |
-} | |
localSession = oc >>= (\x -> execStatement x ...) >> cc h | |
{- | |
But I lose the value of the exec statement... or at least, I seem to. | |
Or is this the type of thing (ie. keeping a single handle open to the db and closing it | |
when finished) that would fit well inside a monad or somesuch? | |
-} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment